Pages:
Author

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

hero member
Activity: 938
Merit: 500
https://youengine.io/
Today is again one of these days where MtGox's SocketIO server is almost unusable.

Open the .ini file and switch to plain old websocket protocol:

use_plain_old_websocket = True

Both protocols are implemented, you can compare how they behave and which one is better for you, default is socketio because they say the other one is deprecated but it turns out that plain old websocket is *much* more reliable on days like today while socketio won't connect at all or the messages lag behind websocket by 20 seconds or more!

(If you are going to experiment with a lot of restarts of the application then please temporarily turn off load_fulldepth and load_history because this is eating a lot of bandwidth)
full member
Activity: 238
Merit: 100
Fantastic work. I love curses based programs.

I'll chuck a donation you way soon. Any chance you could display the high/low/last prices at the top near the account info.
It will just make it easier to see the current BTC at a quick glance.
hero member
Activity: 938
Merit: 500
https://youengine.io/
I couldn't find it so you probably haven't implemented keeping an up-to-date synced orderbook? Maybe I didn't look hard enough.

Please pull a recent version from github, I just made some changes an hour ago and fixed some bugs and also refactored some stuff (I'm still moving a lot of stuff around, thats why I called it "experimental" ;-).

The orderbook is updated automatically. The Gox() instance contains an OrderBook() instance, gox is generating signals for trade, depth, ticker, user_order, etc and orderbook will connect itself to all these signals. Look for signal_xxxx.connect() calls in the constructors to see what is connected to what and the slot_xxxx() functions to see how they all react to these signals. OrderBook will process the signals fulldepth, ticker, depth, trade and user_order and orderbook itself will then emit signal_changed for the UI to update.
donator
Activity: 2772
Merit: 1019
cool stuff man, just took a look at the code.

I couldn't find it so you probably haven't implemented keeping an up-to-date synced orderbook? Maybe I didn't look hard enough.

hero member
Activity: 938
Merit: 500
https://youengine.io/
...written in python. Curses based UI, live orderbook, ascii-art chart of latest 24h, trading functions can be defined in separate module "strategy.py" which receives all events from the gox client and all keystrokes from the terminal. Strategy module can be edited and reloaded at runtime which is great for experimenting with bots. Works also without MtGox API-key to view only without trading.


(still experimantal, license: GPL3)
http://prof7bit.github.com/goxtool/
https://github.com/prof7bit/goxtool

screenshot


Usage:

  • it needs python 2.7 (and maybe a few additional packages but nothing that would not be found in the standard ubuntu repositories). It will NOT work on Windows because there exists no ncurses (maybe it works with cygwin, not tested)
  • Download and unzip (or better git clone the repo from github).
  • ./goxtool.py

This should give you the orderbook on the left side and an M15 candlestick chart of the lat 24 hours (if your terminal is wide enough) on the right side and a log window at the bottom.

To use the trading features do the following:

./goxtool.py --add-secret

This will ask you for your MtGox API key and secret, you get them at the mtgox website, copy and paste key and secret, supply a passphrase which will be used to encrypt the secret. Then it will write the encrypted secret to goxtool.ini and exit. The next time you start ./goxtool.py it will ask for the passphrase to access the API secret and then all trading functions will be enabled, you will see your own orders in the orderbook and in the chart and your account balance at the top of the terminal.

To use it with other currencies, just edit the ini file. If it is one of these days when the socket.io just wont want to connect, edit the ini file and change use_plain_old_websockets to True. If you don't need history or full orderbook you can turn it off in the ini too.

press q to quit the program.
press F4 to buy
press F5 to sell
press F6 to view orders / cancel orders
press l (lowercase L) to reload the strategy module at runtime.
any other key will call the slot_keypress() in the Strategy class in strategy.py, see the examples. Here you can call methods like gox.buy() or .sell() or .cancel()  or peek around in the order book to decide what fancy stuff to do.

(this forum posting and the instructions might eventually come out of sync with the current version, see here for the official manual: http://prof7bit.github.com/goxtool/)

There are also methods that will be fired on signals from the gox object, you can use them to build fully automated trading bots (there exist even more signals to connect to, for example orderbook.signal_changed or gox.signal_wallet, etc. Look into the source of goxtool to find them all). You can also instantiate more Gox() objects from within your strategy for different currencies (you will also need separate GoxConfig() objects for each of them that use separate config files) to trade multiple currencies at once (useful for arbitrage strategies).

And finally you can rip out parts of this for your own programs, you can just import goxapi and use the Gox() class on its own in your own program, connect your slots to its signals and make your own UI for it (or no UI at all).
Pages:
Jump to: