Working With Minute Bar Simulations
Anatomy of a CloudQuant Lite Script High Level Strategy - Start/Finishon_stategy_start: called when the strategy starts (aka before anything else)
@classmethod
def on_strategy_start(cls, md, service, account):
pass
on_strategy_finish: called when the strategy finish (aka after everything else has stopped)
@classmethod
def on_strategy_finish(cls, md, service, account):
pass
is_symbol_qualified: this determines which symbols the script will run on if you do not set up specific symbols when you schedule the backtest. You can choose symbols dynamically, for example choosing those with a certain number of shares. This is called once when the strategy starts. Note that this doesn't start with "self" because it's a @classmethod
@classmethod
def is_symbol_qualified(cls, symbol, md, service, account):
return True
backtesting_extra_symbols: used to load data for other symbols that are not in is_symbol_qualified, for example if you want to compare your symbol to an index. Only used in backtesting
@classmethod
def backtesting_extra_symbols(cls, symbol, md, service, account):
return False
__init__: used to pass external parameters for each instance (same for values for every instance)
def __init__(self): #, **params - if passing in parameters is desired
pass
on_start: called at the beginning of each instance
def on_start(self, md, order, service, account):
pass
on_finish: if running with an instance per symbol, call when an instance is terminated
def on_finish(self, md, order, service, account):
pass
on_save: called by the system at the end of a trading day when a script is run as a "Single Symbol Script" (not using is_symbol_qualified) and hasn't been terminated
def on_save(self, state_dict):
pass
on_restore: called by the system after on_start when a script is run as a "Single Symbol Script" (not using is_symbol_qualified) and has been restored
def on_restore(self, state_dict):
pass
on_minute_bar: called 5 seconds after a new minute starts
def on_minute_bar(self, event, md, order, service, account, bar):
pass