Author Topic: [ReleaseCandidate] Module "GrapheneExchange" - Simple Python Trading Interface  (Read 8986 times)

0 Members and 1 Guest are viewing this topic.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: 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
« Last Edit: January 28, 2016, 11:26:35 am by xeroc »

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: 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

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
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.
« Last Edit: January 26, 2016, 04:36:22 am by tonyk »
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

iHashFury

  • Guest
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%

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
error:
Code: [Select]
[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
Code: [Select]
[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

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

Thank you again your help,  patience and BOT Xeroc

Code: [Select]
[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

  • Guest
error:
Code: [Select]
[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
Code: [Select]
[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

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
testing config using MUSE
Code: [Select]
#: 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)
Code: [Select]
[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?
Code: [Select]
#: 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
« Last Edit: January 14, 2016, 12:50:16 pm by xeroc »

iHashFury

  • Guest
testing config using MUSE
Code: [Select]
#: 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)
Code: [Select]
[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?
Code: [Select]
#: place orders at this spread (in percent)
bridge_spread_percent = 5

Offline kenCode

  • Hero Member
  • *****
  • Posts: 2283
    • View Profile
    • Agorise
kenCode - Decentraliser @ Agorise
Matrix/Keybase/Hive/Commun/Github: @Agorise
www.PalmPay.chat

iHashFury

  • Guest
one step closer  8)

Code: [Select]
[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%

Offline kenCode

  • Hero Member
  • *****
  • Posts: 2283
    • View Profile
    • Agorise
kenCode - Decentraliser @ Agorise
Matrix/Keybase/Hive/Commun/Github: @Agorise
www.PalmPay.chat

iHashFury

  • Guest
Thank you for your help and patience Xeroc
Code: [Select]
# delete all - start fresh
rm ~/.local/lib/python*
rm python-graphenelib
Code: [Select]
# 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
Code: [Select]
# 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

Offline cube

  • Hero Member
  • *****
  • Posts: 1404
  • Bit by bit, we will get there!
    • View Profile
  • BitShares: bitcube
Good job, xeroc!  You are all charged up in a new year.  :)
ID: bitcube
bitcube is a dedicated witness and committe member. Please vote for bitcube.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Could you re-pull from github then do

  make install-user

and try again?