Author

Topic: traidor.py - command-driven text-mode trading client (mtgox) (Read 2330 times)

full member
Activity: 160
Merit: 100
OS X 10.6.8
stock python, macports simplejson and pygame. Couldn't find a websockets in macports, assuming already there?

I get

Code:
:~/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?
donator
Activity: 2772
Merit: 1019
$ python -V
Python 2.7.1+

$ python traidor.py
Traceback (most recent call last):
  File "./traidor.py", line 17, in
    from websocket import WebSocket
ImportError: Bad magic number in /btc/traidor/websocket/__init__.pyc


dude, didn't even see this. try "git pull".
sr. member
Activity: 435
Merit: 250
$ python -V
Python 2.7.1+

$ python traidor.py
Traceback (most recent call last):
  File "./traidor.py", line 17, in
    from websocket import WebSocket
ImportError: Bad magic number in /btc/traidor/websocket/__init__.pyc
member
Activity: 280
Merit: 10
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.
donator
Activity: 2772
Merit: 1019
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.
hero member
Activity: 854
Merit: 500
What version of python should I be using?

Code:
jonny@netbook:~/traidor$ python traidor.py
Traceback (most recent call last):
  File "traidor.py", line 21, in
    from wxgui import *
  File "/home/jonny/traidor/wxgui.py", line 4, in
    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.

Code:
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?
donator
Activity: 2772
Merit: 1019
What version of python should I be using?

Code:
jonny@netbook:~/traidor$ python traidor.py
Traceback (most recent call last):
  File "traidor.py", line 21, in
    from wxgui import *
  File "/home/jonny/traidor/wxgui.py", line 4, in
    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
hero member
Activity: 854
Merit: 500
What version of python should I be using?

Code:
jonny@netbook:~/traidor$ python traidor.py
Traceback (most recent call last):
  File "traidor.py", line 21, in
    from wxgui import *
  File "/home/jonny/traidor/wxgui.py", line 4, in
    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
member
Activity: 280
Merit: 10
After leaving this program running for 6-8 hours, I found this:

Code:
mtgox | 0 BTC | 0.00458 USD | [h]elp #> Fatal Python error: (pygame parachute) Segmentation Fault
Aborted
gambler@irony:~/src/traidor$
donator
Activity: 2772
Merit: 1019
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?
donator
Activity: 2772
Merit: 1019
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:

Quote
mtgox | x BTC | y USD #> tb >= 12.5 ps alarm.wav
donator
Activity: 2772
Merit: 1019
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.
member
Activity: 280
Merit: 10
WTF? I just noticed that this program uses the sound card to make strange "ticking" noises.
member
Activity: 70
Merit: 10
Only a curious passer-by / FirstBits: 13zsc1
I hope this script don't betray me!
donator
Activity: 2772
Merit: 1019
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!

member
Activity: 280
Merit: 10
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.
donator
Activity: 2772
Merit: 1019
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.
donator
Activity: 2772
Merit: 1019
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:

Quote
#> git clone git://github.com/molecular/traidor.git
#> cd traidor

then prepare config-file and start traidor:

Quote
#> cp traidor.conf.sample traidor.conf
#> edit traidor.conf
#> python traidor.py

The most important commands:
Quote
-----------command-----------------------action------------
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
atoggle auto-update on/off
b enter order to buy btc at
s enter order to sell btc at
oview your order book
d delete order at from orderbook

Note: you must use a decimal point (".") when entering the of an order. If you dont, 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

Jump to: