| Overall Statistics |
|
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return 193.784% Drawdown 50.500% Expectancy 0 Net Profit 75.649% Sharpe Ratio 2.868 Probabilistic Sharpe Ratio 64.046% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 2.739 Beta -0.533 Annual Standard Deviation 0.901 Annual Variance 0.811 Information Ratio 2.497 Tracking Error 0.918 Treynor Ratio -4.843 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset CLXPF.CLXPF 2S |
import decimal
class ImportStock(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 12, 31)
# 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