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 -0.76 Tracking Error 0.062 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
#region imports from AlgorithmImports import * #endregion class CarryTrading(QCAlgorithm): def Initialize(self): self.Pair_1 = "USDDKK" self.Pair_2 = "USDPLN" self.SetStartDate (2000, 3, 3) self.SetEndDate(2022,5,24) self.SetCash(1000000) self.SetBrokerageModel(BrokerageName.OandaBrokerage) self.EURSEK = self.AddForex(self.Pair_1, Resolution.Daily, Market.Oanda) self.GBPSGD = self.AddForex(self.Pair_2, Resolution.Daily, Market.Oanda) self.symbols = [self.Pair_1, self.Pair_2] self.prevMinPriceVariation = { symbol : RollingWindow[QuoteBar](20) for symbol in self.symbols } #added bool statement: self.added_rw = False symbol_properties = self.Securities[self.Pair_1].SymbolProperties MinimumPriceVariation = symbol_properties.MinimumPriceVariation def OnData(self,data): for symbol in self.symbols: if data.ContainsKey(symbol): self.prevMinPriceVariation[symbol].Add( data[symbol] ) if not all([ window.IsReady for window in self.prevMinPriceVariation.values() ]): return Pair1_Variation = self.prevMinPriceVariation[self.Pair_1] quote_bar = Pair1_Variation[6] self.Quit(f"QuoteBar low: {quote_bar.Bid.Low}; QuoteBar high: {quote_bar.Ask.High}") return Pair1_6D = Pair1_Variation[6].MinimumPriceVariation Pair1_5D = Pair1_variation[5].MinimumPriceVariation Pair1_4D = Pair1_Variation[4].MinimumPriceVariation Pair1_3D = Pair1_Variation[3].MinimumPriceVariation Pair1_2D = Pair1_Variation[2].MinimumPriceVariation Pair1_1D = Pair1_Variation[1].MinimumPriceVariation Pair1_0D = Pair1_Variation[0].MinimumPriceVariation Pair2_Variation = self.prevMinPriceVariation[self.Pair_2] Pair2_6D = Pair1_Variation[6].MinimumPriceVariation Pair2_5D = Pair1_Variation[5].MinimumPriceVariation Pair2_4D = Pair1_Variation[4].MinimumPriceVariation Pair2_3D = Pair1_Variation[3].MinimumPriceVariation Pair2_2D = Pair1_Variation[2].MinimumPriceVariation Pair2_1D = Pair1_Variation[1].MinimumPriceVariation Pair2_0D = Pair1_Variation[0].MinimumPriceVariation self.added_rw = True AvgPair1_Variation = (Pair1_0D + Pair1_1D + Pair1_2D + Pair1_3D + Pair1_4D +Pair1_5D + Pair1_6D) / 7 AvgPair2_Variation = (Pair2_0D + Pair2_1D + Pair2_2D + Pair2_3D + Pair2_4D +Pair2_5D + Pair2_6D) / 7 if self.added_rw is True: self.Log( str+(AvgPair1_Variation))