mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-27 20:36:38 +08:00
e415c0f350
The end date of the last contract with a sufficient start date was being used for the continuous future overall end date; however the end date of that contract (which is the last day for which there is data for the contract) is not necessarily the greatest end date out of all contracts. It is possible for the furthest out contract to have some, but very few, trades before it is more actively traded. Which would give it a start date within in the range of the simulation, but an end date is earlier than the other contracts which are active during the simulation. This bug would result in `nan`s when getting the current price because of the `end_date` check in `get_spot_value`. When the current simulation time was greater than the `end_date` of the last contract the condition which guards against attempting to get data for an instrument past its end date would return a `nan`, even when the current underlying contract did have data for that date. Use max end date of all contracts instead of the last one, to ensure that the continuous future last date is always great enough to allow access to all contracts with in the chain. Also, use min start date to accurately mirror the end date behavior.