Overall Statistics
Total Trades
4
Average Win
0.16%
Average Loss
-11.83%
Compounding Annual Return
-11.660%
Drawdown
19.900%
Expectancy
-0.493
Net Profit
-11.690%
Sharpe Ratio
-0.748
Probabilistic Sharpe Ratio
1.441%
Loss Rate
50%
Win Rate
50%
Profit-Loss Ratio
0.01
Alpha
-0.055
Beta
-0.136
Annual Standard Deviation
0.103
Annual Variance
0.011
Information Ratio
-0.742
Tracking Error
0.33
Treynor Ratio
0.568
Total Fees
$140.00
Estimated Strategy Capacity
$260000000.00
Lowest Capacity Asset
GOOCV VP83T1ZUHROL
Portfolio Turnover
0.73%
from AlgorithmImports import *

class ProblemB(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2021, 1, 1)
        self.SetCash(1000000)
        self.AddEquity("GOOG", Resolution.Daily)
        self.AddEquity("AMZN", Resolution.Daily)

        self.goog_quantity = 6000
        self.amzn_quantity = -8000  
        self.goog_price = None
        self.amzn_price = None
        self.stop_loss = 100000

    def OnData(self, data: Slice):

        if self.goog_price is None:
            self.goog_price = self.Securities["GOOG"].Close
            self.LimitOrder("GOOG", self.goog_quantity, 0.95*self.goog_price)

        if self.amzn_price is None:
            self.amzn_price = self.Securities["AMZN"].Close
            self.LimitOrder("AMZN", self.amzn_quantity, 1.05*self.amzn_price)
        
        if self.Portfolio.Invested:
            if self.Portfolio.TotalPortfolioValue < 1000000 - self.stop_loss:
                self.Liquidate()

    def OnEndOfDay(self):
        self.Debug(f"Portfolio Value: {self.Portfolio.TotalPortfolioValue}")