molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
July 02, 2011, 08:56:34 PM Last edit: August 08, 2011, 08:29:24 AM by molecular |
|
I made a simple trading client for the mtgox trading api a while back: https://github.com/molecular/traidor I gave it an overhaul and I thought I'd share it, maybe someone likes it. Features: - display market depth and recent trades
- display mtgox balances (BTC, USD)
- manage own orders (view, buy, sell, cancel)
To get started, first checkout the code: #> git clone git://github.com/molecular/traidor.git #> cd traidor
then prepare config-file and start traidor: #> cp traidor.conf.sample traidor.conf #> edit traidor.conf #> python traidor.py
The most important commands: -----------command------------- | ----------action------------ | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | a | toggle auto-update on/off | b <amount> <price> | enter order to buy <amount> btc at <price> | s <amount> <price> | enter order to sell <amount> btc at <price> | o | view your order book | d <index> | delete order at <index> from orderbook |
Note: you must use a decimal point (".") when entering the <price> of an order. If you dont, <price> is interpreted as an index in the depth table (1st column "[IDX]") and the order is placed just above/below the price at that index. If you use and like it, consider a small donation to 1Ct1vCN6idU1hKrRcmR96G4NgAgrswPiCn
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 08, 2011, 08:23:03 AM |
|
during the last weeks I made quite a few improvements to traidor: - use websocket implementation made by Giel (more stable)
- avoid queue-up of websocket messages by using asynchronous display thread
- be able to set market depth display precision (key "p")
- many small bugfixes
- improve connection trouble handling (catch exceptions, retry)
Any suggestions or bug reports always welcome.
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
GamblingPurveyor
Member
Offline
Activity: 280
Merit: 10
|
|
August 09, 2011, 06:04:54 PM Last edit: August 09, 2011, 07:30:02 PM by GamblingPurveyor |
|
Storing the password in traidor.conf is insecure. An alternative is needed. Perhaps the password could be read from the TTY if the user doesn't provide it in traidor.conf.
Also, the program should check the $LINES and $COLUMNS environment variables every time it updates the screen, instead of having to set it manually with the d menu option.
|
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 09, 2011, 08:31:26 PM |
|
Storing the password in traidor.conf is insecure. An alternative is needed. Perhaps the password could be read from the TTY if the user doesn't provide it in traidor.conf.
True. I will switch to using api-key, like goxsh does, with encrypted secret. Password authentication will be switched off for the api at some point anyhow. Your suggestion is a good way to deal with it in the meantime. If I get around, I'll implement that. Also, the program should check the $LINES and $COLUMNS environment variables every time it updates the screen, instead of having to set it manually with the d menu option.
That's a good suggestion. Will probably implement that. Thanks for your feedback!
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
ffuentes
Member
Offline
Activity: 70
Merit: 10
Only a curious passer-by / FirstBits: 13zsc1
|
|
August 09, 2011, 08:42:42 PM |
|
I hope this script don't betray me!
|
|
|
|
GamblingPurveyor
Member
Offline
Activity: 280
Merit: 10
|
|
August 09, 2011, 09:07:17 PM |
|
WTF? I just noticed that this program uses the sound card to make strange "ticking" noises.
|
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 09, 2011, 10:24:02 PM |
|
I hope this script don't betray me!
The source code is right there to check. I'm sure if I inserted malicious code, it'd be reported here quite quickly.
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 10, 2011, 09:24:42 AM |
|
WTF? I just noticed that this program uses the sound card to make strange "ticking" noises.
Yeah, that's the "ClickBot". I should probably make that optional or start it by command. btw, you can also set an alarm using the TriggerBot: mtgox | x BTC | y USD #> tb >= 12.5 ps alarm.wav
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 10, 2011, 09:25:36 AM |
|
Storing the password in traidor.conf is insecure. An alternative is needed. Perhaps the password could be read from the TTY if the user doesn't provide it in traidor.conf.
Also, the program should check the $LINES and $COLUMNS environment variables every time it updates the screen, instead of having to set it manually with the d menu option.
Hmm, I tried reading $LINES from os.environ, it's not in there. while "echo $LINES" in bash works, "env | grep LINES" doesn't show it either. Any hint for me?
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
GamblingPurveyor
Member
Offline
Activity: 280
Merit: 10
|
|
August 10, 2011, 11:27:02 PM |
|
After leaving this program running for 6-8 hours, I found this: mtgox | 0 BTC | 0.00458 USD | [h]elp #> Fatal Python error: (pygame parachute) Segmentation Fault Aborted gambler@irony:~/src/traidor$
|
|
|
|
infested999
|
|
August 15, 2011, 12:35:04 PM |
|
What version of python should I be using? jonny@netbook:~/traidor$ python traidor.py Traceback (most recent call last): File "traidor.py", line 21, in <module> from wxgui import * File "/home/jonny/traidor/wxgui.py", line 4, in <module> import wx ImportError: No module named wx jonny@netbook:~/traidor$ python python python2.6 python3.2 python3.2mu jonny@netbook:~/traidor$ python --version Python 2.6.7
|
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 15, 2011, 05:32:28 PM |
|
What version of python should I be using? jonny@netbook:~/traidor$ python traidor.py Traceback (most recent call last): File "traidor.py", line 21, in <module> from wxgui import * File "/home/jonny/traidor/wxgui.py", line 4, in <module> import wx ImportError: No module named wx jonny@netbook:~/traidor$ python python python2.6 python3.2 python3.2mu jonny@netbook:~/traidor$ python --version Python 2.6.7 The problem is you're missing wx tooklit, which I don't actually use currently anyways, so I commented out the import. Do a "git pull" and try again. Python 2.6.7 should work, 3.2 also, probably. I have 2.6.6
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
infested999
|
|
August 15, 2011, 07:22:17 PM |
|
What version of python should I be using? jonny@netbook:~/traidor$ python traidor.py Traceback (most recent call last): File "traidor.py", line 21, in <module> from wxgui import * File "/home/jonny/traidor/wxgui.py", line 4, in <module> import wx ImportError: No module named wx jonny@netbook:~/traidor$ python python python2.6 python3.2 python3.2mu jonny@netbook:~/traidor$ python --version Python 2.6.7 The problem is you're missing wx tooklit, which I don't actually use currently anyways, so I commented out the import. Do a "git pull" and try again. Python 2.6.7 should work, 3.2 also, probably. I have 2.6.6 Thanks, that worked. When I use the "gui" command I get this. mtgox | 0 BTC | x.xxxxx USD | [h]elp #> gui Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner self.run() File "/usr/lib/python2.6/threading.py", line 484, in run self.__target(*self.__args, **self.__kwargs) File "traidor.py", line 714, in __call__ S.cmd(key) File "traidor.py", line 576, in cmd wx = TraidorApp(t) NameError: global name 'TraidorApp' is not defined Is this error just for me, or is the feature just not implemented yet?
|
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
August 15, 2011, 07:56:22 PM |
|
When I use the "gui" command I get this.
Is this error just for me, or is the feature just not implemented yet?
No, gui is not implemented and doesn't have high priority at all. First comes support for other exchanges, then probably some bots.
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
GamblingPurveyor
Member
Offline
Activity: 280
Merit: 10
|
|
August 18, 2011, 03:56:31 AM |
|
Storing the password in traidor.conf is insecure. An alternative is needed. Perhaps the password could be read from the TTY if the user doesn't provide it in traidor.conf.
Also, the program should check the $LINES and $COLUMNS environment variables every time it updates the screen, instead of having to set it manually with the d menu option.
Hmm, I tried reading $LINES from os.environ, it's not in there. while "echo $LINES" in bash works, "env | grep LINES" doesn't show it either. Any hint for me? It turns out that $LINES and $COLUMNS are internal to BASH. The way you really get the size of the terminal is by sending the string "\x1b[18t" (hex: 1b, 5b, 31, 38, 74) to stdout. You'll get a response in the form of "\x1b[8; L; Ct" on stdin, where L and C are the lines and columns, respectively. To allow you to avoid having to send this sequence before every screen update, xterm will send your program the SIGWINCH signal every time the size of the window changes.
|
|
|
|
m3ta
|
|
August 22, 2011, 04:15:16 AM |
|
$ python -V Python 2.7.1+
$ python traidor.py Traceback (most recent call last): File "./traidor.py", line 17, in <module> from websocket import WebSocket ImportError: Bad magic number in /btc/traidor/websocket/__init__.pyc
|
|
|
|
molecular (OP)
Donator
Legendary
Offline
Activity: 2772
Merit: 1019
|
|
December 04, 2012, 08:50:19 PM |
|
$ python -V Python 2.7.1+
$ python traidor.py Traceback (most recent call last): File "./traidor.py", line 17, in <module> from websocket import WebSocket ImportError: Bad magic number in /btc/traidor/websocket/__init__.pyc
dude, didn't even see this. try "git pull".
|
PGP key molecular F9B70769 fingerprint 9CDD C0D3 20F8 279F 6BE0 3F39 FC49 2362 F9B7 0769
|
|
|
supert
|
|
April 04, 2013, 01:55:32 PM |
|
OS X 10.6.8 stock python, macports simplejson and pygame. Couldn't find a websockets in macports, assuming already there? I get :~/data/bitcoin/bots/traidor$ python traidor.py show_depth()-thread started starting exchanges... request_info() Exception in thread Thread-2: Traceback (most recent call last): File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/threading.py", line 551, in __bootstrap_inner self.run() File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/threading.py", line 504, in run self.__target(*self.__args, **self.__kwargs) File "traidor.py", line 189, in __call__ x.start() File "/Users/co1ass/data/bitcoin/bots/traidor/mtgox.py", line 100, in start S.request_info() File "/Users/co1ass/data/bitcoin/bots/traidor/mtgox.py", line 348, in request_info S.info = S.request_json_authed('/api/1/generic/private/info')['return'] File "/Users/co1ass/data/bitcoin/bots/traidor/mtgox.py", line 313, in request_json_authed rc = S.request_json(url, params); File "/Users/co1ass/data/bitcoin/bots/traidor/mtgox.py", line 308, in request_json return json.load(response, use_decimal=True, object_hook=convert_certain_json_objects_to_decimal) File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/json/__init__.py", line 278, in load **kw) File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/json/__init__.py", line 339, in loads return cls(encoding=encoding, **kw).decode(s) TypeError: __init__() got an unexpected keyword argument 'use_decimal'
Any ideas?
|
|
|
|
|