| Overall Statistics |
|
Total Trades 4 Average Win 0% Average Loss -5.14% Compounding Annual Return -10.245% Drawdown 18.800% Expectancy -1 Net Profit -10.272% Sharpe Ratio -0.653 Probabilistic Sharpe Ratio 1.999% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.044 Beta -0.136 Annual Standard Deviation 0.103 Annual Variance 0.011 Information Ratio -0.712 Tracking Error 0.33 Treynor Ratio 0.495 Total Fees $140.00 Estimated Strategy Capacity $200000000.00 Lowest Capacity Asset GOOCV VP83T1ZUHROL Portfolio Turnover 0.71% |
from AlgorithmImports import *
class Example1(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2021, 1, 1)
self.SetCash(1000000)
self.ticker1 = 'GOOG'
self.AddEquity(self.ticker1, Resolution.Daily)
self.amount1 = 6000
self.ticker2 = 'AMZN'
self.AddEquity(self.ticker2, Resolution.Daily)
self.amount2 = -8000
self.count = 0
self.start = 0
def OnData(self, data):
if self.count == 0:
# if not self.Portfolio.Invested:
self.ticker1_open = self.Securities[self.ticker1].Open
self.ticker2_open = self.Securities[self.ticker2].Open
self.ticket1 = self.LimitOrder(self.ticker1, self.amount1, self.ticker1_open * 0.95)
self.ticket2 = self.LimitOrder(self.ticker2, self.amount2, self.ticker2_open * 1.05)
# self.Debug(f"{self.Time}: {self.ticket1.Status}")
if (self.ticket1.Status == 3 and self.ticket2.Status == 3):
profit1 = self.Portfolio[self.ticker1].TotalCloseProfit()
profit2 = self.Portfolio[self.ticker2].TotalCloseProfit()
total_profit = profit1 + profit2
if (total_profit < - 100000):
self.MarketOnCloseOrder(self.ticker1, - self.amount1)
self.MarketOnCloseOrder(self.ticker2, - self.amount2)
self.count = self.count + 1