| Overall Statistics |
|
Total Orders 9 Average Win 12.10% Average Loss -6.08% Compounding Annual Return -21.354% Drawdown 28.700% Expectancy -0.253 Start Equity 100000 End Equity 92955.3 Net Profit -7.045% Sharpe Ratio -0.33 Sortino Ratio -0.434 Probabilistic Sharpe Ratio 18.911% Loss Rate 75% Win Rate 25% Profit-Loss Ratio 1.99 Alpha 0.403 Beta -1.658 Annual Standard Deviation 0.48 Annual Variance 0.23 Information Ratio -0.916 Tracking Error 0.543 Treynor Ratio 0.096 Total Fees $22.23 Estimated Strategy Capacity $1900000000.00 Lowest Capacity Asset CL Z53JGHPB0Q0X Portfolio Turnover 6.91% Drawdown Recovery 22 |
from AlgorithmImports import *
class BuyHoldRolledWTI(QCAlgorithm):
def initialize(self):
self.set_start_date(2026, 3, 20)
self.set_end_date(2026, 7, 8)
self.set_cash(100_000)
self.settings.seed_initial_prices = True
self._future = self.add_future(
Futures.Energy.CRUDE_OIL_WTI,
resolution=Resolution.DAILY,
data_mapping_mode=DataMappingMode.OPEN_INTEREST,
)
self._future.set_filter(0, 60)
def on_data(self, data):
# Roll: on a mapping change, close the expiring contract.
for changed in data.symbol_changed_events.values():
if self.portfolio[changed.old_symbol].invested:
self.liquidate(changed.old_symbol, tag="roll")
# Hold one long front-month contract.
mapped = self._future.mapped
if mapped is not None and not self.portfolio[mapped].invested:
self.market_order(mapped, 1)