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.725 Tracking Error 0.315 Treynor Ratio 0 Total Fees $0.00 |
import numpy as np from datetime import timedelta from datetime import datetime import pandas as pd from System import * from QuantConnect import * from QuantConnect.Algorithm import * from QuantConnect.Indicators import * from QuantConnect.Data.Market import TradeBar from System.Drawing import Color class CrawlingFluorescentPinkBison(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetCash(100000) # Set Strategy Cash self.symbol = "FSLR" self.AddEquity(self.symbol, Resolution.Minute) SmaFastPeriod = 50 SmaSlowPeriod = 200 # slow indicators self.sma50 = self.SMA(self.symbol, SmaFastPeriod, Resolution.Daily) self.sma200 = self.SMA(self.symbol, SmaSlowPeriod, Resolution.Daily) self.ichimoku = self.ICHIMOKU(self.symbol,9, 26, 26, 52, 26, 26, Resolution.Daily) self.adx = self.ADX(self.symbol, 14, Resolution.Daily) # Consolidate 1min SPY -> 45min Bars self.Consolidate(self.symbol, timedelta(minutes=5), self.Minute5BarHandler) # Consolidate 1min SPY -> 1-Hour Bars self.Consolidate(self.symbol, Resolution.Hour, self.HourBarHandler) # Consolidate 1min SPY -> 1-Week Bars self.Consolidate(self.symbol, Resolution.Daily, self.DayBarHandler) self.SetWarmUp(timedelta(days= SmaSlowPeriod)) ichimokuPlot = Chart('ichimokuPlot') ichimokuPlot.AddSeries(Series('Tenkan', SeriesType.Line, "", Color.Turquoise)) ichimokuPlot.AddSeries(Series('Kijun', SeriesType.Line, "", Color.Purple)) ichimokuPlot.AddSeries(Series('SenkouA', SeriesType.Line, "", Color.Orange)) ichimokuPlot.AddSeries(Series('SenkouB', SeriesType.Line, "", Color.Brown)) #ichimokuPlot.AddSeries(Series('Chikou', SeriesType.Line, "", Color.Pink)) ichimokuPlot.AddSeries(Series('5minPrice', SeriesType.Line, "", Color.Gray)) #ichimokuPlot.AddSeries(Series('Price', SeriesType.Line, "", Color.Gray)) ichimokuPlot.AddSeries(Series('Sma50', SeriesType.Line, "", Color.Blue)) ichimokuPlot.AddSeries(Series('Sma200', SeriesType.Line, "", Color.Red)) ichimokuPlot.AddSeries(Series('Buy', SeriesType.Scatter, '$', Color.Green, ScatterMarkerSymbol.Triangle)) ichimokuPlot.AddSeries(Series('Sell', SeriesType.Scatter, '$', Color.Red, ScatterMarkerSymbol.TriangleDown)) self.AddChart(ichimokuPlot) #SMA long plot #SmaDayPlot = Chart('SmaDayPlot') #SmaDayPlot.AddSeries(Series('Sma50', SeriesType.Line, "", Color.Blue)) #SmaDayPlot.AddSeries(Series('Sma200', SeriesType.Line, "", Color.Red)) #self.AddChart(SmaDayPlot) def Minute5BarHandler(self, consolidated): if self.IsWarmingUp: return self.Log(f"{consolidated.EndTime} >> Minute5BarHandler >> {consolidated.Close}") self.Plot("ichimokuPlot", "5minPrice", consolidated.Close) def HourBarHandler(self, consolidated): if self.IsWarmingUp: return self.Log(f"{consolidated.EndTime} >> HourBarHandler >> {consolidated.Close}") #self.Plot("TradePlot", "HourPrice", consolidated.Close) def DayBarHandler(self, consolidated): if self.IsWarmingUp: return self.Log(f"{consolidated.EndTime} >> DayBarHandler >> {consolidated.Close}") #self.Plot("SmaDayPlot", "Sma50", self.sma50.Current.Value) #self.Plot("SmaDayPlot", "Sma200", self.sma200.Current.Value) # ichimoku plot # plot self.Plot("ichimokuPlot", "Tenkan", self.ichimoku.Tenkan.Current.Value) self.Plot("ichimokuPlot", "Kijun", self.ichimoku.Kijun.Current.Value) self.Plot("ichimokuPlot", "Price", consolidated.Close) #self.Plot("ichimokuPlot", "Chikou", self.ichimoku.Chikou.Current.Value) self.Plot("ichimokuPlot", "SenkouA", self.ichimoku.SenkouA.Current.Value) self.Plot("ichimokuPlot", "SenkouB", self.ichimoku.SenkouB.Current.Value) self.Plot("ichimokuPlot", "Sma50", self.sma50.Current.Value) self.Plot("ichimokuPlot", "Sma200", self.sma200.Current.Value) #adxplot # self.Plot("adxPlot", "adx", self.adx.Current.Value) # self.Plot("adxPlot", "adxMinus", self.adx.NegativeDirectionalIndex.Current.Value) # self.Plot("adxPlot", "adxPlus", self.adx.PositiveDirectionalIndex.Current.Value) def OnData(self, data): if self.IsWarmingUp: return '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' # if not self.Portfolio.Invested: # self.SetHoldings(self.symbol, 1)