Overall Statistics
Total Orders
2548
Average Win
1.68%
Average Loss
-0.92%
Compounding Annual Return
83.504%
Drawdown
61.400%
Expectancy
0.241
Start Equity
10000
End Equity
68923.33
Net Profit
589.233%
Sharpe Ratio
1.203
Sortino Ratio
2.188
Probabilistic Sharpe Ratio
39.468%
Loss Rate
56%
Win Rate
44%
Profit-Loss Ratio
1.84
Alpha
0.812
Beta
0.076
Annual Standard Deviation
0.679
Annual Variance
0.461
Information Ratio
1.087
Tracking Error
0.692
Treynor Ratio
10.752
Total Fees
$10809.01
Estimated Strategy Capacity
$820000.00
Lowest Capacity Asset
GME SC72NCBXXAHX
Portfolio Turnover
75.81%
# 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['GME'].fast.Current.Value < self.averages['GME'].slow.Current.Value and self.previous_increase == True:
                self.set_holdings('GME', .475)
                self.set_holdings('AMC', -.475)
                self.previous_increase = False
            elif self.averages['GME'].fast.Current.Value > self.averages['GME'].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)