| Overall Statistics |
|
Total Orders 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 100000 End Equity 100000 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 Lowest Capacity Asset Portfolio Turnover 0% Drawdown Recovery 0 |
from AlgorithmImports import *
class VixMiniFuturesAlgorithm(QCAlgorithm):
"""Subscribes to the first three VXM (CBOE Mini VIX) futures contracts.
VXM has no universe (chain) files on QC because AlgoSeek does not cover CFE,
so `add_future(...)` would return an empty chain. Instead we build the
contract tickers ourselves (VXM + month code + 2-digit year) and let
SymbolRepresentation.parse_future_symbol resolve each one to a canonical
Symbol with the correct expiry, then subscribe to them individually.
"""
# CME/CFE month codes, January -> December.
MONTH_CODES = "FGHJKMNQUVXZ"
def initialize(self):
self.set_start_date(2026, 7, 21)
self.set_cash(100000)
self.contracts = []
# Walk forward month by month from the current month, keeping the first
# three contracts that have not expired yet. This runs live, so
# self.time is "now".
today = self.time.date()
year, month = self.time.year, self.time.month
for _ in range(12):
if len(self.contracts) == 3:
break
ticker = f"VXM{self.MONTH_CODES[month - 1]}{year % 100:02d}"
symbol = SymbolRepresentation.parse_future_symbol(ticker)
security = self.add_future_contract(symbol, Resolution.TICK)
self.contracts.append(security.symbol)
self.set_benchmark(security.symbol)
self.log(f"Subscribed to {ticker} -> {security.symbol} "
f"(expiry {symbol.id.date:%Y-%m-%d})")
month += 1
if month > 12:
month = 1
year += 1
def on_data(self, slice: Slice):
for symbol in self.contracts:
bar = slice.bars.get(symbol)
if bar is not None:
self.log(f"{symbol.value} close {bar.close}")