Overall Statistics
Total Orders
2396
Average Win
1.91%
Average Loss
-0.63%
Compounding Annual Return
144.858%
Drawdown
41.800%
Expectancy
0.453
Start Equity
10000
End Equity
172468.55
Net Profit
1624.686%
Sharpe Ratio
1.841
Sortino Ratio
4.38
Probabilistic Sharpe Ratio
77.692%
Loss Rate
64%
Win Rate
36%
Profit-Loss Ratio
3.05
Alpha
1.151
Beta
0.039
Annual Standard Deviation
0.627
Annual Variance
0.393
Information Ratio
1.696
Tracking Error
0.642
Treynor Ratio
29.396
Total Fees
$21353.67
Estimated Strategy Capacity
$680000.00
Lowest Capacity Asset
GME SC72NCBXXAHX
Portfolio Turnover
66.50%
# region imports
from AlgorithmImports import *
# endregion

class LogicalOrangeGorilla(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2021, 1, 1)
        self.set_end_date(2024, 5, 27)
        self.set_cash(10000)
        self.gme = self.add_equity("GME", Resolution.MINUTE)
        self.amc = self.add_equity("AMC", Resolution.MINUTE)
        self.averages = {}
        self.previous_increase = False

    def on_data(self, data: Slice):
        for symbol in ['GME', 'AMC']:
            if symbol not in self.averages:
                self.averages[symbol] = SelectionData() 

            self.averages[symbol].update(self.time, self.securities[symbol].close)

        if self.averages['GME'].is_ready:

            if self.averages['AMC'].fast.Current.Value < self.averages['AMC'].slow.Current.Value and self.previous_increase == True:
                self.set_holdings('GME', .45)
                self.set_holdings('AMC', -.45)
                self.previous_increase = False
            elif self.averages['AMC'].fast.Current.Value > self.averages['AMC'].slow.Current.Value and self.previous_increase == False:
                self.liquidate('AMC')
                self.previous_increase = True


class SelectionData(object):
    def __init__(self):
        self.slow = ExponentialMovingAverage(200)
        self.fast = ExponentialMovingAverage(50)
    
    def is_ready(self):
        return self.slow.is_ready and self.fast.is_ready
    
    def update(self, time, price):
        self.fast.update(time, price)
        self.slow.update(time, price)