Overall Statistics
Total Trades
200
Average Win
0.18%
Average Loss
-0.24%
Compounding Annual Return
-3.036%
Drawdown
6.700%
Expectancy
-0.190
Net Profit
-3.728%
Sharpe Ratio
-0.709
Probabilistic Sharpe Ratio
0.953%
Loss Rate
54%
Win Rate
46%
Profit-Loss Ratio
0.74
Alpha
-0.02
Beta
-0.176
Annual Standard Deviation
0.029
Annual Variance
0.001
Information Ratio
-0.224
Tracking Error
0.107
Treynor Ratio
0.118
Total Fees
$0.00
Estimated Strategy Capacity
$1000000.00
Lowest Capacity Asset
USDDKK 8G
from AlgorithmImports import *
# endregion

class CustomIndexStrategy(QCAlgorithm):

    def Initialize(self):

        self.Pair_1_Multiplier = 4
        self.Pair_1 = "USDDKK"
        self.holdingDays = 1
        self.SetStartDate (2015, 3, 3) 
        self.SetEndDate(2016,5,24)
        self.SetCash(1000000)  
        self.SetBrokerageModel(BrokerageName.OandaBrokerage)
        self.EURSEK = self.AddForex(self.Pair_1, Resolution.Daily, Market.Oanda)
        self.symbols = [self.Pair_1]
        self.prevPrices = { symbol : RollingWindow[QuoteBar](7) for symbol in self.symbols }
        self.ticketPair1 = None 

    def OnData(self,data):
        
        for symbol in self.symbols:
            if data.ContainsKey(symbol):
                self.prevPrices[symbol].Add( data[symbol] )

        if not all([ window.IsReady for window in self.prevPrices.values() ]):
            return
            
        Pair1_window = self.prevPrices[self.Pair_1]
        Pair1_1D = Pair1_window[1].Close
        Pair1_0D = Pair1_window[0].Close

        if self.ticketPair1 is not None and self.UtcTime < self.ticketPair1.Time + timedelta(days=(self.holdingDays)):
            return

        if self.ticketPair1 is None and self.IsMarketOpen(self.Pair_1) and Pair1_0D < Pair1_1D and self.Time.weekday() != 4:
            self.ticketPair1 = self.MarketOrder(self.Pair_1, 100000 * self.Pair_1_Multiplier)    

        if self.ticketPair1 is not None and self.UtcTime >= self.ticketPair1.Time + timedelta(days = self.holdingDays) and self.Time.weekday() != 4: 
            self.MarketOrder(self.Pair_1, -100000 * self.Pair_1_Multiplier)
            self.ticketPair1 = None