| Overall Statistics |
|
Total Trades 3701 Average Win 0.75% Average Loss -1.77% Compounding Annual Return -46.110% Drawdown 91.600% Expectancy -0.083 Net Profit -90.120% Sharpe Ratio -0.826 Probabilistic Sharpe Ratio 0.000% Loss Rate 35% Win Rate 65% Profit-Loss Ratio 0.42 Alpha -0.391 Beta 1.023 Annual Standard Deviation 0.365 Annual Variance 0.133 Information Ratio -1.113 Tracking Error 0.349 Treynor Ratio -0.295 Total Fees $4408.00 Estimated Strategy Capacity $3800000.00 Lowest Capacity Asset TSLA UNU3P8Y3WFAD |
# region imports
from AlgorithmImports import *
# endregion
class MyAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2015, 1, 1)
self.SetEndDate(2022, 1, 1)
# Set the cash we'd like to use for our strategy
self.SetCash(10000)
self.trade_quantity=100
# Set the equity we'd like to trade
self.symbol = self.AddEquity("TSLA").Symbol
# Set the period for the RSI indicator
self.rsi_period = 14
# Create the RSI indicator
self.rsi = self.RSI(self.symbol, self.rsi_period)
def OnData(self, data):
# Check if we have enough data to calculate the RSI indicator
if not self.rsi.IsReady:
return
# Check if the RSI is above 70 (overbought)
if self.rsi.Current.Value > 72:
# If the RSI is overbought, place a sell order
self.Liquidate()
# Check if the RSI is below 30 (oversold)
elif self.rsi.Current.Value < 28:
# If the RSI is oversold, place a buy order
self.MarketOrder(self.symbol, self.trade_quantity)