examples/futures, examples/options, examples/bonds and examples/cross_asset.
Futures
Listings vs contracts
A listing is what you order and price. A contract (FuturesContract) carries the specification — multiplier, expiration — and is reached through listing.asset.
Rolling
front_contract is the pick and the roll at once: once the contract you hold fails the roll_before_days test, it returns the next delivery, and you roll by ordering what it now returns.
await data.current_contract(cf) instead.
Sizing
Futures sizing is a notional calculation:price × multiplier × quantity.
PerContract plus exchange fees by root.
Options
Requiresziplime[options] for pricing and Greeks.
Selecting from a chain:
nearest_delta takes the delta as a magnitude (0.20 for the 20-delta put) and computes a Black-Scholes delta at the volatility you pass. Near a 0DTE close almost every contract has a delta of 0 or 1, so select by strike_offset there instead.
OptionChain also has calls, puts, strikes, at_strike, nearest_strike and strike_offset.
- A 0DTE strategy calls
option_chainevery session: contracts are listed fresh each day. option_greeksreads the contract’simplied_volatilityfield when the data has one and raises when it doesn’t, rather than inventing a volatility. Passvolatility=explicitly otherwise.- Options settle at intrinsic value. Commission is
PerOptionContractby default.
Bonds
Coupons are paid into cash, amortisation reduces principal, and bonds are redeemed at par. Commission is
PerBondTurnover by default.