Overall Statistics
Total Orders
2047
Average Win
2.70%
Average Loss
-0.96%
Compounding Annual Return
133.897%
Drawdown
38.000%
Expectancy
0.328
Start Equity
10000
End Equity
149096.06
Net Profit
1390.961%
Sharpe Ratio
1.977
Sortino Ratio
3.942
Probabilistic Sharpe Ratio
87.509%
Loss Rate
65%
Win Rate
35%
Profit-Loss Ratio
2.83
Alpha
0.994
Beta
-0.253
Annual Standard Deviation
0.494
Annual Variance
0.244
Information Ratio
1.738
Tracking Error
0.525
Treynor Ratio
-3.863
Total Fees
$23579.65
Estimated Strategy Capacity
$980000.00
Lowest Capacity Asset
AMC VMGNNM1SRKH1
Portfolio Turnover
87.92%
# 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
        self.everyother = 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:
                if self.everyother == False:
                    self.set_holdings('GME', .3)
                self.set_holdings('AMC', -.6)
                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
            
            self.everyother = not self.everyother


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)