| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -3.598% Drawdown 25.100% Expectancy 0 Net Profit -13.920% Sharpe Ratio -0.332 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.104 Beta -8.057 Annual Standard Deviation 0.08 Annual Variance 0.006 Information Ratio -0.535 Tracking Error 0.08 Treynor Ratio 0.003 Total Fees $0.00 |
from System import *
from QuantConnect import *
from QuantConnect.Data.Consolidators import *
from QuantConnect.Data.Market import *
from QuantConnect.Orders import OrderStatus
from QuantConnect.Algorithm import QCAlgorithm
from QuantConnect.Indicators import *
import numpy as np
from datetime import timedelta, datetime
class RollingWindowAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2013,10,1)
self.SetEndDate(2017,11,1)
self.SetCash(100000)
ForexSymbols = ["EURUSD", "USDJPY"]
for symbol in ForexSymbols:
self.AddForex(symbol, Resolution.Daily)
self.SMA("EURUSD", 9).Updated += self.SmaUpdated
self.SMA("USDJPY", 9).Updated += self.SmaUpdated
self.smaWin = RollingWindow[IndicatorDataPoint](9)
self.window = RollingWindow[QuoteBar](2)
def SmaUpdated(self, sender, updated):
self.smaWin.Add(updated)
def OnData(self, data):
self.window.Add(data["EURUSD"])
holdingseurusd = self.Portfolio["EURUSD"].Quantity
if not (self.window.IsReady and self.smaWin.IsReady): return
CurrentBar = self.window[0]
PastBar = self.window[1]
currSma = self.smaWin[0]
pastSma = self.smaWin[1]
if holdingseurusd <= 0 and currSma.Value > pastSma.Value:
self.SetHoldings("EURUSD", 1)