Strategy

class quanttrader.strategy.strategy_base.StrategyBase

Base strategy class

adjust_position(sym, size_from, size_to, timestamp=None)

use market order to adjust position :param sym: :param size_from: :param size_to: :param timestamp: used by backtest broker to get price on timestamp :return:

cancel_all()

cancel all standing orders from this strategy id :return:

cancel_order(oid)
on_fill(fill_event)

on order filled derived class call super().on_fill first

on_init(strategy_manager, data_board, instrument_meta)
on_order_status(order_event)

on order acknowledged :return:

on_start()
on_stop()
on_tick(tick_event)

Respond to tick

place_order(o)

expect user to set up order type, order size and order price

set_capital(capital)
set_name(name)
set_params(params_dict=None)
set_symbols(symbols)
class quanttrader.strategy.strategy_manager.StrategyManager(config, broker, order_manager, position_manager, risk_manager, data_board, instrument_meta)
cancel_all()
cancel_order(oid)
cancel_strategy(sid)

call strategy cancel to take care of strategy order_manager

flat_all()

flat all according to position_manager TODO: should turn off all strategies? :return:

flat_strategy(sid)

flat with MARKET order (default) Assume each strategy track its own positions TODO: should turn off strategy?

load_strategy(strat_dict)
on_cancel(order_event)

TODO no need for this

on_fill(fill_event)

assign fill ordering to order id ==> strategy id TODO: check fill_event source; if not, fix it or use fill_event.order_id

on_order_status(order_event)

TODO: check if source is working :param order_event: :return:

on_position(pos)

get initial position read from config file instead :param pos: :return:

on_tick(k)
pause_strategy(sid)
place_order(o, check_risk=True)
start_all()
start_strategy(sid)
stop_all()
stop_strategy(sid)