本文整理汇总了Python中simulation.Simulation.apply_strategy方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.apply_strategy方法的具体用法?Python Simulation.apply_strategy怎么用?Python Simulation.apply_strategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.apply_strategy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_simulations
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import apply_strategy [as 别名]
def process_simulations(self):
"""
This function will iterate over all the symbols and simulate the
strategy.
"""
n=0 # For sleeping and going on getting data from yahoo
for row in self.symbols.iterrows():
symbol = row[1]['symbol']
print 'processing ' + str(symbol)
sim = Simulation(symbol, from_date=self.from_date, to_date=self.to_date)
sim.get_prices_yahoo()
sim.apply_strategy(self.strategy)
s_result = sim.get_result()
if s_result.empty: continue ## If it was not possible to make the simulation
s_result = s_result.append(row[1])
self.df_results = self.df_results.append(s_result, ignore_index=True)
columns = ['symbol', 'name', 'category', 'subcategory', 'track index',
'comments', 'commodity', 'sector', 'countries', 'assets',
'avg. vol', 'inverse', 'leveraged',
'from_date', 'to_date', 'nperiods', 'ntrades',
'max_open', 'drawdown', 'abs_profit', 'pct_simple_profit',
'pct_compound_profit', 'annual_pct_simple_profit',
'annual_pct_compound_profit', 'volatility', 'sharpe']
self.df_results = self.df_results[columns]
## Time for not overuse Yahoo API
n += 1
if n == 350:
# sleep(10)
n=0
示例2: process_simulations
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import apply_strategy [as 别名]
def process_simulations(self):
"""
This function will iterate over all the symbols and simulate the
strategy.
"""
for row in self.symbols.iterrows():
symbol = row[1]['symbol']
print 'processing ' + str(symbol)
sim = Simulation(symbol, from_date=self.from_date, to_date=self.to_date)
sim.get_prices_yahoo()
sim.apply_strategy(self.strategy)
s_result = sim.get_result()
s_result['symbol']=symbol
self.df_results = self.df_results.append(s_result, ignore_index=True)