QSTraderRunner#
tradeexecutor.strategy.qstrader.runner.QSTraderRunner Python class in Trading Strategy framework.
- class QSTraderRunner[source]#
Bases:
StrategyRunner
A live trading executor for QSTrade based algorithm.
Warning
This is legacy alpha code and will be deprecated.
- __init__(*args, alpha_model, max_data_age=None, cash_buffer=0.05, **kwargs)[source]#
- Parameters:
alpha_model (AlphaModel) –
timed_task_context_manager –
max_data_age (Optional[timedelta]) – Allow to unit test on old datasets
Methods
__init__
(*args, alpha_model[, max_data_age, ...])- param alpha_model:
check_accounts
(universe, state)Perform extra accounting checks on live trading startup.
check_position_triggers
(clock, state, ...)Check stop loss/take profit for positions.
is_progress_report_needed
()Do we log the strategy steps to logger?
on_clock
(clock, executor_universe, ...)Run one strategy cycle.
on_data_signal
()pretick_check
(ts, universe)Check the data looks more or less sane.
refresh_visualisations
(state, universe)Update the visualisations in the run state.
repair_state
(state)Repair unclean state issues.
report_after_execution
(clock, universe, ...)report_after_sync_and_revaluation
(clock, ...)report_before_execution
(clock, universe, ...)report_strategy_thinking
(...)Strategy admin helpers to understand a live running strategy.
revalue_portfolio
(ts, state, valuation_method)Revalue portfolio based on the data.
setup_routing
(universe)Setups routing state for this cycle.
sync_portfolio
(strategy_cycle_ts, universe, ...)Adjust portfolio balances based on the external events.
tick
(strategy_cycle_timestamp, universe, ...)Execute the core functions of a strategy.
- __init__(*args, alpha_model, max_data_age=None, cash_buffer=0.05, **kwargs)[source]#
- Parameters:
alpha_model (AlphaModel) –
timed_task_context_manager –
max_data_age (Optional[timedelta]) – Allow to unit test on old datasets
- on_clock(clock, executor_universe, pricing_model, state, debug_details)[source]#
Run one strategy cycle.
Takes universe, pricing model and state as an input
Generates a list of new trades to change the current state
- Parameters:
clock (datetime) –
executor_universe (TradingStrategyUniverse) –
pricing_model (PricingModel) –
state (State) –
debug_details (dict) –
- Return type:
- pretick_check(ts, universe)[source]#
Check the data looks more or less sane.
- Parameters:
ts (datetime) –
universe (TradingStrategyUniverse) –