Overall Statistics
Total Trades
120
Average Win
0.18%
Average Loss
-0.04%
Compounding Annual Return
6.262%
Drawdown
8.700%
Expectancy
2.301
Net Profit
35.548%
Sharpe Ratio
0.841
Probabilistic Sharpe Ratio
31.147%
Loss Rate
44%
Win Rate
56%
Profit-Loss Ratio
4.87
Alpha
0.045
Beta
-0.003
Annual Standard Deviation
0.053
Annual Variance
0.003
Information Ratio
-0.509
Tracking Error
0.165
Treynor Ratio
-13.904
Total Fees
$0.00
Estimated Strategy Capacity
$1900000.00
Lowest Capacity Asset
USDTRY 8G
# The official interest rate is from Quandl
from QuantConnect.Python import PythonQuandl
from NodaTime import DateTimeZone


class BootCampTask(QCAlgorithm):

    def Initialize(self):

        self.SetStartDate(2016, 6, 1) 
        self.SetEndDate(2021, 6, 1)  
        self.SetCash(100000)
        
        tickers = ["USDEUR", "USDZAR", "USDAUD",
                   "USDJPY", "USDTRY", "USDINR", 
                   "USDCNY", "USDMXN", "USDCAD"]
        
        rate_symbols = ["BCB/17900",  # Euro Area 
                        "BCB/17906",  # South Africa
                        "BCB/17880",  # Australia
                        "BCB/17903",  # Japan
                        "BCB/17907",  # Turkey
                        "BCB/17901",  # India
                        "BCB/17899",  # China
                        "BCB/17904",  # Mexico
                        "BCB/17881"]  # Canada
       
        self.symbols = {}
        for i in range(len(tickers)):
            symbol = self.AddForex(tickers[i], Resolution.Daily, Market.Oanda).Symbol
            self.AddData(QuandlRate, rate_symbols[i], Resolution.Daily, DateTimeZone.Utc, True)
            self.symbols[str(symbol)] = rate_symbols[i]
            
        self.Schedule.On(self.DateRules.MonthStart("USDEUR"), self.TimeRules.AfterMarketOpen("USDEUR"), Action(self.Rebalance))

    def Rebalance(self):
        top_symbols = sorted(self.symbols, key = lambda x: self.Securities[self.symbols[x]].Price)
        
        if self.Securities[top_symbols[0]].Price != 0 and self.Securities[top_symbols[-1]].Price != 0:
            self.SetHoldings(top_symbols[0], -0.5)
            self.SetHoldings(top_symbols[-1], 0.5)

    def OnData(self, data):
        pass
    
class QuandlRate(PythonQuandl):
    
    def __init__(self):
        self.ValueColumnName = 'Value'