futures
Skill268 starsChanged 48 days agoApache-2.0View on GitHub
Use whenever a strategy trades futures — position sizing (notional/contracts), continuous-contract history and its `IEnumerable<TradeBar>`, and warm-up. Load it for any futures sizing, history, or warm-up step.
In this repository39 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- docs-styleSkill
- calendarSkill
- code-qualitySkill
- cryptoSkill
- data-exportSkill
- data-issuesSkill
- debug-algorithmSkill
- debug-performanceSkill
- equity-fundamental-dataSkill
- equity-optionsSkill
- historical-data-equity-optionsSkill
- historySkill
- indicatorsSkill
- loggingSkill
- option-strategiesSkill
- ordersSkill
- pricingSkill
- scheduled-eventsSkill
- universesSkill
- calendarSkill
- code-qualitySkill
- cryptoSkill
- data-exportSkill
- data-issuesSkill
- debug-algorithmSkill
- debug-performanceSkill
- equity-fundamental-dataSkill
- equity-optionsSkill
- futuresSkill
- historical-data-equity-optionsSkill
- historySkill
- indicatorsSkill
- loggingSkill
- option-strategiesSkill
- ordersSkill
- pricingSkill
- scheduled-eventsSkill
- universesSkill
The file
Files
Futures: sizing, history, warm-up
Position sizing (notional, not SetHoldings)
To take a target notional (portfolio-fraction) exposure in a future, do NOT use SetHoldings: for a future it sizes off (already-leveraged) buying power, so a target near 1.0 takes on many times 1x notional — margin calls and blow-ups — and |target| > 1 is rejected outright. Also, the continuous/canonical future symbol (e.g. /ES) is a DATA symbol and is NOT tradable — MarketOrder or portfolio reads on it silently do nothing, so symbol below must be a real contract (the front month via future.Mapped, or the specific contract the strategy selects). Size by notional with explicit contract math:
var price = Securities[symbol].Price;
var multiplier = Securities[symbol].SymbolProperties.ContractMultiplier; // read it; never hardcode (ES = 50)
var targetContracts = Math.Round(Portfolio.TotalPortfolioValue * targetWeight / (price * multiplier)); // may be 0 on a small account — correct, not a bug
var delta = targetContracts - Portfolio[symbol].Quantity; MarketOrder(symbol, delta); // trade the deltaHistory — use History<TradeBar>(); do NOT hand-build any other structure from the bars
Seeding a raw look-back buffer (e.g. an expanding regression window) is a HISTORY REQUEST, not a warm-up (warm-up pumps data through OnData and updates indicators; a history request hands you the bars to process yourself).
- Request continuous-contract history on the canonical
future.Symbol. Roll behavior is set by thedataMappingMode/dataNormalizationMode/contractDepthOffsetpassed toAddFuture(e.g.DataNormalizationMode.BackwardsRatiofor a roll-adjusted price/return series). History<TradeBar>(symbol, n, Resolution.Daily)ALREADY yields the bars directly — iterate them and read the fields you need (e.g.bar.Close); do NOT hand-build any other structure from them.- A request can return fewer bars than asked when available history is limited; check the bar count and widen the lookback if short.
Warm-up (for indicators, not raw buffers)
To ready indicators before the start date: SetWarmUp(n[, resolution]) or SetWarmUp(TimeSpan.FromDays(...)), gated with if (IsWarmingUp) return;; or WarmUpIndicator(symbol, indicator[, resolution]) / Settings.AutomaticIndicatorWarmUp / IndicatorHistory(indicator, symbol, n, resolution). After warming, check readiness and widen the lookback if short.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

