Overall Statistics
Total Trades
201
Average Win
0.18%
Average Loss
-0.21%
Compounding Annual Return
-2.016%
Drawdown
4.100%
Expectancy
-0.122
Net Profit
-2.478%
Sharpe Ratio
-0.73
Probabilistic Sharpe Ratio
0.978%
Loss Rate
52%
Win Rate
48%
Profit-Loss Ratio
0.83
Alpha
-0.013
Beta
-0.103
Annual Standard Deviation
0.019
Annual Variance
0
Information Ratio
-0.173
Tracking Error
0.099
Treynor Ratio
0.134
Total Fees
$0.00
Estimated Strategy Capacity
$1600000.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 Pair1_0D < Pair1_1D and self.Securities["USDDKK"].Exchange.ExchangeOpen is True:
            
            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.Securities["USDDKK"].Exchange.ExchangeOpen is True: 
            
            self.MarketOrder(self.Pair_1, -100000 * self.Pair_1_Multiplier)
            self.ticketPair1 = None