本文整理汇总了Python中zipline.TradingAlgorithm.metrics_tracker方法的典型用法代码示例。如果您正苦于以下问题:Python TradingAlgorithm.metrics_tracker方法的具体用法?Python TradingAlgorithm.metrics_tracker怎么用?Python TradingAlgorithm.metrics_tracker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zipline.TradingAlgorithm
的用法示例。
在下文中一共展示了TradingAlgorithm.metrics_tracker方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bts_simulation_dt
# 需要导入模块: from zipline import TradingAlgorithm [as 别名]
# 或者: from zipline.TradingAlgorithm import metrics_tracker [as 别名]
def test_bts_simulation_dt(self):
code = """
def initialize(context):
pass
"""
algo = TradingAlgorithm(
script=code,
sim_params=self.sim_params,
env=self.env,
metrics=metrics.load('none'),
)
algo.metrics_tracker = algo._create_metrics_tracker()
benchmark_source = algo._create_benchmark_source()
algo.metrics_tracker.handle_start_of_simulation(benchmark_source)
dt = pd.Timestamp("2016-08-04 9:13:14", tz='US/Eastern')
algo_simulator = AlgorithmSimulator(
algo,
self.sim_params,
self.data_portal,
BeforeTradingStartsOnlyClock(dt),
benchmark_source,
NoRestrictions(),
None
)
# run through the algo's simulation
list(algo_simulator.transform())
# since the clock only ever emitted a single before_trading_start
# event, we can check that the simulation_dt was properly set
self.assertEqual(dt, algo_simulator.simulation_dt)