| Overall Statistics |
|
Total Trades 214 Average Win 0.95% Average Loss -0.97% Compounding Annual Return -12.943% Drawdown 25.300% Expectancy -0.196 Net Profit -11.979% Sharpe Ratio -0.43 Probabilistic Sharpe Ratio 4.755% Loss Rate 59% Win Rate 41% Profit-Loss Ratio 0.98 Alpha -0.076 Beta -0.009 Annual Standard Deviation 0.179 Annual Variance 0.032 Information Ratio -0.674 Tracking Error 0.333 Treynor Ratio 8.302 Total Fees $9982.65 Estimated Strategy Capacity $140000000.00 Lowest Capacity Asset ROKU WO9FGTL2I89X |
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020,1,1)
self.SetEndDate(2021,1,1)
self.SetCash(1000000)
# add securities
self.AddEquity("GOOG", Resolution.Daily)
self.GOOG = self.Symbol("GOOG")
self.AddEquity("AMZN", Resolution.Daily)
self.AMZN = self.Symbol("AMZN")
self.count = 0
def OnData(self, data: Slice):
if self.count == 0:
self.MarketOrder("GOOG", 6000)
self.MarketOrder("AMZN",-8000)
value = self.Portfolio.TotalPortfolioValue
self.Log('Portfolio Value : ' + str(value))
self.count += 1
if value < 900000:
order_ids = self.Liquidate()
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020,1,1)
self.SetEndDate(2021,1,1)
self.SetCash(1000000)
# add securities
self.AddEquity("GOOG", Resolution.Daily)
self.AddEquity("AMZN", Resolution.Daily)
def OnData(self, data: Slice):
# get starting date prices
if self.Time.day == 1 and self.Time.month == 1 and self.Time.year == 2020:
self.AMZN_start = self.Securities["AMZN"].Price
self.GOOG_start = self.Securities["GOOG"].Price
self.LimitOrder("AMZN", -8000, 1.05 * self.AMZN_start)
self.LimitOrder("GOOG", 6000, 0.95 * self.GOOG_start)
value = self.Portfolio.TotalPortfolioValue
if value < 900000:
order_ids = self.Liquidate()
value = self.Portfolio.TotalPortfolioValue
if value < 900000:
order_ids = self.Liquidate()# region imports
from AlgorithmImports import *
# endregion
class MeasuredTanJackal(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020,1,1)
self.SetEndDate(2021,1,1)
self.SetCash(1000000)
# add securities
self.AddEquity("GOOG", Resolution.Daily)
self.AddEquity("AMZN", Resolution.Daily)
self.amzn_orders = -5628
self.goog_orders = round(self.amzn_orders * 3/4,0)
def OnData(self, data: Slice):
self.Debug(f"AMZN : {self.amzn_orders} \n GOOG : {self.goog_orders}")
if self.Time.day == 1 and self.Time.year == 2020 and self.Time.month == 1:
self.MarketOrder("AMZN", self.amzn_orders)
self.MarketOrder("GOOG", -self.goog_orders)# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
"""
1. (5 pts) Compute the Sharpe Ratio of a buy-and-hold strategy for each of the above stocks
individually for the given time period, that is, you need to compute four
Sharpe Ratios separately, one for each stock.
"""
def Initialize(self):
self.SetStartDate(2019,2,1)
self.SetEndDate(2021,2,1)
self.SetCash(1000000)
#self.AddEquity('GS', Resolution.Daily)
#self.AddEquity('MS', Resolution.Daily)
#self.AddEquity('AMD', Resolution.Daily)
self.AddEquity('XOM', Resolution.Daily)
def OnData(self, data: Slice):
#self.SetHoldings('GS', 1)
#self.SetHoldings('MS', 1)
#self.SetHoldings('AMD', 1)
self.SetHoldings('XOM', 1)
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,2,1)
self.SetEndDate(2021,2,1)
self.SetCash(1000000)
# just commenting and uncommenting the below to find the statistic for
# the relevant ticker
#self.AddEquity('GS', Resolution.Daily)
self.AddEquity('MS', Resolution.Daily)
#self.AddEquity('AMD', Resolution.Daily)
#self.AddEquity('XOM', Resolution.Daily)
self.count = 0
def OnData(self, data: Slice):
if self.count == 0:
#self.SetHoldings('GS', 1)
self.SetHoldings('MS', 1)
#self.SetHoldings('AMD', 1)
#self.SetHoldings('XOM', 1)
value = self.Portfolio.TotalUnrealizedProfit
stop_loss = 0.07 * 1000000
self.count += 1
# with 1MM starting value, equates to losing or gaining $70,000
if (value <= -stop_loss) or (value >= stop_loss):
order = self.Liquidate()# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,2,1)
self.SetEndDate(2021,2,1)
self.SetCash(1000000)
# just commenting and uncommenting the below to find the statistic for
# the relevant ticker
self.AddEquity('GS', Resolution.Daily)
self.AddEquity('MS', Resolution.Daily)
#self.AddEquity('AMD', Resolution.Daily)
#self.AddEquity('XOM', Resolution.Daily)
self.count = 0
def OnData(self, data: Slice):
if self.count == 0:
self.SetHoldings('GS', 0.5)
self.SetHoldings('MS', -0.5)
#self.SetHoldings('AMD', 1)
#self.SetHoldings('XOM', 1)
self.count += 1
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,2,1)
self.SetEndDate(2021,2,1)
self.SetCash(1000000)
# just commenting and uncommenting the below to find the statistic for
# the relevant ticker
self.AddEquity('GS', Resolution.Daily)
self.AddEquity('MS', Resolution.Daily)
self.AddEquity('AMD', Resolution.Daily)
self.AddEquity('XOM', Resolution.Daily)
self.count = 0
def OnData(self, data: Slice):
if self.count == 0:
self.SetHoldings('GS', 0.25)
self.SetHoldings('MS', -0.25)
self.SetHoldings('AMD', 0.25)
self.SetHoldings('XOM', -.25)
self.count += 1
#region imports
from AlgorithmImports import *
#endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,8,20)
self.SetEndDate(2020,7,20)
self.SetCash(2000000)
self.ticker ='ROKU'
self.sym = self.AddEquity(self.ticker, Resolution.Daily) #S1
self.sma = self.SMA(self.ticker, 20, Resolution.Daily)
self.port = False
if self.port:
self.wt = 0.25 # if we have two stocks, each wt will be 25%
else:
self.wt = 0.5 # single stock wt 50%
def OnData(self, data: Slice):
ind = self.sma.Current.Value
if not self.Portfolio[self.ticker].Invested:
if self.sym.Price > ind:
self.SetHoldings(self.sym.Symbol, self.wt)
elif self.sym.Price < ind:
self.SetHoldings(self.sym.Symbol, -self.wt)
elif (self.Portfolio[self.ticker].IsLong and self.sym.Price< ind) or (self.Portfolio[self.ticker].IsShort and self.sym.Price> ind):
self.SetHoldings(self.sym.Symbol, 0.0)
#region imports
from AlgorithmImports import *
#endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,8,20)
self.SetEndDate(2020,7,20)
self.SetCash(2000000)
self.ticker1 ='AMD'
self.sym1 = self.AddEquity(self.ticker1, Resolution.Daily) #S1
self.sma = self.SMA(self.ticker1, 20, Resolution.Daily)
self.port = False
if self.port:
self.wt = 0.25 # if we have two stocks, each wt will be 25%
else:
self.wt = 0.5 # single stock wt 50%
def OnData(self, data: Slice):
ind1 = self.sma.Current.Value
if not self.Portfolio[self.ticker1].Invested:
if self.sym1.Price > ind1:
self.SetHoldings(self.sym1.Symbol, -self.wt)
elif self.sym1.Price < ind1:
self.SetHoldings(self.sym1.Symbol, self.wt)
elif self.Portfolio[self.ticker1].IsLong and self.sym1.Price< ind1 or self.Portfolio[self.ticker1].IsShort and self.sym1.Price> ind1:
self.SetHoldings(self.sym1.Symbol, 0.0)
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,8,20)
self.SetEndDate(2020,7,20)
self.SetCash(2000000)
self.ticker1 ='ROKU'
self.sym1 = self.AddEquity(self.ticker1, Resolution.Daily) #S1
self.sma1 = self.SMA(self.ticker1, 20, Resolution.Daily)
self.ticker2 = 'AMD'
self.sym2 = self.AddEquity(self.ticker2, Resolution.Daily) #S2
self.sma2 = self.SMA(self.ticker2, 20, Resolution.Daily)
self.port = True
if self.port:
self.wt = 0.25 # if we have two stocks, each wt will be 25%
else:
self.wt = 0.5 # single stock wt 50%
def OnData(self, data: Slice):
ind1 = self.sma1.Current.Value
ind2 = self.sma2.Current.Value
self.Debug("Price1 " + str(self.sym1.Price) + "indicator " +str(ind1))
self.Debug("Price2 " + str(self.sym2.Price) + "indicator " +str(ind2))
if not self.Portfolio[self.ticker1].Invested:
if self.sym1.Price > ind1:
self.SetHoldings(self.sym1.Symbol, self.wt)
elif self.sym1.Price < ind1:
self.SetHoldings(self.sym1.Symbol, -self.wt)
elif self.Portfolio[self.ticker1].IsLong and self.sym1.Price< ind1 or \
self.Portfolio[self.ticker1].IsShort and self.sym1.Price> ind1:
self.SetHoldings(self.sym1.Symbol, 0.0)
#Trend-reversal Strategy for self.ticker1
if self.port:
if not self.Portfolio[self.ticker2].Invested:
if self.sym2.Price > ind2:
self.SetHoldings(self.sym2.Symbol, -self.wt)
elif self.sym2.Price <ind2:
self.SetHoldings(self.sym2.Symbol, self.wt)
elif self.Portfolio[self.ticker2].IsLong and self.sym2.Price< ind2 or \
self.Portfolio[self.ticker2].IsShort and self.sym2.Price> ind2:
self.SetHoldings(self.sym2.Symbol, 0.0)
# region imports
from AlgorithmImports import *
# endregion
class EnergeticYellowGreenGiraffe(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2019,8,20)
self.SetEndDate(2020,7,20)
self.SetCash(2000000)
self.ticker1 ='ROKU'
self.sym1 = self.AddEquity(self.ticker1, Resolution.Daily) #S1
self.sma1 = self.SMA(self.ticker1, 20, Resolution.Daily)
self.ticker2 = 'AMD'
self.sym2 = self.AddEquity(self.ticker2, Resolution.Daily) #S2
self.sma2 = self.SMA(self.ticker2, 20, Resolution.Daily)
self.port = True
if self.port:
self.wt = 0.25 # if we have two stocks, each wt will be 25%
else:
self.wt = 0.5 # single stock wt 50%
def OnData(self, data: Slice):
ind1 = self.sma1.Current.Value
ind2 = self.sma2.Current.Value
self.Debug("Price1 " + str(self.sym1.Price) + "indicator " +str(ind1))
self.Debug("Price2 " + str(self.sym2.Price) + "indicator " +str(ind2))
if not self.Portfolio[self.ticker1].Invested:
if self.sym1.Price > ind1:
self.SetHoldings(self.sym1.Symbol, self.wt)
elif self.sym1.Price < ind1:
self.SetHoldings(self.sym1.Symbol, -self.wt)
elif self.Portfolio[self.ticker1].IsLong and self.sym1.Price< ind1 or \
self.Portfolio[self.ticker1].IsShort and self.sym1.Price> ind1:
self.SetHoldings(self.sym1.Symbol, 0.0)
#Trend-reversal Strategy for self.ticker1
if self.port:
if not self.Portfolio[self.ticker2].Invested:
if self.sym2.Price > ind2:
self.SetHoldings(self.sym2.Symbol, -self.wt)
elif self.sym2.Price <ind2:
self.SetHoldings(self.sym2.Symbol, self.wt)
elif self.Portfolio[self.ticker2].IsLong and self.sym2.Price< ind2 or \
self.Portfolio[self.ticker2].IsShort and self.sym2.Price> ind2:
self.SetHoldings(self.sym2.Symbol, 0.0)