The exact APIs used to initialize a bot has not been fleshed out yet. For now, you do it like this:
import digitex_bot_framework
bot = digitex_bot_framework.Bot(host=..., token=...)Then, add one or more markets you're going to trade on:
market = digitex_bot_framework.Market.BTC_USD
await bot.add_market(market)That's it, from there on you can start your trading.
You can trade on one or more markets, represented by the Market objects.
Market.BTC_USDMarket.ETH_USDMarket.XRPx10000_USDMarket.XAU_USDMarket.AMZNMarket.BTC_USD1
From a market, you can get to:
market.bot, a reference back to the botmarket.ticktick.size, the size of one tick in the quote currencytick.price, the price of one tick in the native currency (DGTX)
market.currency_pairmarket.rounded_spot_price(), the current spot price (market.currency_pair.mark_price), rounded to the market's tick size. You can pass adirectionargument, which should be eitherup,down, orclosest(the default)market.order_bookmarket.last_tradelast_trade.pricelast_trade.quantitylast_trade.time
market.trader
There are a bunch of currency pairs pre-declared, such as CurrencyPair.BTC_USD, and
you can always get the one to use with a particular market as market.currency_pair.
A currency pair has:
currency_pair.code, a short string identifying the currency pair (e.g. "BTC/USD")currency_pair.mark_price,currency_pair.sell_price, andcurrency_pair.buy_price, the latest spot price values (these will initially beNoneuntil price info is received)currency_pair.on_update(), a hook you can use to listen for spot price changes
You can get to the order book from a market using market.order_book.
An order book has:
order_book.bids,order_book.asks, dictionaries mapping prices to order book entries (both of these dictionaries will initially beNone)order_book.best_bid_price(),order_book.best_ask_price(), the best bid and ask prices in the order book (will beNoneif there's no such price)order_book.on_update(), a hook you can use to listen for order book updates
Each order book entry has:
order_book_entry.priceorder_book_entry.quantityorder_book_entry.entry_time
The trader objects represents properties of the individual trader (you), as
opposed to general properties of the market. You can get to the trader from
a market using market.trader.
The trader has:
trader.balance,trader.pnl,trader.upnltrader.positiontrader.orderstrader.leverage,await trader.change_leverage()trader.on_update()
position.contractsposition.volumeposition.liquidation_volumeposition.bankruptcy_volumeposition.marginposition.type, which can beNone(unknown),PositionType.FLAT,PositionType.LONG, andPositionType.SHORTposition.on_update()
The Orders class is a collection of trader's orders. It addtionally provides
the following APIs:
orders.margin,orders.buy_margin,orders.sell_marginasync orders.place(order)async orders.cancel_all()orders.on_margins_update
Each order has the following properties:
order.priceorder.quantityorder.side, eitherOrderSide.BUYorOrderSide.SELLorder.type, eitherOrderType.LIMIT(the default) orOrderType.MARKETorder.duration, which you should probably leave atOrderDuration.GTCorder.statusorder.error_code
Create an order by calling its constructor, then placing it into orders:
order = Order(price=..., quantity=..., side=...)
await market.trader.orders.place(order)