コード例 #1
0
            vendor_fields = ['close'],
            cache_algo = 'cache_algo_return')               # how to return data)

        df = self.tsfactory.harvest_time_series(tsr_indices)

        df.columns = [x.split(".")[0] for x in df.columns]

        return df

if __name__ == '__main__':

    # create FX CTA strategy then chart the returns, leverage over time
    if True:
        strategy = StrategyFXCTA_Example()

        strategy.construct_strategy()
        strategy.plot_strategy_pnl()
        strategy.plot_strategy_leverage()
        strategy.plot_strategy_group_benchmark_pnl()
        strategy.plot_strategy_group_leverage()
        strategy.plot_strategy_group_benchmark_annualised_pnl()

    # create FX CTA strategy then use TradeAnalysis (via pyfolio) to analyse returns
    if True:
        from pythalesians.backtest.stratanalysis.tradeanalysis import TradeAnalysis
        strategy = StrategyFXCTA_Example()
        strategy.construct_strategy()

        tradeanalysis = TradeAnalysis()
        tradeanalysis.run_strategy_returns_stats(strategy)
コード例 #2
0
        strategy.plot_strategy_pnl()                        # plot the final strategy
        strategy.plot_strategy_leverage()                   # plot the leverage of the portfolio
        strategy.plot_strategy_group_pnl_trades()           # plot the individual trade P&Ls
        strategy.plot_strategy_group_benchmark_pnl()        # plot all the cumulative P&Ls of each component
        strategy.plot_strategy_group_leverage()             # plot all the individual leverages
        strategy.plot_strategy_group_benchmark_annualised_pnl()

    # create a FX CTA strategy, then examine how P&L changes with different vol targeting
    # and later transaction costs
    if True:
        strategy = StrategyFXCTA_Example()

        from pythalesians.backtest.stratanalysis.tradeanalysis import TradeAnalysis

        ta = TradeAnalysis()

        # which backtesting parameters to change
        # names of the portfolio
        # broad type of parameter name
        parameter_list = [
            {'portfolio_vol_adjust': True, 'signal_vol_adjust' : True},
            {'portfolio_vol_adjust': False, 'signal_vol_adjust' : False}]

        pretty_portfolio_names = \
            ['Vol target',
             'No vol target']

        parameter_type = 'vol target'

        ta.run_arbitrary_sensitivity(strategy,
コード例 #3
0
            cache_algo='cache_algo_return')  # how to return data)

        df = self.tsfactory.harvest_time_series(tsr_indices)

        df.columns = [x.split(".")[0] for x in df.columns]

        return df


if __name__ == '__main__':

    # create FX CTA strategy then chart the returns, leverage over time
    if True:
        strategy = StrategyFXCTA_Example()

        strategy.construct_strategy()
        strategy.plot_strategy_pnl()
        strategy.plot_strategy_leverage()
        strategy.plot_strategy_group_benchmark_pnl()
        strategy.plot_strategy_group_leverage()
        strategy.plot_strategy_group_benchmark_annualised_pnl()

    # create FX CTA strategy then use TradeAnalysis (via pyfolio) to analyse returns
    if True:
        from pythalesians.backtest.stratanalysis.tradeanalysis import TradeAnalysis
        strategy = StrategyFXCTA_Example()
        strategy.construct_strategy()

        tradeanalysis = TradeAnalysis()
        tradeanalysis.run_strategy_returns_stats(strategy)