economicnetwork / archon Goto Github PK
View Code? Open in Web Editor NEWTrading framework
License: MIT License
Trading framework
License: MIT License
introduce order-route
orders can be routed, i.e. the exchange is selected based on any criteria. start with only limit-price order
APIError(code=-1013): Filter failure: LOT_SIZE
apikeys and conf files are now stored in $HOME/.archon
please add the following files in $HOME/.archon folder
https://stackoverflow.com/questions/25239650/python-requests-speed-up-using-keep-alive
Prepare HTTPS session
self.session = requests.Session()
broker submit should parse market
incorporate fees
maker/taker per exchange
currently broker and arch are redundant. there should be only a single broker interface.
https://docs.python-guide.org/starting/install3/linux/
sudo apt-get update -y
sudo apt-get -y install python3-pip
git clone [email protected]:economicnetwork/archon.git
inside archon directory
pip3 install -r requirements.txt
create file apikeys.toml, see apikeys_example.toml as an example
(create file conf.toml, see example_conf.toml as an example)
export PYTHONPATH=/Users/someuser/archon
cd examples
python3 balance_example.py
mongodb
currently archon broker is a single-user interface/gateway. the api keys are set only once and then the clients communication with exchange.
multi-user requires:
for realised PnL
get all transactions
for each symbol
if its sell
volume weight exit price - volume weighted entry price
for unrealised PnL
average entry
(value current balance)
(not considering deposits and withdraws)
make sure client is connected before calling
File "/Users/ben/archon/archon/exchange/bitmex/bitmex.py", line 401, in _query_bitmex
self.logger.error("429 Too Many Requests for url. Request: %s \n %s" % (url, json.dumps(postdict)))
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type UUID is not JSON serializable
INITIALIZING: 'INITIALIZING',
// Created and send to the exchange, but no acknowledgement received yet
SUBMITTED: 'SUBMITTED',
// Order is open on the exchange
OPEN: 'OPEN',
// Order is completely filled
FILLED: 'FILLED',
// Order was succesfully cancelled
CANCELLED: 'CANCELLED',
// Order was rejected by the exchange
REJECTED: 'REJECTED',
ERROR: 'ERROR'
add bitmex exchange
line 633
config with mlab. this will be in conf.toml
[MONGO]
uri = "mongodb://user:[email protected]:23312/MYDB"`
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "store_prices.py", line 77, in <module>
show()
File "store_prices.py", line 40, in show
book = bitmex_get_book()
File "store_prices.py", line 35, in bitmex_get_book
book = abroker.afacade.get_orderbook(smarket, exc.BITMEX)
File "/Users/ben/archon/archon/broker/facade.py", line 190, in get_orderbook
ob = client.market_depth(market,depth=bookdepth)
File "/Users/ben/archon/archon/exchange/bitmex/bitmex.py", line 124, in market_depth
result = self._query_bitmex(path=path, query={'symbol': symbol, 'depth': depth})
File "/Users/ben/archon/archon/exchange/bitmex/bitmex.py", line 464, in _query_bitmex
return self._query_bitmex(path, query, postdict, timeout, verb)
File "/Users/ben/archon/archon/exchange/bitmex/bitmex.py", line 458, in _query_bitmex
raise ConnectionError("bitmex error")
archon.exchange.bitmex.bitmex.ConnectionError: bitmex error
in broker for orders keep track of orders and their states
full support
facade understands data of and to exchange
broker understands abstract data model
for all exchanges
throttle properly
bitmex_test_public
Traceback (most recent call last):
File "bitmex_test_public.py", line 30, in <module>
run()
File "bitmex_test_public.py", line 24, in run
logger.info("Market Depth: %s" % ws.market_depth())
File "/home/mm/.local/lib/python3.6/site-packages/bitmex_websocket.py", line 91, in market_depth
return self.data['orderBookL2']
KeyError: 'orderBookL2'
currently the broker assumes that balances belong to an agent. in the future agent should be registered with broker and have it assign any balance
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/root/trading/archon/archon/brokersrv/feeder.py", line 101, in run
self.publish_bitmex()
File "/root/trading/archon/archon/brokersrv/feeder.py", line 75, in publish_bitmex
book = self.abroker.afacade.orderbook(self.mex_sym, exc.BITMEX)
File "/root/trading/archon/archon/brokersrv/facader.py", line 87, in orderbook
self.logger.debug("get orderbook %s %i" %(str(market),exchange))
TypeError: %i format: a number is required, not str
import os
if os.name == 'nt':
.... windows part
elif os.name == ''posix':
... mac part
"[archon.exchange.bitmex.bitmex] init bitmex - (2019-03-13 15:08:24,818) 56
name 'time' is not defined"
[archon.exchange.bitmex.bitmex] Unhandled Error: 400 Client Error: Bad Request for url: https://www.bitmex.com/api/v1/order {"error":{"message":"Duplicate clOrdID","name":"HTTPError"}} - (2019-03-08 13:27:06,162) 457
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/home/mm/exch/makers/strat.py", line 150, in run
self.handle_books(book)
File "simple_maker.py", line 232, in handle_books
self.handle_no_position()
File "simple_maker.py", line 174, in handle_no_position
result = self.abroker.submit_order_post(order, exc.BITMEX)
File "/home/mm/exch/archon/archon/brokersrv/brokerservice.py", line 274, in submit_order_post
result = self.afacade.submit_order_post(order, exchange)
File "/home/mm/exch/archon/archon/facader.py", line 159, in submit_order_post
order_result = client.buy_post(quantity=qty, price=order_price, symbol=market)
File "/home/mm/exch/archon/archon/exchange/bitmex/bitmex.py", line 216, in wrapped
return fn(self, *args, **kwargs)
File "/home/mm/exch/archon/archon/exchange/bitmex/bitmex.py", line 269, in buy_post
return self.place_order_post(symbol, directional_quantity, price)
File "/home/mm/exch/archon/archon/exchange/bitmex/bitmex.py", line 216, in wrapped
return fn(self, *args, **kwargs)
File "/home/mm/exch/archon/archon/exchange/bitmex/bitmex.py", line 328, in place_order_post
return self._query_bitmex(path=endpoint, postdict=postdict, verb="POST")
File "/home/mm/exch/archon/archon/exchange/bitmex/bitmex.py", line 423, in _query_bitmex
self.logger.error("429 Too Many Requests for url. Request: %s \n %s" % (url, json.dumps(postdict)))
File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.6/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.6/json/encoder.py", line 180, in default
o.__class__.__name__)
TypeError: Object of type 'UUID' is not JSON serializable
How do you pronounce "archon"?
result none
0x is a Ethereum-DEX protocol. archon has a generic broker architecture which can allow to trade against CEX or DEX at the same time. archon's role is to make it easier to use exchange wrappers and any exchange communication by adding middleware i.e. a "trading broker" described here [1]. the middleware makes it easy to write strategy code by bridging polling or streaming protocols, track orders and execution. 0x can be integrated by adding a exchange gateway to the broker
the calls needed are:
the broker will poll the smart contracts/relayers. the frontend of archon can be used to display the relevant data i.e. orderbooks, balances, orders, executions
relevant libraries that can be used is the python backend from makerdao
https://github.com/makerdao/pymaker
https://github.com/makerdao/pyexchange
https://github.com/0xProject/0x-monorepo/
[1] https://gist.github.com/benjyz/d9faef0926b20473716cf28286df77ed
install python3 https://docs.python-guide.org/starting/install3/win/
install pip3, see https://stackoverflow.com/questions/41501636/how-to-install-pip3-on-windows, https://matthewhorne.me/how-to-install-python-and-pip-on-windows-10/
install requirements.txt with pip
add apikeys.toml file
add conf.toml file
at startup and regularly hearbeat exchange and ensure connection is ok
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.