Module areixio.brokers.realtime_broker

Classes

class RealtimeBroker (base_currency: str = 'USDT', include_current_position: bool = False)

on_connect on_disconnect on_error on_tick on_account on_trade on_order on_position

Ancestors

  • areixio.broker.Broker
  • Base
  • abc.ABC

Methods

def add_connection(self, exchange: str, asset_type: Union[str, AssetType], key: str, secret: str, user_id: str = None, passphrase: str = None, is_testnet: bool = False, leverage: float = None, mode: str = 'oneway', is_isolated: bool = True, version: int = None, on_account_callback: Callable = None, on_order_callback: Callable = None, on_trade_callback: Callable = None, on_position_callback: Callable = None)
def cancel_order(self, order)

Cancel an existing order. implementation should finish the tasks blow: * send request to server

def close(self) ‑> None

Close broker connection.

def connect(self) ‑> None

Start broker connection.

to implement this method, you must: * connect to server if necessary * log connected if all necessary connection is established * do the following query and response corresponding on_xxxx and write_log * contracts : on_contract * account asset : on_account * account holding: on_position * orders of account: on_order * trades of account: on_trade * if any of query above is failed, write log.

future plan: response callback/change status instead of write_log

def query_account(self) ‑> None

Query account balance.

def query_position(self, symbol: str = None) ‑> None

Query holding positions.

def send_order(self, order)

Send a new order to server.

implementation should finish the tasks blow: * create an OrderData from req using OrderRequest.create_order_data * assign a unique(gateway instance scope) id to OrderData.orderid * send request to server * if request is sent, OrderData.status should be set to Status.SUBMITTING * if request is failed to sent, OrderData.status should be set to Status.REJECTED * response on_order: * return vt_orderid

:return str vt_orderid for created OrderData

def subscribe(self, symbol, exchange=None, asset_type=None) ‑> None

Subscribe tick data update.

Inherited members