[ReleaseCandidate] Module "GrapheneExchange" - Simple Python Trading Interface

Started by xeroc, January 11, 2016, 02:08:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xeroc

For those using this module: Please note that prices are now denoted in 'base'/'quote'. I highly recommend to read the latest release notes and the documentation:
http://python-graphenelib.readthedocs.org/en/latest/

Note that this release is not available via pip

xeroc

The whole thing is documented at
http://python-graphenelib.readthedocs.org/en/latest/
which is a page that is build from the content of docs/* and the comments in the code.

The graphenewsrpc.py file is to talk to the witness node via rpc.
the payload is constructed to follow the JSON syntax for calls properly:
https://github.com/xeroc/python-graphenelib/blob/master/grapheneapi/graphenewsrpc.py#L82-L86

tonyk

I know it is only semi related...

In graphenewsrpc.py

where can I find some explanation/examples etc.

payload in:

def rpcexec(self, payload):

is bothering me right this moment, but general info will be appreciated as well.
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

iHashFury

Will  add METAEX.BTC too.

Just need some more BTC and BTS.
Plus BTS to rise in price so I can borrow more BTC   ;) +5%

xeroc

Quote from: iHashFury on January 14, 2016, 01:12:31 PM
error:
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
- 1.7.19973
Traceback (most recent call last):
  File "/home/jason/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py", line 13, in <module>
    dex.cancel(o["orderNumber"])
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneexchange/exchange.py", line 908, in cancel
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 160, in method
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 146, in rpcexec
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 138, in rpcexec
grapheneapi.grapheneapi.RPCError: 10 assert_exception: Assert Exception
!is_locked():
    {}
    th_a  wallet.cpp:3508 cancel_order


works with unlocked wallet
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
- 1.7.19524
- 1.7.19527
- 1.7.19530
Placing Orders:
- Selling 89541.300000 OPENMUSE for TRADE.MUSE @1.034500
- Buying 68965.500000 TRADE.MUSE with OPENMUSE @0.965500


I should probably do a check for unlocked wallet somewhere ..
Lots of other checks can be added for misconfiguration and similar stuff .. still in release candidate :)

Good to see it working for you now

iHashFury

Exchange bridge market maker running :) with a little BTC - OPENBTC - TRADE.BTC - TRADE.MUSE - OPENMUSE

Thank you again your help,  patience and BOT Xeroc

[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
- 1.7.19973
- 1.7.19974
Placing Orders:
- Selling 0.034526 BTC for TRADE.BTC @1.034500
- Buying 0.034452 TRADE.BTC with BTC @0.965500
- Selling 0.034526 BTC for OPENBTC @1.034500
- Buying 0.034476 OPENBTC with BTC @0.965500
- Selling 0.034476 OPENBTC for TRADE.BTC @1.034500
- Buying 0.034452 TRADE.BTC with OPENBTC @0.965500
- Selling 89541.300000 OPENMUSE for TRADE.MUSE @1.034500
- Buying 68965.500000 TRADE.MUSE with OPENMUSE @0.965500


Markets:
TRADE.MUSE : OPENMUSE
TRADE.BTC : BTC
OPENBTC : BTC
OPENBTC : TRADE.BTC


iHashFury

error:
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
- 1.7.19973
Traceback (most recent call last):
  File "/home/jason/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py", line 13, in <module>
    dex.cancel(o["orderNumber"])
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneexchange/exchange.py", line 908, in cancel
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 160, in method
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 146, in rpcexec
  File "/home/jason/.local/lib/python3.5/site-packages/graphenelib-0.2rc5-py3.5.egg/grapheneapi/grapheneapi.py", line 138, in rpcexec
grapheneapi.grapheneapi.RPCError: 10 assert_exception: Assert Exception
!is_locked():
    {}
    th_a  wallet.cpp:3508 cancel_order


works with unlocked wallet
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
- 1.7.19524
- 1.7.19527
- 1.7.19530
Placing Orders:
- Selling 89541.300000 OPENMUSE for TRADE.MUSE @1.034500
- Buying 68965.500000 TRADE.MUSE with OPENMUSE @0.965500


xeroc

Quote from: iHashFury on January 14, 2016, 10:52:20 AM
testing config using MUSE
#: Markets that are of interest for us
watch_markets         = ["OPENMUSE : TRADE.MUSE",
                         ]


but got this error - (I do have open orders on TRADE.MUSE : OPENMUSE)
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
Traceback (most recent call last):
  File "/home/jason/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py", line 11, in <module>
    for o in orders[m]:
TypeError: list indices must be integers or slices, not dict


the bot should close my open orders and create new orders at 5% spread?
#: place orders at this spread (in percent)
bridge_spread_percent = 5

Yes .. i noticed it too ..

thing is I coded the api too close to what poloniex is doing .. and they change syntax if you have only one market (compared to several markets)
I will definietly change this behavior ..

in the meantime .. just add another market for which you don't have funds ..

//edit: just pushed a new master that should change the behavior so that the bot works on one market as well

iHashFury

testing config using MUSE
#: Markets that are of interest for us
watch_markets         = ["OPENMUSE : TRADE.MUSE",
                         ]


but got this error - (I do have open orders on TRADE.MUSE : OPENMUSE)
[jason@i4p python-graphenelib]$ python3 ~/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py
Closing Orders:
Traceback (most recent call last):
  File "/home/jason/tmp/git/python-graphenelib/scripts/exchange-bridge-market-maker/main.py", line 11, in <module>
    for o in orders[m]:
TypeError: list indices must be integers or slices, not dict


the bot should close my open orders and create new orders at 5% spread?
#: place orders at this spread (in percent)
bridge_spread_percent = 5

kenCode

kenCode@Agorise
Matrix/Keybase/Blurt/Hive: @Agorise
Session: 0525c95e7f37dca6e29ac84fe7030f0bc5f8bcd564207f03c893e47d2a381a2337

iHashFury

one step closer  8)

[jason@i4p python-graphenelib]$ date ; python3 ~/tmp/git/python-graphenelib/scripts/exchange-simpleticker-stats/main.py
Wed 13 Jan 22:47:53 CET 2016

GOLD_BTS
========
- Trade Premium: 24.085%
- Bid Order Premium: 24.081%
- Ask Order Premium: 8.121%
- Spread: 19.024%
- CER premium:  5.26%

BTC_BTS
=======
- Trade Premium: 15.561%
- Bid Order Premium: 20.528%
- Ask Order Premium: 13.149%
- Spread: 8.874%
- CER premium:  5.22%

EUR_BTS
=======
- Trade Premium: 5.071%
- Bid Order Premium: 21.758%
- Ask Order Premium: 5.071%
- Spread: 19.272%
- CER premium:  5.26%

SILVER_BTS
==========
- Trade Premium: 11.765%
- Bid Order Premium: 11.286%
- Ask Order Premium: 3.340%
- Spread: 8.573%
- CER premium:  5.27%

CNY_BTS
=======
- Trade Premium: 4.270%
- Bid Order Premium: 3.073%
- Ask Order Premium: 4.270%
- Spread: 7.299%
- CER premium:  5.26%

kenCode

kenCode@Agorise
Matrix/Keybase/Blurt/Hive: @Agorise
Session: 0525c95e7f37dca6e29ac84fe7030f0bc5f8bcd564207f03c893e47d2a381a2337

iHashFury

Thank you for your help and patience Xeroc

# delete all - start fresh
rm ~/.local/lib/python*
rm python-graphenelib


# install
git clone https://github.com/xeroc/python-graphenelib.git
cd python-graphenlib
make install-user
# Finished processing dependencies for graphenelib==0.2rc5
pip install --user -r requirements.txt graphenelib
# Successfully installed autobahn-0.11.0 ecdsa-0.13 requests-2.9.1 scrypt-0.7.1 txaio-2.2.0 websocket-client-0.35.0


# feed script error
# ImportError: No module named 'numpy'
pip3 install numpy --user
# Successfully installed numpy-1.10.4
# ImportError: No module named 'prettytable'
pip3 install prettytable --user

feed scripts working :)

will now try the simple ticker

cube

ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

xeroc

Could you re-pull from github then do

  make install-user

and try again?