Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# for logging
from findatapy.util import LoggerManager
# for signal generation
from finmarketpy.economics import TechIndicator, TechParams
# for plotting
from chartpy import Chart, Style
logger = LoggerManager().getLogger(__name__)
import datetime
backtest = Backtest()
br = BacktestRequest()
fxconv = FXConv()
# get all asset data
br.start_date = "02 Jan 1990"
br.finish_date = datetime.datetime.utcnow()
br.spot_tc_bp = 2.5 # 2.5 bps bid/ask spread
br.ann_factor = 252
tech_params = TechParams();
tech_params.sma_period = 200;
indicator = 'SMA'
tech_params.only_allow_longs = True
# tech_params.only_allow_shorts = True
# pick EUR/USD
# note: we are calculating returns from spot (it is much better to use to total return
# for logging
from findatapy.util.loggermanager import LoggerManager
# for signal generation
from finmarketpy.economics import TechIndicator, TechParams
# for plotting
from chartpy import Chart, Style
logger = LoggerManager().getLogger(__name__)
import datetime
backtest = Backtest()
br = BacktestRequest()
fxconv = FXConv()
# get all asset data
br.start_date = "02 Jan 1990"
br.finish_date = datetime.datetime.utcnow()
br.spot_tc_bp = 2.5 # 2.5 bps bid/ask spread
br.ann_factor = 252
# have vol target for each signal
br.signal_vol_adjust = True
br.signal_vol_target = 0.05
br.signal_vol_max_leverage = 3
br.signal_vol_periods = 60
br.signal_vol_obs_in_year = 252
br.signal_vol_rebalance_freq = 'BM'
br.signal_vol_resample_freq = None
def load_parameters(self, br = None):
if br is not None: return br
##### FILL IN WITH YOUR OWN BACKTESTING PARAMETERS
br = BacktestRequest()
# get all asset data
br.start_date = "04 Jan 1989"
br.finish_date = datetime.datetime.utcnow().date()
br.spot_tc_bp = 0.5
br.ann_factor = 252
br.plot_start = "01 Apr 2015"
br.calc_stats = True
br.write_csv = False
br.plot_interim = True
br.include_benchmark = True
# have vol target for each signal
br.signal_vol_adjust = True
br.signal_vol_target = 0.1
def load_parameters(self, br = None):
if br is not None: return br
##### FILL IN WITH YOUR OWN BACKTESTING PARAMETERS
br = BacktestRequest()
# get all asset data
br.start_date = "04 Jan 1989"
br.finish_date = datetime.datetime.utcnow().date()
br.spot_tc_bp = 0.5
br.ann_factor = 252
br.plot_start = "01 Apr 2015"
br.calc_stats = True
br.write_csv = False
br.plot_interim = True
br.include_benchmark = True
# have vol target for each signal
br.signal_vol_adjust = True
br.signal_vol_target = 0.1