Overall Statistics
Total Trades
97
Average Win
0%
Average Loss
0%
Compounding Annual Return
117.634%
Drawdown
49.700%
Expectancy
0
Net Profit
54240.308%
Sharpe Ratio
1.361
Probabilistic Sharpe Ratio
92.094%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.796
Beta
-0.079
Annual Standard Deviation
0.578
Annual Variance
0.334
Information Ratio
1.13
Tracking Error
0.591
Treynor Ratio
-9.951
Total Fees
$97.00
from math import trunc
class DynamicParticleComputer(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2012, 1, 1)  # Set Start Date
        self.SetCash(1000)  # Set Strategy Cash
        self.AddEquity("TSLA", Resolution.Daily)
        self.time_to_add = self.Time.month

    def OnData(self, data):
        if not self.Portfolio.Invested:
            shares = 1000 / data['TSLA'].Close
            self.MarketOrder("TSLA", trunc(shares))
        
        if data.Bars.ContainsKey("TSLA"):
            self.Log(f'Portfolio Cash: {self.Portfolio.Cash}')
            if self.time_to_add != self.Time.month:
                self.Log('Adding $1,000 to portfolio')
                # Add cash
                self.Portfolio.SetCash(self.Portfolio.Cash + 1000)
                # Place order
                shares = 1000 / data['TSLA'].Close
                self.MarketOrder("TSLA", trunc(shares))
                self.time_to_add = self.Time.month