Author

Topic: ToyTrader - a daytrading command line tool for mtgox (Read 6479 times)

newbie
Activity: 11
Merit: 0
That did the trick. Thanks again! Smiley
newbie
Activity: 9
Merit: 0
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. :-)
newbie
Activity: 11
Merit: 0
Thank you very much, twinpeaks, that solved the problem.

Now i get the same output like you.
newbie
Activity: 9
Merit: 0
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?

full member
Activity: 162
Merit: 100
 Wow! Nice! Will try later.
newbie
Activity: 11
Merit: 0
Like i said i already got this error days before MtGox was down.
kjj
legendary
Activity: 1302
Merit: 1026
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.
newbie
Activity: 11
Merit: 0
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:
newbie
Activity: 6
Merit: 0
Huh, thanx for feedback, please give me some time to make changes Wink
sr. member
Activity: 408
Merit: 261
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.
newbie
Activity: 6
Merit: 0
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
sr. member
Activity: 408
Merit: 261
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.
newbie
Activity: 6
Merit: 0
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.
sr. member
Activity: 408
Merit: 261
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
newbie
Activity: 6
Merit: 0
i guess that I fixed it. Used fgets() instead of readline(). Please download new version Wink Enjoy.
newbie
Activity: 39
Merit: 0
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!

newbie
Activity: 6
Merit: 0
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 - refresh stats,
H - displays short help
S amount price - 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 - 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 - list all your active trade orders
C oid type - cancels order with oid and type i.e. "c 272654 1" cancels sell order number 272654
T [num] - list last num trades on mtgox (default 10)
Q - quit program

Jump to: