Overall Statistics
Total Trades
342
Average Win
0.10%
Average Loss
-0.11%
Compounding Annual Return
-4.399%
Drawdown
2.900%
Expectancy
-0.123
Net Profit
-2.370%
Sharpe Ratio
-1.836
Probabilistic Sharpe Ratio
2.293%
Loss Rate
54%
Win Rate
46%
Profit-Loss Ratio
0.92
Alpha
-0.044
Beta
0.001
Annual Standard Deviation
0.024
Annual Variance
0.001
Information Ratio
-0.276
Tracking Error
0.443
Treynor Ratio
-43.562
Total Fees
$0.00
from Execution.ImmediateExecutionModel import ImmediateExecutionModel
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data import *
from datetime import timedelta

 
class main(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)  # Set Start Date
        self.SetCash(10000)  # Set Strategy Cash
        self.Ticket1 = None
        self.Ticket2 = None
        
        self.symbol = "AA"
        self.quantityAA=50
        
        self.AA=self.AddEquity(self.symbol,Resolution.Minute)
        self.AA.SetDataNormalizationMode(DataNormalizationMode.Raw)
        self.SetExecution(ImmediateExecutionModel())
        
      ################################################################################################################################  
        self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.AfterMarketOpen(self.symbol , 2), self.EveryDayAfterMarketOpen)#two minutes after market open
        
     
      ##################################################################################################################################   
        self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.BeforeMarketClose(self.symbol , 2), self.EveryDayBeforeMarketClose)

       

        self.Securities[self.symbol].FeeModel = ConstantFeeModel(0)

        self.Securities[self.symbol].SlippageModel = ConstantSlippageModel(0)

    def EveryDayBeforeMarketClose(self):
        self.Liquidate(self.symbol)
    
    def EveryDayAfterMarketOpen(self):
        
        if not self.Portfolio.Invested: 
            self.MarketOrder(self.symbol, self.quantityAA)
            open = self.Securities[self.symbol].Open
            stopPrice = open * .98 # Trigger stop limit when price falls 1%.
            limitPrice = open * 1.02 # Sell equal or better than 1% > close.
            
            self.Ticket1=self.StopMarketOrder(self.symbol, -self.quantityAA, stopPrice,"STOP LOSS")
            self.Ticket2=self.LimitOrder(self.symbol, -self.quantityAA, limitPrice,"TAKE PROFIT")