Pages:
Author

Topic: ncurses based MtGox live monitor and trading-bot-framework - page 10. (Read 33853 times)

vip
Activity: 756
Merit: 503

Along with prof7bit's code you need to install this pycrypto package from here:

https://pypi.python.org/pypi/pycrypto

Working thanks very much!
sr. member
Activity: 408
Merit: 261

Along with prof7bit's code you need to install this pycrypto package from here:

https://pypi.python.org/pypi/pycrypto

vip
Activity: 756
Merit: 503
What is missing?

Code:
~/goxtool$ ./goxtool.py
Traceback (most recent call last):
  File "./goxtool.py", line 30, in
    import goxapi
  File "/home/r2d2/goxtool/goxapi.py", line 34, in
    from Crypto.Cipher import AES
ImportError: No module named Crypto.Cipher

~/goxtool$ ./goxtool.py --add-secret
Traceback (most recent call last):
  File "./goxtool.py", line 30, in
    import goxapi
  File "/home/r2d2/goxtool/goxapi.py", line 34, in
    from Crypto.Cipher import AES
ImportError: No module named Crypto.Cipher

~/goxtool$ python --version
Python 2.7.3
hero member
Activity: 812
Merit: 1022
No Maps for These Territories
Ha, bravo. Looks great.
sr. member
Activity: 408
Merit: 261
Congratulations and thank you to prof7bit (I've tried many CLI-type tools posted here and this is probably the best) and also to MagicalTux because the new beta streaming socket.io feed is FINALLY the first real improvement in reliability since pretty much ever.  You can get it with something like this:

Code:
goxtool.py --protocol=socketio-beta

I am on Mac and can confirm it is working really good.

I believe new Mac OS X versions ship with python v2.7 installed.

Along with prof7bit's code you need to install this pycrypto package from here:

https://pypi.python.org/pypi/pycrypto

which of course will not install unless you have XCode installed, because it needs to compile something.  If you don't want to install or don't have XCode you can also download a Command Line Only Tools package which can also compile/install this if you register as an Apple Developer.

If you can post us some boilerplate examples on how to use strategy.py I will certainly tip your donation address if I manage to make any money autotrading with this thing.
member
Activity: 135
Merit: 10
Great stuff mate.
hero member
Activity: 882
Merit: 1000
It's got electrolytes
nice work.

thank you.
hero member
Activity: 938
Merit: 500
https://youengine.io/
I have just run my code through 2to3 and did some additional small adjustments and got it almost working (there are no fundamental problems, its just a few module names have changed, the () around the print (there are only few) and the change to the str class (strings in py3 are always unicode and for byte-strings i have to use bytes() because str() will not have a decode() method anymore, so a few things regarding the encryption/decryption of the api secret and and base64-encoding/decoding and signing stuff must be slightly changed to use bytes() where I currently (ab)use str() for byte strings, this should all be possible without too many problems. Its only few places that need to be changed.

The main problem was the websocket code from Hiroki Ohtani, I first tried to port it myself, it contains a lot of the same sort of string manipulation all over the place and after an hour or so I gave up. Then I saw that there already exists an experimental py3 version of this module from the same author already on github, so not all hope is lost, it can eventually be ported to python 3 if necessary.

I will try to make my own code more python3 friendly (in small steps to not break anything) so that it will be prepared for easy transition eventually but I won't switch to python 3 yet, not at this time.
legendary
Activity: 1792
Merit: 1008
/dev/null
yes, if backporting isnt possible i will run python2.7 coexistent, that should be fine Wink

I have just googled and it seems you could break your debian stable or bring it into some totally inconsistent state when installing 2.7 on it.

If you really want to experiment with new software then I think debian stable is not the right distribution for you. Its main "advantage" is that it consists only of stuff that is so old (old abandoned branches of software versions) that won't ever change anymore (not moving == stable (== dead?)). You can use it to run old server software that has existed for 20+ years and run them for another 20+ years, software that won't break or change APIs with new updates because the only updates they will ever receive at all will be security fixes. That the Debian definition of "stable": old, petrified, fossilized. Thats what Debian *stable* is meant for.

If you have a Desktop computer and want to be flexible and experiment with cool new stuff now and not in 3 years when its old, you should choose a different distribution. The simplest solution for you would probably to upgrade to Debian testing if you intend to test new (everything that is not really old) software and then stay on their testing release schedule from then on.

Bleeding edge and Debian-Stable just does not go together. Not even "pretty well stable" or "stable" or even "rock solid stable for 2 years now" and "Debian-stable". They have a different and very extreme definition of "stable" over there at Debian.
you can install another python into a specific prefix, so u dont overwrite the systems versions. or you can do it with virtualenv too Wink
hero member
Activity: 938
Merit: 500
https://youengine.io/
yes, if backporting isnt possible i will run python2.7 coexistent, that should be fine Wink

I have just googled and it seems you could break your debian stable or bring it into some totally inconsistent state when installing 2.7 on it.

If you really want to experiment with new software then I think debian stable is not the right distribution for you. Its main "advantage" is that it consists only of stuff that is so old (old abandoned branches of software versions) that won't ever change anymore (not moving == stable (== dead?)). You can use it to run old server software that has existed for 20+ years and run them for another 20+ years, software that won't break or change APIs with new updates because the only updates they will ever receive at all will be security fixes. That the Debian definition of "stable": old, petrified, fossilized. Thats what Debian *stable* is meant for.

If you have a Desktop computer and want to be flexible and experiment with cool new stuff now and not in 3 years when its old, you should choose a different distribution. The simplest solution for you would probably to upgrade to Debian testing if you intend to test new (everything that is not really old) software and then stay on their testing release schedule from then on.

Bleeding edge and Debian-Stable just does not go together. Not even "pretty well stable" or "stable" or even "rock solid stable for 2 years now" and "Debian-stable". They have a different and very extreme definition of "stable" over there at Debian.
legendary
Activity: 1792
Merit: 1008
/dev/null
yes, if backporting isnt possible i will run python2.7 coexistent, that should be fine Wink
hero member
Activity: 938
Merit: 500
https://youengine.io/
Code:
AttributeError: 'module' object has no attribute 'WeakSet'

This is unfortunate because I am not going to refrain from using these weakref classes. Maybe it would be easier to port the entire program to python-3 than to backport weakref.WeakSet() to a deprecated old python-2.6 version, but then again the problem would be that I would then probably be tempted to use features from python 3.2 (Ubuntu) and Debian users with deprecated 3.0 would complain.

I'm doing this for *fun* and not for profit! If I see that there is there is python 2.7 installed on stable Ubuntu (and even was installed on the previous Ubuntu version too and probably even on the one before that) then I am going to use it. I choose python-2.7 because it is the largest stable island and common denominator in the entire python world that is most likely to be available *everywhere*.

There *must* exist a python-2.7 installer for your distribution, 2.7 is three(!) years stable already. Maybe somewhere in the backports repository. If not then there is something seriously wrong in Debian-land, sorry.
legendary
Activity: 1792
Merit: 1008
/dev/null
is it possible to make it backward compatible to 2.6?

Not sure, I don't have python 2.6 installed to test it, I relied on the fact that the 2.x branch ended at 2.7 many years ago (I consider it as old and mature and stable) and I assumed that over the time (until now?) from all the different 2.x versions there would eventually only 2.7 be left as the only relevant 2.x version. What Linux distribution are you using? Debian?

What exactly is missing/wrong/different? If it is something trivial it might be possible, but the main problem is I can't (and don't want to) test and maintain it on 2.6 but maybe someone else can temporarily maintain a 2.6 fork until there is no 2.6 anymore (hopefully soon).
python 2.6/2.7 are considered stable, therefore used by most ppls.
well it dosnt work:
Code:
$ python goxtool.py
Traceback (most recent call last):
  File "goxtool.py", line 1031, in
    main()
  File "goxtool.py", line 1023, in main
    curses.wrapper(curses_loop)
  File "/usr/lib/python2.6/curses/wrapper.py", line 44, in wrapper
    return func(stdscr, *args, **kwds)
  File "goxtool.py", line 947, in curses_loop
    gox = goxapi.Gox(secret, config)
  File "/home/k1773r/git/goxtool/goxapi.py", line 779, in __init__
    BaseObject.__init__(self)
  File "/home/k1773r/git/goxtool/goxapi.py", line 243, in __init__
    self.signal_debug = Signal()
  File "/home/k1773r/git/goxtool/goxapi.py", line 172, in __init__
    self._functions = weakref.WeakSet()
AttributeError: 'module' object has no attribute 'WeakSet'
hero member
Activity: 938
Merit: 500
https://youengine.io/
+1 for 2.6
Debian squeeze has 2.5, 2.6 and 3.0 in repo.

Debian. Isn't the whole point of willingly choosing Debian instead of practically *any* other distribution to explicitly *avoid* any software that is less than 5 years old and work only with old and proven stuff that does not move a single millimeter anymore?

Don't misunderstand me. I mean I really try my best to avoid using any bleeding edge stuff when writing software (I once criticized bitcoin-wx for using a bleeding edge wx-widgets version that was *not* in widespread use), I consider something stable and available and usable for mainstream development if it is in the standard repositories of Ubuntu LTS. I had the same kind of problems when I started TorChat 5(!) years ago with python 2.6 (stable on Ubuntu Hardy at that time and widely used everywhere), soon after the Debian users started complaining that it would not work with their ancient python version.

There were even a few Windows-98 users (imagine! win98!), I even installed win98 in wmvare to see what strange problem they had with python-2.6 on win-98 and to see if I could fix it (and fixed it!) but eventually I decided that it is just not reasonably possible to care about all these exotic corner cases (and a Debian stable user (==conservative by definition) who wants to install the latest bleeding edge software is an exotic corner case). I don't have an army of programmers and testers working for me, At some point I must make a decision and then stick to it. In my case this is the software and libs and their versions that are available in Ubuntu.
hero member
Activity: 938
Merit: 500
https://youengine.io/
is it possible to make it backward compatible to 2.6?

Not sure, I don't have python 2.6 installed to test it, I relied on the fact that the 2.x branch ended at 2.7 many years ago (I consider it as old and mature and stable) and I assumed that over the time (until now?) from all the different 2.x versions there would eventually only 2.7 be left as the only relevant 2.x version. What Linux distribution are you using? Debian?

What exactly is missing/wrong/different? If it is something trivial it might be possible, but the main problem is I can't (and don't want to) test and maintain it on 2.6 but maybe someone else can temporarily maintain a 2.6 fork until there is no 2.6 anymore (hopefully soon).
hero member
Activity: 482
Merit: 502
+1 for 2.6
Debian squeeze has 2.5, 2.6 and 3.0 in repo.
legendary
Activity: 1792
Merit: 1008
/dev/null
is it possible to make it backward compatible to 2.6?
hero member
Activity: 938
Merit: 500
https://youengine.io/
Implemented manual trading functions, now its a full featured trading client :-)



In the above screenshot you see the order cancel dialog (press F6 to open it). It is inspired by midnight commander: arrow keys to move up/down, insert to select/unselect an order, F8 to cancel all selected orders, F10 to exit the dialog (sorry, cannot use ESC without ugly hacks). F10 is the key to exit all dialogs.

F4: new buy order
F5: new sell order
F6: cancel order(s)
q quit the client

l (lowercase L) reload the strategy module (your trading bot)

other keys (a..z, except the two above) will emit the signal gox.signal_keypress, the default empty strategy class already has a slot connected to this signal, there you can trigger stuff to happen in your bot when you press certain keys.

Also added since my last posting: display total fiat on the orderbook bid side, total BTC on the orderbook ask side, ratio of these two numbers BTC/USD, everything updating in realtime (see screenshot)

Code:
$ ./goxtool.py -h
usage: goxtool.py [-h] [--add-secret] [--strategy STRATEGY]
                  [--protocol PROTOCOL] [--no-fulldepth] [--no-history]

MtGox live market data monitor and trading bot experimentation framework

optional arguments:
  -h, --help           show this help message and exit
  --add-secret         prompt for API secret, encrypt it and then exit
  --strategy STRATEGY  name of strategy module file, default=strategy.py
  --protocol PROTOCOL  force protocol (socketio or websocket), ignore setting
                       in .ini
  --no-fulldepth       do not download full depth (useful for debugging)
  --no-history         do not download full history (useful for debugging)


happy trading :-)
hero member
Activity: 868
Merit: 1000
Very cool project - I will look into this!
hero member
Activity: 938
Merit: 500
https://youengine.io/


Added:
* y-axis labels for chart
* better looking candle bodies in chart
* display current order-lag
* display last trade price, bid and ask in the xterm window title bar
* fixed some bugs and flaws (and probably also introduced new ones)
Pages:
Jump to: