Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
124.143%
Drawdown
37.000%
Expectancy
0
Net Profit
165.749%
Sharpe Ratio
2.792
Probabilistic Sharpe Ratio
75.352%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
1.271
Beta
0.938
Annual Standard Deviation
0.608
Annual Variance
0.37
Information Ratio
2.114
Tracking Error
0.588
Treynor Ratio
1.811
Total Fees
$1.00
Estimated Strategy Capacity
$660000.00
Lowest Capacity Asset
ETSY VZR6X1TTY8H1
from clr import AddReference
AddReference("System")
AddReference("QuantConnect.Algorithm")
AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
import math 

class CalmApricotCamel(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 4, 28)
        self.SetEndDate(2021, 7, 13)
        self.SetCash(1500) 
        self.etsy = self.AddEquity("ETSY", Resolution.Minute).Symbol
        self.rsi = self.RSI("ETSY", 12, MovingAverageType.Wilders, Resolution.Minute)
        self.SetWarmUp(12)
        self.SetBenchmark("SPY")
        self.entryticket = None
        self.fillprice = 0
        self.price = self.Securities["ETSY"].Price
        
    def OnData(self, data):  
        
        if not self.rsi.IsReady: 
            return
        
        rsivalue = self.rsi.Current.Value
        quantity = self.CalculateOrderQuantity(self.etsy, 1)
        
        if (self.entryticket is None) and (rsivalue <= 36):
            self.entryticket = self.MarketOrder("ETSY", quantity)
            self.Debug("Market Order Fill Price: {0}".format(self.entryticket.AverageFillPrice))
            self.Debug("Order ID: {0}".format(self.entryticket.OrderId))
            self.Debug("RSI value: {0}".format(self.rsi.Current.Value))
            self.fillprice = self.entryticket.AverageFillPrice
            
    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status != OrderStatus.Filled:
            return
        
        #if self.entryticket is not None and self.entryticket.OrderId == orderEvent.OrderId:
            #self.entryticket is None
            #self.fillprice = 0
        
        if (self.entryticket is not None) and (self.fillprice != 0) and (rsivalue >= 64) and (self.price > self.fillprice):
            self.Liquidate("ETSY")
            self.entryticket is None
            self.fillprice = 0