| Overall Statistics |
|
Total Orders 2 Average Win 0% Average Loss 0% Compounding Annual Return -6.654% Drawdown 24.000% Expectancy 0 Start Equity 1000000 End Equity 933344.96 Net Profit -6.666% Sharpe Ratio -0.627 Sortino Ratio -0.651 Probabilistic Sharpe Ratio 6.390% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.033 Beta -0.449 Annual Standard Deviation 0.145 Annual Variance 0.021 Information Ratio -1.128 Tracking Error 0.195 Treynor Ratio 0.202 Total Fees $40.34 Estimated Strategy Capacity $160000000.00 Lowest Capacity Asset GOOCV VP83T1ZUHROL Portfolio Turnover 0.27% |
from AlgorithmImports import *
class MaxPositionSizing(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2023, 6, 1)
self.SetEndDate(2024, 6, 1)
self.SetCash(1000000)
self.goog = self.AddEquity("GOOG", Resolution.Daily).Symbol
self.amzn = self.AddEquity("AMZN", Resolution.Daily).Symbol
def OnData(self, data):
if not self.Portfolio.Invested:
cash = self.Portfolio.Cash
goog_price = data[self.goog].Close
amzn_price = data[self.amzn].Close
max_shares_goog = int((cash * 3) / (7 * goog_price))
max_shares_amzn = int((cash * 4) / (7 * amzn_price))
position_factor = min(max_shares_goog / 3, max_shares_amzn / 4)
self.MarketOrder(self.goog, int(position_factor * 3))
self.MarketOrder(self.amzn, -int(position_factor * 4))