| Overall Statistics |
|
Total Orders 6261 Average Win 0.26% Average Loss -0.18% Compounding Annual Return -10.271% Drawdown 38.200% Expectancy -0.053 Start Equity 100000 End Equity 72229.45 Net Profit -27.771% Sharpe Ratio -1.105 Sortino Ratio -1.321 Probabilistic Sharpe Ratio 0.019% Loss Rate 61% Win Rate 39% Profit-Loss Ratio 1.42 Alpha -0.123 Beta 0.474 Annual Standard Deviation 0.099 Annual Variance 0.01 Information Ratio -1.331 Tracking Error 0.104 Treynor Ratio -0.231 Total Fees $6533.42 Estimated Strategy Capacity $11000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X Portfolio Turnover 568.06% Drawdown Recovery 24 |
# region imports
from AlgorithmImports import *
# endregion
class AroonOscillatorAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2022, 1, 1)
self.set_end_date(2024, 12, 31)
self.set_cash(100000)
# automatic_indicator_warm_up only supports automatic indicators, not manual indicators.
self.settings.automatic_indicator_warm_up = True
self._spy = self.add_equity("SPY", Resolution.MINUTE).symbol
self._aroon = self.aroon(self._spy, 25, Resolution.MINUTE)
# Alternatively, use a manual indicator.
# self._aroon = AroonOscillator(25, 25)
# self.warm_up_indicator(self._spy, self._aroon)
# self.register_indicator(self._spy, self._aroon)
self.plot_indicator("Aroon Oscillator", self._aroon)
def on_data(self, data: Slice) -> None:
if not self._aroon.is_ready:
return
current = self._aroon.current.value
previous = self._aroon.previous.value
if self.portfolio[self._spy].is_long:
if previous >= -50 and current < -50:
self.liquidate(self._spy)
elif previous <= 50 and current > 50:
self.set_holdings(self._spy, 1.0)