| 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 -2.716 Tracking Error 0.135 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset |
class ImportStock(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 1, 1)
# self.SetEndDate(2020, 1, 1)
self.SetCash(1000000)
self.SetWarmup(200)
self.SetBenchmark("SPY")
self.stock = self.AddData(CLXPF, "CLXPF", Resolution.Minute).Symbol
self.SetSecurityInitializer(lambda x: x.SetMarketPrice(self.GetLastKnownPrice(x)))
# schedule trade execution 30 minutes after the first trading day of each month
self.Schedule.On(self.DateRules.MonthStart(self.stock), \
self.TimeRules.AfterMarketOpen(self.stock, 30), \
self.Rebalance)
def OnData(self, data):
if self.IsWarmingUp:
return
def Rebalance(self):
self.Log("Rebalance fired at : {0}".format(self.Time))
self.SetHoldings(self.stock, (1))
class CLXPF(PythonData):
# get data
def GetSource(self, config, date, isLive):
source = "https://www.dropbox.com/s/1u82fjrctjual8y/CLXPF_price_volume_daily.csv?dl=1"
return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile)
#input data into reader method line-by-line
def Reader(self, config, line, date, isLive):
# If line is empty or first character is not digit, pass
if not (line.strip() and line[0].isdigit()):
return None
#split line at commas
data = line.split(',')
clxpf = CLXPF()
clxpf.Symbol = config.Symbol
clxpf.Time = datetime.strptime(data[0], '%m%d%Y') + timedelta(hours=20) # Make sure we only get this data AFTER trading day - don't want forward bias.
clxpf.Value = decimal.Decimal(data[5])
clxpf["Volume"] = float(data[6])
return clxpf