| Overall Statistics |
|
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -7.791 Tracking Error 0.134 Treynor Ratio 0 Total Fees $0.00 |
class MyAlgor(QCAlgorithm):
def Initialize(self):
# configurable params
self.baseFX = 'EUR'
self.quoteFX = 'GBP'
self.atrPeriod = 14
self.fastPeriod = 50
# set brokerage model / account type / cash
self.SetBrokerageModel(BrokerageName.OandaBrokerage)
self.SetCash(10000)
# start and end dates for the backtest
#self.SetTimeZone("UTC")
self.SetStartDate(2020, 7, 1)
self.SetEndDate(2020, 7, 10)
# add currency pair
self.fx = self.baseFX + self.quoteFX
self.symbol = self.AddForex(self.fx, Resolution.Minute, market=Market.Oanda).Symbol
#self.fx = "SPY"
#self.symbol = self.AddEquity("SPY", Resolution.Daily, Market.USA).Symbol
# schedule event 60 mins after market open
self.Schedule.On(
self.DateRules.EveryDay(self.fx),
self.TimeRules.AfterMarketOpen(self.fx, 60),
self.EveryDayAfterMarketOpen
)
# add indicators and warmup period
self.atr = self.ATR(
self.symbol,
self.atrPeriod,
MovingAverageType.Wilders,
Resolution.Daily
)
self.atr.Updated += self.atrUpdated
self.fastEMA = self.EMA(
self.symbol,
self.fastPeriod,
Resolution.Daily
)
self.SetWarmUp(
max(
self.atrPeriod,
self.fastPeriod,
),
Resolution.Daily
)
def EveryDayAfterMarketOpen(self):
if self.IsWarmingUp:
return
#self.Log(f"{self.Time} atr {self.atr.Current.Value:,.4f} fast ema {self.fastEMA.Current.Value:,.4f}")
def OnEndOfDay(self):
self.Log(f"Closing Price: {self.Securities[self.fx].Price}")
def atrUpdated(self, sender, updated):
if not self.IsWarmingUp:
self.Log(f"ATR: {self.atr.Current.Value} EMA: {self.fastEMA.Current.Value}")