How to use the finmarketpy.backtest.TradingModel function in finmarketpy

To help you get started, we’ve selected a few finmarketpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cuemacro / finmarketpy / finmarketpy_examples / tradingmodelfxtrend_example.py View on Github external
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)
github cuemacro / finmarketpy / finmarketpy_examples / tradingmodelfxtrend_example.py View on Github external
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
github cuemacro / finmarketpy / finmarketpy_examples / tradingmodelfxtrend_bbg_example.py View on Github external
"""
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):
github cuemacro / finmarketpy / finmarketpy_examples / tradingmodelfxtrend_bbg_example.py View on Github external
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