Overall Statistics
Total Trades
260
Average Win
0.32%
Average Loss
-0.50%
Compounding Annual Return
-35.973%
Drawdown
20.800%
Expectancy
-0.361
Net Profit
-20.774%
Sharpe Ratio
-4.307
Probabilistic Sharpe Ratio
0.000%
Loss Rate
61%
Win Rate
39%
Profit-Loss Ratio
0.65
Alpha
-0.361
Beta
0.054
Annual Standard Deviation
0.083
Annual Variance
0.007
Information Ratio
-1.011
Tracking Error
0.429
Treynor Ratio
-6.552
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

 #Hi Serkan!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:) :) :) :)
class main(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)  # Set Start Date
        self.SetCash(100)  # Set Strategy Cash
        
        self.symbol = "AA"
        self.AA=self.AddEquity(self.symbol,Resolution.Minute)
        
        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):
        if self.Portfolio.Invested:
           self.SetHoldings(self.symbol , 0,False,"Selling the stock at market closing time")
    
    def EveryDayAfterMarketOpen(self):
        
        if not self.Portfolio.Invested: 
           #self.SetHoldings(self.symbol , 1,False,"Buying the stock at market open")
           open = self.Securities[self.symbol].Open
           stopPrice = open * .99 # Trigger stop limit when price falls 1%.
           limitPrice = open * 1.01 # Sell equal or better than 1% > close.
           stopLimitTicket = self.StopLimitOrder(self.symbol, 1, stopPrice, limitPrice)