QSTraderRunner#

API documentation for 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 version code and will be deprecated. It is only used in unit testing.

__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_balances_post_execution(universe, ...)

Check that on-chain balances matches our internal accounting after executing trades.

check_position_triggers(clock, state, ...[, ...])

Check stop loss/take profit for positions.

collect_post_execution_data(...)

Collect post execution data for all trades.

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_state(ts, state, valuation_model)

Revalue portfolio based on the latest prices.

setup_routing(universe)

Setups routing state for this cycle.

sync_portfolio(...[, end_block, ...])

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:
Return type:

List[TradeExecution]

pretick_check(ts, universe)[source]#

Check the data looks more or less sane.

Parameters: