Closed maystorm closed 1 year ago
I noticed this during development and it is a little strange. But that is the result from the API. With the current implementation if the message version is less than 2, both the start and end date default to the current date. Otherwise, the start and end date are read from the message.
There may be a bug in the
ibapi::client::Client::historical_data_ending_now()
method regarding the start date in the returnedibapi::market_data::historical::HistoricalData
struct. E.g., when calling the method as follows (asking for the last 7 days):historical_data_ending_now(&contract, 7.days(), BarSize::Day, WhatToShow::MidPoint, true)
the following data is returned:
Seven TRADING days are correctly returned with "2023-06-16" as the first day, however, the start day says "2023-06-20".
It seems that
HistoricalData::start
is simply filled by subtracting 7 days from the current date and not looking for the first day returned by TWS which would be the correct behaviour.