Bitcoin Forum
December 03, 2016, 03:52:19 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: ToyTrader - a daytrading command line tool for mtgox  (Read 6175 times)
toyotasupra
Newbie
*
Offline Offline

Activity: 6


View Profile
May 19, 2011, 06:18:59 PM
 #1

Hello,

i'd like to introduce a a very early version of command line trading tool for mtgox. It's very usable for me, so i guess that it will be usable for more bitcoin users...

https://github.com/toyotasupra/ToyTrader

Please put feedback here, also please donate:  1N8b1uzWA7RsfVPmA2kdGSEmsv91zTRMAX Grin

Config: edit config.inc.php

Usage: php -q mtgox.php

Commands:
^M or <enter> - refresh stats,
H<enter> - displays short help
S amount price<enter> - sell amount of btc at price i.e. "s 10 7.01" makes mtgox order for selling 10 btc at 7.01$, you can also use "s all 7.09" for selling all available btc at 7.09
B amount price<enter> - buy amount of btc at price i.e. "b 5 6.5" makes mtgox order for buying 5 btc at 6.5$, you can also use "b all 6.66" for buying btc for all available $ at price 6.66
L<enter> - list all your active trade orders
C oid type<enter> - cancels order with oid and type i.e. "c 272654 1" cancels sell order number 272654
T [num]<enter> - list last num trades on mtgox (default 10)
Q<enter> - quit program

1480780339
Hero Member
*
Offline Offline

Posts: 1480780339

View Profile Personal Message (Offline)

Ignore
1480780339
Reply with quote  #2

1480780339
Report to moderator
1480780339
Hero Member
*
Offline Offline

Posts: 1480780339

View Profile Personal Message (Offline)

Ignore
1480780339
Reply with quote  #2

1480780339
Report to moderator
1480780339
Hero Member
*
Offline Offline

Posts: 1480780339

View Profile Personal Message (Offline)

Ignore
1480780339
Reply with quote  #2

1480780339
Report to moderator
Satoshi is no god. He did not come down from the mountain with 10 golden rules engraved in stone for no one to question.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480780339
Hero Member
*
Offline Offline

Posts: 1480780339

View Profile Personal Message (Offline)

Ignore
1480780339
Reply with quote  #2

1480780339
Report to moderator
yomi
Jr. Member
*
Offline Offline

Activity: 40


View Profile
May 19, 2011, 06:24:41 PM
 #2

Great work!

I am run it but got this:

Code:
$ php -q mtgox.php
ToyTrader v. 0.0.2 - command line mtgox trading tool
DONATE for FASTER development: 1N8b1uzWA7RsfVPmA2kdGSEmsv91zTRMAX
For help type: H and press enter

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead in /Users/edu/hacking/bitcoin/ToyTrader/mtgox.php on line 31
== 2011-05-19 20:22:49 ================================
USD:   BTC:
Last: 6.85
BUY OFFERS SELL OFFERS
6.81 23.45 6.85599 2
6.8 39.085 6.85699 2
6.76 10.919 6.85899 2
6.7502 29.5 6.872 2
6.75011 314.22 6.873 2
6.75 8 6.874 2
6.745 22.7 6.9415 37.57
6.72 1.2 6.945 100
6.7011 1 6.95 5
6.701 5 6.99 5.14

Fatal error: Call to undefined function readline() in /Users/edu/hacking/bitcoin/ToyTrader/mtgox.php on line 59

This is Mac OS X 10.6

Thanks!


17qXiw646kuukEwjArHNKCNPUh3HnXfgbw
toyotasupra
Newbie
*
Offline Offline

Activity: 6


View Profile
May 19, 2011, 08:49:53 PM
 #3

i guess that I fixed it. Used fgets() instead of readline(). Please download new version Wink Enjoy.
toffoo
Sr. Member
****
Offline Offline

Activity: 392



View Profile
May 21, 2011, 04:53:13 AM
 #4

Congratulations on this very interesting little project, and thanks for sharing.

I had one major problem/comment for you on this:

The order depth table does not appear to be synched or correct for me.  It's either lagged, delayed, (cached?), or missing the top few best buy/sell orders.  I can't tell without taking a closer read of your code if this is ToyTrader's problem or with Mt.Gox's API (I would assume the former) but when I run and update this, the order depth chart is not the same as what is shown on https://mtgox.com/trade/history

Thanks again for sharing this and I look forward to seeing further refinements.

ps: I couldn't for the life of me get rid of that timezone warning that comes up with every refresh.  I finally fixed it by just putting it in the command line:

php -d date.timezone="America/mytimezone" -q mtgox.php

toyotasupra
Newbie
*
Offline Offline

Activity: 6


View Profile
May 21, 2011, 08:37:26 PM
 #5

Thanks for your interest Wink

New version (0.0.4) sorts a feed from mtgox, so if appears any differences - they are on mtgox side. Each refresh downloads a new data from mtgox, and never cache it.
toffoo
Sr. Member
****
Offline Offline

Activity: 392



View Profile
May 21, 2011, 08:54:48 PM
 #6

Hello again,

Thanks for checking this out.

But I just tried v.0.0.4 and it looks like the depth chart is still missing the top best bid and ask prices.  I looked at the raw Mt.Gox API JSON data and they are there, so maybe check if your code is doing something screwy with the first entry in the list or something.

Thanks again.

toyotasupra
Newbie
*
Offline Offline

Activity: 6


View Profile
May 22, 2011, 01:31:04 AM
 #7

OMG. what a shame... it was classic mistake, i forgot that arrays in php is from 0 Wink

Please update mtgox.php from github 0.0.5 version.

Thanks Wink
toffoo
Sr. Member
****
Offline Offline

Activity: 392



View Profile
May 23, 2011, 06:39:30 PM
 #8

OMG. what a shame... it was classic mistake, i forgot that arrays in php is from 0 Wink

Great, looks much better now.  (I'm no PHP programming expert, but I figured it was something like that.)

I would say that this little tool borders on being quite useful already.  Here are a few other thoughts for improvement:

1.) there should be a quick command to immediately cancel all open orders, perhaps just "c" or "c all".  When things are moving fast it can be real tough to "l" to list all the open orders and then type in "c" with the each oid to cancel everything.

2.) there are a few places, like "t" to list the recent trades, where the timestamps are in Unix time.  They should probably be converted to human readable format.

3.) I cannot backspace once typing in a command or an order.  If I mess up, I need to Ctrl-C the entire script because my backspace just gives ^H at your command line (but works fine as a backspace in my shell).

4.) maybe a header row for the "l" list that explains what all the numbers are.

I'll let you know if I can think of anything else useful as I start to use this more.

Thanks again for this fun little tool and I look forward to any further refinements.

toyotasupra
Newbie
*
Offline Offline

Activity: 6


View Profile
May 25, 2011, 05:05:12 PM
 #9

Huh, thanx for feedback, please give me some time to make changes Wink
romsek
Newbie
*
Offline Offline

Activity: 11


View Profile
June 20, 2011, 01:33:52 AM
 #10

For some reason, your application is not working anymore for me.

All i get is this (i got this error days before MTGox was down):

Code:
== 2011-06-19 06:54:16 ================================
*** curllib: Operation timed out after 30001 milliseconds with 0 bytes received
PHP Notice:  Trying to get property of non-object in /home/peter/toyotasupra-ToyTrader-7825748/mtgox.php on line 35
PHP Notice:  Trying to get property of non-object in /home/peter/toyotasupra-ToyTrader-7825748/mtgox.php on line 36
USD:   BTC:
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
June 20, 2011, 01:42:10 AM
 #11

For some reason, your application is not working anymore for me.

All i get is this (i got this error days before MTGox was down):

Code:
== 2011-06-19 06:54:16 ================================
*** curllib: Operation timed out after 30001 milliseconds with 0 bytes received
PHP Notice:  Trying to get property of non-object in /home/peter/toyotasupra-ToyTrader-7825748/mtgox.php on line 35
PHP Notice:  Trying to get property of non-object in /home/peter/toyotasupra-ToyTrader-7825748/mtgox.php on line 36
USD:   BTC:

Mtgox is currently down.  For more information, head on over to the discussion forum and read any of the last 300 threads or so.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
romsek
Newbie
*
Offline Offline

Activity: 11


View Profile
June 20, 2011, 04:02:46 AM
 #12

Like i said i already got this error days before MtGox was down.
TheRandomGuy
Full Member
***
Offline Offline

Activity: 163


View Profile
June 20, 2011, 05:08:35 PM
 #13

 Wow! Nice! Will try later.

BTC: 1wbGAAabrsu8pjVXWUQvjUUhe18e721K2
FAUCET ROTATOR SCRIPT
twinpeaks
Newbie
*
Offline Offline

Activity: 9


View Profile
June 29, 2011, 06:16:52 PM
 #14

Hi,

*** curllib: Operation timed out after 30001 milliseconds with 0 bytes received

This can be avoided by inserting
Code:
curl_setopt ($ch, CURLOPT_USERAGENT, 'Wget/1.9.1');
in the function doRequest() in file curlib3.inc.php.
(found this tip on the mtgox support forum).

But starting with the MtGox restart, there is another problem: the script hangs after displaying the funds. What I get is only:
Code:
ToyTrader v. 0.0.5 - command line mtgox trading tool
DONATE for FASTER development: 1N8b1uzWA7RsfVPmA2kdGSEmsv91zTRMAX
For help type: H and press enter
== 2011-06-29 20:15:10 ================================
USD: xxx.xx  BTC: yyy.yy

Did the API change somehow?

romsek
Newbie
*
Offline Offline

Activity: 11


View Profile
June 29, 2011, 06:32:42 PM
 #15

Thank you very much, twinpeaks, that solved the problem.

Now i get the same output like you.
twinpeaks
Newbie
*
Offline Offline

Activity: 9


View Profile
June 29, 2011, 07:59:51 PM
 #16

Hey, just got it working again!

I added
Code:
user_agent="PHP"
to my php.ini

Instead of inserting
Code:
curl_setopt ($ch, CURLOPT_USERAGENT, 'Wget/1.9.1');
uncommenting the line
Code:
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)');
works too.

The entry in php.ini alone is not enough, it seems you also have to set one of the useragents in curllib3.inc.php.

The formatting is a little off, but it works. :-)
romsek
Newbie
*
Offline Offline

Activity: 11


View Profile
June 29, 2011, 09:07:34 PM
 #17

That did the trick. Thanks again! Smiley
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!