Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
TradingModelFXCTA
Shows how to create a simple FX CTA style strategy, using the StrategyTemplate abstract class (backtest_examples.py
is a lower level way of doing this).
"""
import datetime
from findatapy.market import Market, MarketDataGenerator, MarketDataRequest
from finmarketpy.backtest import TradingModel, BacktestRequest
from finmarketpy.economics import TechIndicator
from chartpy import Style
class TradingModelFXTrend_Example(TradingModel):
def __init__(self):
super(TradingModel, self).__init__()
##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
self.market = Market(market_data_generator=MarketDataGenerator())
self.DUMP_PATH = ''
self.FINAL_STRATEGY = 'FX trend'
self.SCALE_FACTOR = 1
self.DEFAULT_PLOT_ENGINE = 'matplotlib'
# self.CHART_STYLE = Style(plotly_plot_mode='offline_jupyter')
self.br = self.load_parameters()
return
###### Parameters and signal generations (need to be customised for every model)
def __init__(self):
super(TradingModel, self).__init__()
##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
self.market = Market(market_data_generator=MarketDataGenerator())
self.DUMP_PATH = ''
self.FINAL_STRATEGY = 'FX trend'
self.SCALE_FACTOR = 1
self.DEFAULT_PLOT_ENGINE = 'matplotlib'
# self.CHART_STYLE = Style(plotly_plot_mode='offline_jupyter')
self.br = self.load_parameters()
return
"""
TradingModelFXCTA
Shows how to create a simple FX CTA style strategy, using the StrategyTemplate abstract class (backtest_examples.py
is a lower level way of doing this). Uses BBG total returns data.
"""
import datetime
from findatapy.market import Market, MarketDataGenerator, MarketDataRequest
from finmarketpy.backtest import TradingModel, BacktestRequest
from finmarketpy.economics import TechIndicator
class TradingModelFXTrend_BBG_Example(TradingModel):
def __init__(self):
super(TradingModel, self).__init__()
##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
self.market = Market(market_data_generator=MarketDataGenerator())
self.DUMP_PATH = ''
self.FINAL_STRATEGY = 'FX trend'
self.SCALE_FACTOR = 1
self.DEFAULT_PLOT_ENGINE = 'matplotlib'
self.br = self.load_parameters()
return
###### Parameters and signal generations (need to be customised for every model)
def load_parameters(self, br = None):
def __init__(self):
super(TradingModel, self).__init__()
##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
self.market = Market(market_data_generator=MarketDataGenerator())
self.DUMP_PATH = ''
self.FINAL_STRATEGY = 'FX trend'
self.SCALE_FACTOR = 1
self.DEFAULT_PLOT_ENGINE = 'matplotlib'
self.br = self.load_parameters()
return