Code Monkey home page Code Monkey logo

goxtool's Introduction

#goxtool.py

Goxtool is a trading client for the MtGox Bitcon currency exchange. It is designed to work in the Linux console (it has a curses user interface). It can display live streaming market data and you can buy and sell with keyboard commands.

Goxtool also has a simple interface to plug in your own automated trading strategies, your own code can be (re)loded at runtime, it will receive events from the API and can act upon them.

The user manual is here: http://prof7bit.github.com/goxtool/

goxtool's People

Contributors

prof7bit avatar smopucilowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goxtool's Issues

release ?

it would be nice to have a tarball release (using setup.py) so this fine piece of sw could be packaged for linux distros easily.

Proxy support

Hi!

Do you plan to add a http(s) proxy support?

Thanks in advance!

Suppression of Outputs

A nice feature might be the ability to suppress some console messages by flagging them true or false in the ini file.

For example:

Trades
Depth
General system messages (Ping pong etc).

For trades, what i've done on my personal version is rather than have 'TRADE' as the ouput, it puts the type first in caps so its ASK or BID as it makes it easier to see whats happening rather than scrolling to the right (Might just be personal preference).

Delerium

Multiple processes same API

Firstly, thanks for a great tool which is a great platform for doing interesting (and profitable!) things with Python. Your code is written and laid out well - and it is great to see the active maintanance.

I would like to have multiple goxtool processes running in different terminals. For the sake of network and processor efficiency, what would be required to have multiple goxtool.py processes listen to the same API stream?

From reading the code I have formed a vague comprehension. Please confirm that I'm understanding your threading implementation correctly: the goxapi.py process starts the main thread which implements Signal locking via a nonce. All of the Signal connected slots send/receive signals seem to be regulated by the Baseclient FIFO Queue object. Additionally, goxtool communicates with the remote streaming server by emiting (via self._recv_thread?) and receiving (via self._http_thread?). I hope I have this even slightly correct so far...

Should another goxtool process start, what would be an appropriate hook for it to use to access the datastream? I am prepared to work it out and code it but a pointer will be appreciated.

Also, in the same vein, I have coded a strategy that plots price indicators (using TAlib for Python) via Matplotlib. This is working great except for frequent complaints by Tkinter (in Matplotlib) that it is not being run in the main thread - when it throws an exception this often freezes goxtool. Well, tough luck - I will either have to hardcode plotting into the API or call goxtool from a separate plotting main thread. Any sugestions would be welcome and I will be sure to share my code in a fork on Github.

WebSocketConnectionClosedException

So when I start goxtool, I get this:

http://i.imgur.com/vH4ptPG.png

trying plain old Websocket: wss://websocket.mtgox.com?Channel=depth.BTCUSD/ticker.BTCUSD ...
WebSocketConnectionClosedException reconnecting in 1 seconds...

I have tried:
./goxtool.py
./goxtool.py --protocol=socketio
./goxtool.py --protocol=websocket
./goxtool.py --protocol=websocket --use-http

I am running Python 2.7.3 on Ubuntu Server 12.04.3 LTS

My uname -a:
Linux penguinista 3.11.6-x86-linode54 #1 SMP Wed Oct 23 15:22:49 EDT 2013 i686 i686 i386 GNU/Linux

Any suggestions or way to get more information?

problem with F10 key as dialog exit

F10 key usually used as menu hotkey in graphics terminal.
So now impossible cancel UI dialogs in some linux distros.
Probably better use X, C or F9 keys?
ESC key probably better, but sometimes ESC used for metakeys.

Faulty Owns?

image

Owns displaying as zero vol - this is new since the last push.

Del

Several "Method not found" in latest revision

Several "Method not found" in latest revision:

DEBUG:Gox:{u'message': u'Method not found', u'id': u'order_lag', u'success': False, u'op': u'remark'}
DEBUG:Gox:{u'message': u'Method not found', u'id': u'orders', u'success': False, u'op': u'remark'}
DEBUG:Gox:{u'message': u'Method not found', u'id': u'idkey', u'success': False, u'op': u'remark'}
DEBUG:Gox:{u'message': u'Method not found', u'id': u'info', u'success': False, u'op': u'remark'}

Some refactoring suggestions

The goxapi.py has 1696 LOC. I'm going to use parts of goxapi and refactor a module, so that it is independent of the UI and the exchange. I would split up the goxapi.py in orders.py (Order and Orderbook classes), exc_cllients.py (BaseClient and SocketIO / Websocket classes), config.py (Secret, Goxconfig classes), util.py (number conversions and pretty_format).

The Gox object is an active streaming object (start method), as well as a passive broker to the exchange. A request sometimes can not only be a streaming request, but a one time request.

I can do a pull request if there is interest. It makes sense to have one great MtGox API out there, where then everyone can add their own stuff ontop. goxtool this is certainly the best existing code for interfacing with MtGox and I would like to contribute to a common base.

candle volume discrepancy

I am coding a strategy based on volume and notice that previous candle volumes are not updated when a new candle is created.

Sorry - my mistake - volume is indeed updated correctly - list indexing error on my part

Ability to change logging level from ini file

Hi,

Thanks for a great tool!

Would it be possible add an ini file parameter to change the logging level; giving the option to make it less or more verbose or even an option to disable logging altogether?

I have a system that runs on an SD card and fear too much r/w activity.

UPDATE

I have had a closer look at the logfile and it seems all logged messages are at DEBUG level. Maybe better use could be made of the WARNING, INFO, ERROR and CRITICAL levels rather than logging everything at same level. Just a suggestion, thanks. Then the user may decide via ini file which level they want to see.

Add flag to hide log at bottom

I use goxtool so that I can quickly at a glance see the current bitcoin price, but the log (section that shows keypresses and ticks on bottom etc) don't really interest me.

Is there a way to hide this field? A flag in goxtool.ini would be really nice. I don't know the project well enough to suggest an implementation.

F4 does not bring up buy window

When I press F4 the buy window does not appear; instead, I see the following in the message console:

key pressed: key=27
key pressed: key=91
key pressed: key=49
key pressed: key=52
key pressed: key=126

I'm running the latest git version on a shell account. I've tried different terminal software and different computers with the same result.

Ability to have longer history than just the last 24h

Hi there!

Thanks for goxtool, love it! Well-written code, plenty of callbacks to hook into, overall a very cool framework for bots!

I'd like to request a feature to be added which is the ability to pull a longer history than just the last 24h that MtGox sends by default.

Unfortunately, the problem in passing a specific time in the fetch url through the ?since= parameter is that MtGox only sends back a chunk of 100 trades since the requested timestamp.

Therefore, the request_history() function would have to loop the requests by updating its request parameter with the last timestamp received until the requested timeframe is filled, and slot_fullhistory() would maybe have to check there's no duplicates just in case.

A parameter could then be specified in the goxtool.ini file to override/specify the default history span, and a slot_history_complete() that fires when the history is fully downloaded and processed into candles would be the cherry on top :)

I don't know if i'm the only one needing this, but i can certainly think of multiple cases for needing more than just the last 24h history, for example calculating any kind of moving average would be a big one. I don't know if this is something that rates very high on your priority list, but in any case that functionality would be very helpful.

And again, thanks (a lot) for goxtool!

Second scrolling view for Strategy plugin usage

With all the noise present in the main scrolling view, it's hard to read any output coming from your Strategy plugin.

It would be wonderful if a dedicated plugin view was added, as well as the ability to toggle both it and the main view.

Socket Reconnect on Silence

Might be an easy one but I know you weren't keen on having to do this as you'd be coding around bad server reliability.

If socketio is silent for 60 seconds, disconnect then reconnect socket.

Delerium

nocache results in 500 server error

In the latest commit (e30f428) there are two changes to goxapi.py that both result in HTTP Error 500: Internal Server Error:

-                + "/api/2/BTC" + self.currency + "/money/depth/full")
+                + "/api/2/BTC" + self.currency + "/money/depth/full?"
+                + str(time.time()))

and

+            if since:
+                querystring = "?since=" + str(since * 1000000)
+                querystring += "&nocache=" + str(time.time())
+            else:
+                querystring = "?nocache=" + str(time.time())

It appears the server doesn't like the unexpected unknown parameter.

Would prefer buy/sell interface similiar to Mt.Gox

Would prefer to have an interface that 'solves for x' , similar to the Mt.Gox webui.

Example.

Mt.Gox : (AMT of BTC to buy) x (AMT to pay per BTC) = (AMT native currency PAID)

As long as you fill out two fields, the webui fills out the third field. I would like similiar functionality available in goxtool.

"I would like to buy 15 dollars worth of BTC at so and so a price."

suggestion: use the decimal module instead of float

Hello, first thanks a lot for goxtool.

I have one suggestion to improve it a bit. It would be nice to use decimal instead of the float builtin type to avoid rounding and precision errors or at least provide additional methods to provide BTC and fiat values as Decimal. I implemented a hackish decimal conversion in a helper class for a custom strategy but having it directly in goxapi would be nicer.

Resizing not handled correctly

When resizing the window, the gaps between the order book, the y-axis price labels, and the chart itself don't dynamically adjust. This is problematic on both very large and very small screens, since it either case it does not utilized the screen space efficiently.

Here's what it looks like under a vertical split on 1680x1050 monitor:

7Np0and

And here it is fullscreen at 2560x1440:

GTSHdnT

I think it would be nice to have adjustable layouts that could be written to a config file, but I have no idea how much work that takes in ncurses.

Half Streaming window for Strategy output

Hey
i just got a strategy running and its doing well i love this tool and how simple it makes life :D

Though it would be beneficial to cut the streaming window (the one Down the bottom) in half and use the second half for the output of strategy and client messages instead of having them jumbled in the stream to make reading a lot easier :D

http://screenshots.setkeh.com/goxtool.png << for example :D

ImportError: No module named Crypto.Cipher

Does this work on mac's? Would you be able to provide a little guidance of how to download this dependency please? (I'm a programmer, just not familiar with python.)

± ./goxtool.py
Traceback (most recent call last):
  File "./goxtool.py", line 30, in <module>
    import goxapi
  File "/Users/F/Documents/Business/Prospects/BTC trading/tools/goxtool (python)/git-goxtool/goxtool/goxapi.py", line 34, in <module>
    from Crypto.Cipher import AES
ImportError: No module named Crypto.Cipher

Multi Currency Support In One GoxTool

Might be a far fetched request this but is it possible to have one goxtool instance relay information for multiple currencies in one window meaning just one socketio connection.

I expect this would be a significant rewrite of code as each signal would need to have currency identifier.

Delerium

HTTP API v2

Thanks a lot for coding this. Always good to learn code by reading code.

Is there an official doc for trading via websockets / socketIO? How does this relate to the new API version 2?

Decryption of the key

In the signed call there is this:

sign = hmac.new(base64.b64decode(sec), call, hashlib.sha512).digest()

This descripts the secret. Why is does secret class have seperate decription with a password?

Backspace not working in dialogs

Whenever I make a typo in the dialog buttons, I can't press backspace (or del) to fix them. I have to close the dialog and reopen it again and reenter everything.

Can this be fixed?

Command Line Passphrase Parameter

As discussed on IRC. The ability to pass your passphrase to goxtool using command prompt would be beneficial to those needing to start multiple instances of goxtool (for example 5 currencies) at once than having to do each manually.

Delerium

Instantiate gox client for unittest

My strategies have become so bulky and interdependent that testing new code by simply starting goxtool is proving impractical. I would like to instantiate a BaseClient so that I may import goxapi and my strategy into a unittest and then access my strategy and goxapi class functions:

So far I have:

import unittest
import goxapi
import mystrategy

#construct a minimal API client
config = goxapi.GoxConfig("goxtool.ini")
secret = goxapi.Secret(config)
client = goxapi.BaseClient('BTC','USD',secret,config)

Then I create the client instance:

mygox = goxapi.Gox(secret, config)
mystrat = mystrategy.Strategy(mygox)

This way of instantiating throws an exception as soon as the Strategy init() is executed since the various slots and signals have not been called or created yet.

Am I doing this right and optimally? Is there a 'lighter' instantiation process I could use? My objective is simply to access the Strategy functions and it is not necessary to have all of the 'moving parts' such as http socket and signals functioning. Is there a way of doing this?

Infinite debug ### don't know secret when socketio and --use-http

Hi. First of all, good job!

I have tried launching goxtool with --protocol socketio --use-http and it loops the following message ad infinitum.

2013-03-20 21:50:06,968:DEBUG:SocketIOClient:trying Socket.IO: socketio.mtgox.com ...
2013-03-20 21:50:22,499:DEBUG:SocketIOClient:trying Websocket: wss://socketio.mtgox.com/socket.io/1/websocket/1102064522417529463?Currency=USD ...
2013-03-20 21:50:25,337:DEBUG:SocketIOClient:connected
2013-03-20 21:50:25,821:DEBUG:SocketIOClient:subscribing to channels
2013-03-20 21:50:25,823:DEBUG:SocketIOClient:requesting initial full depth
2013-03-20 21:50:25,824:DEBUG:SocketIOClient:waiting for data...
2013-03-20 21:50:25,825:DEBUG:SocketIOClient:### don't know secret, cannot call generic/private/orders
2013-03-20 21:50:25,826:DEBUG:SocketIOClient:generic/private/orders {} orders 'NoneType' object has no attribute '__getitem__'
[...]

I am not loading any secret (of course). Running on Ubuntu with Python 2.7.3. I'll have a look as well, but I wanted to signal the issue.

Thanks.

F5 - New sell order throws an error

The F5 key for New sell order throws an exception:

014-01-05 16:22:54,086:DEBUG:__main__.PrintHook:Exception in thread Thread-96:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "./goxtool.py", line 1281, in cursor_placement_thread
    curses.curs_set(2)
error: curs_set() returned ERR

The dialog does open however; but as the F4 (New buy oder) doesn't work I haven't been able to test this. See: Issue #51

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.