本文整理汇总了Python中pythalesians.graphics.graphs.graphproperties.GraphProperties.resample方法的典型用法代码示例。如果您正苦于以下问题:Python GraphProperties.resample方法的具体用法?Python GraphProperties.resample怎么用?Python GraphProperties.resample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pythalesians.graphics.graphs.graphproperties.GraphProperties
的用法示例。
在下文中一共展示了GraphProperties.resample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_arbitrary_sensitivity
# 需要导入模块: from pythalesians.graphics.graphs.graphproperties import GraphProperties [as 别名]
# 或者: from pythalesians.graphics.graphs.graphproperties.GraphProperties import resample [as 别名]
def run_arbitrary_sensitivity(self, strat, parameter_list = None, parameter_names = None,
pretty_portfolio_names = None, parameter_type = None):
asset_df, spot_df, spot_df2, basket_dict = strat.fill_assets()
port_list = None
for i in range(0, len(parameter_list)):
br = strat.fill_backtest_request()
current_parameter = parameter_list[i]
# for calculating P&L
for k in current_parameter.keys():
setattr(br, k, current_parameter[k])
strat.br = br # for calculating signals
signal_df = strat.construct_signal(spot_df, spot_df2, br.tech_params)
cash_backtest = CashBacktest()
self.logger.info("Calculating... " + pretty_portfolio_names[i])
cash_backtest.calculate_trading_PnL(br, asset_df, signal_df)
stats = str(cash_backtest.get_portfolio_pnl_desc()[0])
port = cash_backtest.get_cumportfolio().resample('B')
port.columns = [pretty_portfolio_names[i] + ' ' + stats]
if port_list is None:
port_list = port
else:
port_list = port_list.join(port)
pf = PlotFactory()
gp = GraphProperties()
gp.color = 'Blues'
gp.resample = 'B'
gp.file_output = self.DUMP_PATH + strat.FINAL_STRATEGY + ' ' + parameter_type + '.png'
gp.scale_factor = self.scale_factor
gp.title = strat.FINAL_STRATEGY + ' ' + parameter_type
pf.plot_line_graph(port_list, adapter = 'pythalesians', gp = gp)
示例2: run_arbitrary_sensitivity
# 需要导入模块: from pythalesians.graphics.graphs.graphproperties import GraphProperties [as 别名]
# 或者: from pythalesians.graphics.graphs.graphproperties.GraphProperties import resample [as 别名]
def run_arbitrary_sensitivity(self, strat, parameter_list = None, parameter_names = None,
pretty_portfolio_names = None, parameter_type = None):
asset_df, spot_df, spot_df2, basket_dict = strat.fill_assets()
port_list = None
tsd_list = []
for i in range(0, len(parameter_list)):
br = strat.fill_backtest_request()
current_parameter = parameter_list[i]
# for calculating P&L
for k in current_parameter.keys():
setattr(br, k, current_parameter[k])
strat.br = br # for calculating signals
signal_df = strat.construct_signal(spot_df, spot_df2, br.tech_params, br)
cash_backtest = CashBacktest()
self.logger.info("Calculating... " + pretty_portfolio_names[i])
cash_backtest.calculate_trading_PnL(br, asset_df, signal_df)
tsd_list.append(cash_backtest.get_portfolio_pnl_tsd())
stats = str(cash_backtest.get_portfolio_pnl_desc()[0])
port = cash_backtest.get_cumportfolio().resample('B').mean()
port.columns = [pretty_portfolio_names[i] + ' ' + stats]
if port_list is None:
port_list = port
else:
port_list = port_list.join(port)
# reset the parameters of the strategy
strat.br = strat.fill_backtest_request()
pf = PlotFactory()
gp = GraphProperties()
ir = [t.inforatio()[0] for t in tsd_list]
# gp.color = 'Blues'
# plot all the variations
gp.resample = 'B'
gp.file_output = self.DUMP_PATH + strat.FINAL_STRATEGY + ' ' + parameter_type + '.png'
gp.scale_factor = self.scale_factor
gp.title = strat.FINAL_STRATEGY + ' ' + parameter_type
pf.plot_line_graph(port_list, adapter = 'pythalesians', gp = gp)
# plot all the IR in a bar chart form (can be easier to read!)
gp = GraphProperties()
gp.file_output = self.DUMP_PATH + strat.FINAL_STRATEGY + ' ' + parameter_type + ' IR.png'
gp.scale_factor = self.scale_factor
gp.title = strat.FINAL_STRATEGY + ' ' + parameter_type
summary = pandas.DataFrame(index = pretty_portfolio_names, data = ir, columns = ['IR'])
pf.plot_bar_graph(summary, adapter = 'pythalesians', gp = gp)
return port_list