[Experimental] Python Trading without cli-wallet
I have improved the exchange
module in the python-graphenelibs such
that you could now create transactions without the cli_wallet and
thus write trading bots without the need for compiling BitShares.
I would call it experimental even though the code itself seems to pass
all tests.
However, I created a new branch
in the python-graphene libs repository called
feature/signing-of-trades
. I encourage everyone to give it a try.
Installation
git clone https://github.com/xeroc/python-graphenelib
git checkout feature/signing-of-trades
make install-user
Example Code
from grapheneexchange.exchange import GrapheneExchange
from pprint import pprint
class Config():
witness_url = "wss://bitshares.openledger.info/ws"
watch_markets = ["USD_BTS"]
market_separator = "_"
account = "xeroc"
dex = GrapheneExchange(
config,
safe_mode=True,
wif="YOUR-WIF-KEY"
)
pprint(dex.returnTicker())
print(dex.buy("USD_BTS", 1, 10))
print(dex.adjust_collateral_ratio("SILVER", 3.0))
Prove the wif
key for the active permissions of the account provided
in the config.
If you set the safe_mode
flag when instatiating GrapheneExchange
to
False
, it will also broadcast the transaction.
Please give it a try and also remember that there is a TEST network
for this!
Note, this is still work in progress and some interfaces may change.
While writing this post, I realized that the wif key should probably be
put in the Config
class aswell so that it can be put in a distinct
config.py
file and loaded via import config
for separation of code
and access key.
Cheers