Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
HourResolutionMarketOrderStalePriceRegressionAlgorithm now asserts the order
fills at the next hour bar's close price (not the stale previous bar nor the
open), and that the fill bar is a real, freshly closed 11:00 bar rather than a
fill-forwarded repeat.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Market orders wait for fresh data instead of filling on stale prices
A market order would previously fill immediately on the most recent
available data even when that data was older than StalePriceTimeSpan
(default one hour), only attaching a warning. This is unrealistic for a
coarse resolution asset (hour/daily) where the latest bar is the stale
previous close when the order is placed mid-bar or via an intraday
scheduled event.
The default fill models (FillModel, EquityFillModel, FutureFillModel) now
wait for fresh data instead of filling on a stale price, but only for hour
and daily resolutions; the order fills when the next bar closes. For
minute/second/tick subscriptions the previous behavior is kept (fill on
the stale price with a warning), since stale data there is a genuine gap
rather than a bar still forming.
Adds HourResolutionMarketOrderStalePriceRegressionAlgorithm, updates the
FillOutsideHours daily expectation, and regenerates statistics for the
hour/daily algorithms whose fills change. FutureOptionDaily buys and
liquidates a day apart now (a same-day buy + liquidate cannot fill on
daily data once stale fills are disabled).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Normalize and correct StalePriceTimeSpan XML docs
The interface and class docs now match and reflect the actual behavior:
the wait-for-fresh-data only applies to hour/daily resolutions, while
minute/second/tick subscriptions still fill on stale data with a warning.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Fill resting market orders at the bar open instead of the close
A hour/daily market order that was resting before the current bar opened
(it predates the bar - placed after the previous close or while waiting
for fresh data) now fills at the bar open, the price when trading resumed
(like a MarketOnOpen), instead of the bar close. Orders placed during the
bar still fill at the current/close price, so intraday mid-bar fills are
unchanged. Equity fills are unchanged (resting equity orders are already
converted to MarketOnOpen by QCAlgorithm.MarketOrder).
Adds the shared FillModel.GetMarketFillPrice helper used by the base
FillModel and FutureFillModel, a unit test, and regenerates statistics for
the affected daily/hour futures, index and crypto regression algorithms
(order counts unchanged, only fill prices).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add regression algorithm asserting resting market orders fill at the bar open
RestingMarketOrderFillsAtBarOpenRegressionAlgorithm buys a daily future on the
bar that delivers it (fills at that bar's close) and submits a liquidation while
the market is closed (overnight pulse, no fresh bar). The liquidation rests and
fills on a later bar at the bar open, not its close - asserting the new
GetMarketFillPrice behavior. The in-bar buy is asserted to fill at the close, for
contrast.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Carry the bar start time on Prices instead of re-reading the cache
Add Prices.Time (the bar start, mirroring BaseData.Time/EndTime), populated from
the source bar/tick in every GetPrices path. GetMarketFillPrice now uses
prices.Time directly instead of a second asset.Cache.GetData() lookup. Behavior
is unchanged (prices.Time equals the previously read cache time).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add regression algorithm asserting in-session hour orders fill at the latest close
HourMarketOrderFillsAtBarCloseRegressionAlgorithm submits an hour resolution
market order mid-bar (via an intraday scheduled event) while the market is open,
using the default one hour StalePriceTimeSpan. It asserts the order fills
immediately at the latest available bar's close - not waiting and not at the bar
open - since the latest bar is within the stale window. Guards the resting-order
open-fill behavior against affecting ordinary in-session fills.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Regenerate custom fill model algorithm statistics for the open-fill change
CustomModelsAlgorithm and CustomPartialFillModelAlgorithm subscribe SPY at hour
resolution and their custom fill models delegate to base.MarketFill, so resting
orders now fill at the bar open. Regenerate their statistics (C#/Python) and the
inline expected statistics of the PEP8StyleCustomModelsWork test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Python Virtual Environments / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
* Convert daily resolution market orders to MarketOnClose/MarketOnOpen
A market order placed intraday (e.g. through a scheduled event) on an
asset subscribed only at daily resolution has no fresh intraday price to
fill against, so it was filling at the stale previous daily close. This
is common when mixing daily resolution assets with minute resolution
assets or intraday scheduled events.
QCAlgorithm.MarketOrder now converts these orders so they fill at a real
daily open/close instead of the stale previous close:
- market closed (any resolution): MarketOnOpen, as before
- market open, daily-only subscription: MarketOnClose (today's close),
or MarketOnOpen (next open) when already within the MarketOnClose
submission buffer near the close
Assets with intraday data are left untouched, and the conversion is only
applied in backtesting; in live trading an open-market market order fills
at the real current price.
Adds DailyResolutionMarketOrderConversionRegressionAlgorithm covering the
MarketOnClose and MarketOnOpen conversion paths plus a minute resolution
asset that is correctly left as a regular market order.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Minor fix
* Reword conversion warning: "current market price" instead of "real current price"
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Update regression stats affected by daily market order conversion
Daily-resolution market orders placed intraday are now converted to
MarketOnClose/MarketOnOpen so they fill at a real daily open/close
instead of the stale previous close. This shifts the affected fills:
- IndexOptionCall{ITM,OTM}ExpiryDaily: the SPX option entry, placed one
minute after the open, now fills at the daily close. Same economics,
one extra data point and a new order list hash.
- AllShortableSymbols (C# + Python): an intraday order's type changed
from Market to a converted order; identical End Equity, new hash.
- ResolutionSwitchingAlgorithm sampling test: the RemoveSecurity
liquidation (fired at 15:50) previously filled at the stale previous
close; it now converts, shifting the equity/performance samples.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Revert expected data point count change
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Align OnWarmupFinished time to StartDate when ScheduledUniverse skips midnight
* Align algorithm time to StartDate before OnWarmupFinished fires
* Apply warmup time alignment fix to LiveSynchronizer
* Minor fix
* Skip warmup pulse if algorithm not locked
* Fix OnWarmupFinished timing in live trading
Regression Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Fix DataManager skipping invalid data type subscriptions
* Update regression algorithms
* Use effective resolution when looking up subscription data types
* fix: support BNFCR alternative collateral in CryptoFutureMarginModel for Binance (#9339)
* refactor: use classic switch in BinanceFuturesBrokerageModel.GetBuyingPowerModel
* fix: CryptoFutureMarginModel in BinanceCoinFuturesBrokerageModel
* refactor: simplify BinanceCryptoFutureMarginModel collateral conversion
* fix: restore IsCryptoCoinFuture guard in BinanceCryptoFutureMarginModel
* refactor: simplify BinanceCryptoFutureMarginModel to direct BNFCR lookup
Replace IsStableCoinWithoutPair foreach loop with a single TryGetValue
check for BNFCR. BNFCR is EU/EEA-only (MiCA Credits Trading Mode) so
the lookup is a no-op for all other users. Amount reflects availableBalance
from the Binance API — the total cross-margin pool already aggregated by
Binance — making the > 0 guard correct and avoiding CashBook iteration.
* feat: add regression algorithm for BNFCR as sole collateral on Binance USDⓈ-M futures
Asserts end-to-end that EU/MiCA accounts with zero USDT and BNFCR as
the only collateral can open ADAUSDT positions. Verifies buying power,
holdings AbsoluteHoldingsCost, TotalSaleVolume, TotalMarginUsed,
maintenance margin consistency and TotalUnrealizedProfit accuracy.
* refactor: BNFCR presence gate with CashBook iteration for supplementary collateral
Replace IsStableCoinWithoutPair and hardcoded asset list with CashBook
iteration gated by BNFCR presence. Binance controls which assets are in
the account — all with non-zero walletBalance are valid collateral.
Add tests for BNFCR zero balance and BTC collateral conversion.
* refactor: aggregate all collateral without reference equality check
* fix: shared collateral deduction across quote currencies for EU/MiCA BNFCR mode
- Extract virtual SharesCollateral in CryptoFutureMarginModel
- Override in BinanceCryptoFutureMarginModel: BNFCR present → all USDⓈ-M share pool
- Add BNFCRCurrency const
- Add SharedCollateralDeductsMaintenanceMarginAcrossQuoteCurrencies unit test
- Refactor regression algorithm to assert shared collateral across ADAUSDT/ETHUSDC
* refactor: remove dead IsCryptoCoinFuture guard from BinanceCryptoFutureMarginModel
- Remove IsCryptoCoinFuture() check (coin futures use BinanceCoinFuturesBrokerageModel, not this model)
- Call base.GetTotalCollateralAmount() instead of duplicating primaryCollateral.Amount
- Remove CoinFutureDoesNotIncludeBnfcrAsCollateral test (tested wrong margin model)
* refactor: make GetCollateralCash private in CryptoFutureMarginModel
- No longer accessed by subclasses after removing direct collateral checks from BinanceCryptoFutureMarginModel
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add ContractMultiplier setter to Cfd via CfdSymbolProperties
* Fix regression tests
* Solve review comments
* Address new review comments
* Fix regression tests
* Use ContractSymbolProperties as base class
* Minor fix
* Address review comment
* Use universe settings when adding derivatives
Use resolution, fill forward and extended market hours settings from universe settings when adding derivative securities (options, index options, futures and future options)
* Minor python syntax check fix
* Minor change
* Default resolution from universe settings for common lean types securities
* Minor test fix
* Cleanup
Build & Test Lean / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
* Implement indicator-based option price model
This model uses IV and Greeks indicators to implement Lean's own option pricing model
* Minor fixes
* Address peer review
* Minor tests fixes
* Make the indicator based price model the default for options
* Address peer review
* Cleanup and minor changes
* Support indicators configuration for new pricing model
* Some cleanup
* Add QL option price model example algorithm
* Return lean models from static helpers
* Minor tests fixes
* Minor test fixes
* Address peer review
* Cleanup
* Fix unit tests
* Move QL models to OptionPriceModels.QuantLib.*
* Add forward tree helper method
* Fix weights calculation in VBaseSignalExport
* fix empty portfolio handling
* Refactored signal export to compute and export weights for all portfolio positions, not just update targets.
* Update BuildCsv XML doc to clarify CSV output details
* Clarify comments on portfolio value and empty weights
* Stamp targets as is; we expect that users send all the weights they want to stamp. Extended the demo algorithm to use two positions to better demonstrate the intended usage of the VBaseSignalExport class.
* Minor changes to address PR review comments.
* Minor fix
---------
Co-authored-by: vb-vlb <volodymyr@vbase.com>
Co-authored-by: Volodymyr <vb-vlb@users.noreply.github.com>
* Return weekly contracts if no standard contracts exist
* Fix unit and regression tests
* Centralize default expiration type flags
* Add ExcludeWeeklys() method
* Mark IncludeWeeklys() as obsolete since weeklies are now default
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
* Increase option strike digits precision to 6
- Increase option strike digits precision to 6. Adding unit test
* test:fix: couple of build tests
* fix:test: Asset CUSIP and OrderListHash in Regression Algorithms
* test:fix: several regression algos
* test:fix: old Symbol CUSIPs to new ones
---------
Co-authored-by: Romazes <romazes20@gmail.com>
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Add SeedInitialPrices algorithm setting
This is true by default and indicates that the engine will seed initial prices right after the security is added or selected
* Update regression algorithms
* Update regression algorithms
* Update regression algorithms
* Refactor default securities seeding
* Minor fix
* Minro fixes
* Cleanup
* Updated and add regression algorithms
* Address peer review
* Centralize logic to get last known data for multiple securities
* Some cleanup
* Minor build fix
* Minor fixes
* More logic centralization
* Some more cleanup
* Cleanup
* Update regression algorithms and minor fixes
* Update regression algorithms
* Minor fix
* More minor fixes
* Update regression algorithms
* Cleanup
* Minor test fix
* Address peer review
* Minor fix and performance improvement
* Fix to seed open interest data
* Minor test fixes
* Address peer review
* Minor change
* Minor revert
* Minor fixes and improvements
* Disable initial seeding by default
* Minor fixes
* Cleanup
* Cleanup
* Minor fix
* Refactor user define universe handling
- Normalize user define universe additions and removals to behave like
other subscriptions without requiting special handling
* Minor fixes
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Fix performance degradation on expirying assets
- Options would expire and get removed, when the universe removed the
security it would never be reseted on universe selection, causing
leaks
- Minor improvement for composer assembly loading
- Minor improvement for loading exception interepreters, so it uses
composer
* Minor regression test fix
* Add new benchmark algorithm
Regression Tests / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
* Use Futures Bank Holidays For Expirations
* Minor improvements
- Futures will be stored by their contract month, not expiry
* Delete dairy future products
* Minor test fixes