Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in History request for Tick data of Future #7853

Open
scloudyy opened this issue Mar 15, 2024 · 2 comments
Open

Bug in History request for Tick data of Future #7853

scloudyy opened this issue Mar 15, 2024 · 2 comments

Comments

@scloudyy
Copy link

scloudyy commented Mar 15, 2024

Expected Behavior

This 3 History requests for Tick data should return same number of Tick data for Future

  1. History(Symbol, start, end, Resolution.Tick)
  2. History[Tick](Symbol, start, end, Resolution.Tick)
  3. History(Tick, Symbol, start, end, Resolution.Tick)

Actual Behavior

When requesting Tick data for Future, only the first History request History(Symbol, start, end, Resolution.Tick) returns data

The second and third History request returns empty or a few unrelated data point.

Reproducing the Problem

Run below code on research environment in Algorithm Lab:

qb.SetStartDate(2020, 6, 4)
future = qb.AddFuture(Futures.Currencies.EUR, Resolution.Minute)
contract_symbols = sorted(qb.FutureChainProvider.GetFutureContractList(future.Symbol, qb.Time), key=lambda symbol: symbol.ID.Date)
contract = contract_symbols[0]
qb.AddFutureContract(contract_symbols[0])

end_time = datetime(2020, 6, 3, 11, 0, 0)
start_time = end_time - timedelta(days=1)
ticks_df_tick_in_first_argument = qb.History(Tick, contract, start_time, end_time, Resolution.Tick)
ticks_obj = qb.History[Tick](contract, start_time, end_time, Resolution.Tick)
ticks_df = qb.History(contract, start_time, end_time, Resolution.Tick)

print('length of tick dataframe:' + str(len(ticks_df)))
print('length of tick dataframe with Tick in first argument:' + str(len(ticks_df_tick_in_first_argument)))
print('length of tick object list:' + str(len([t for t in ticks_obj])))

// The output is:
// length of tick dataframe:856834
// length of tick dataframe with Tick in first argument:3
// length of tick object list:3

The History request History(Symbol, start, end, Resolution.Tick) returns 856834 data points. The other returns 3 data points, which are all Open Interest instead of Trade or Quote, see image below:

Screenshot 2024-03-14 at 2 24 59 PM

Also tried different future like Futures.Indices.SP500EMini, as well as different time range 2024-03-06 11:00:00 - 2024-03-07 11:00:00. The issue consists for multiple Futures and multiple time range:

Screenshot 2024-03-14 at 2 25 08 PM Screenshot 2024-03-14 at 2 25 12 PM

To make the second and third History request return more data, the future must be added at Tick resolution qb.AddFutureContract(contract_symbols[0], Resolution.Tick). After that 3 History call return same data:

Screenshot 2024-03-17 at 3 35 17 PM

This issue not exist in Equity. Take SPY for example. SPY are added at Minute resolution and 3 History call returns same amount Tick data:

Screenshot 2024-03-14 at 2 25 19 PM

System Information

Algorithm Lab

Checklist

  • [ x] I have completely filled out this template
  • [ x] I have confirmed that this issue exists on the current master branch
  • [ x] I have confirmed that this is not a duplicate issue by searching issues
  • [ x] I have provided detailed steps to reproduce the issue
@scloudyy
Copy link
Author

scloudyy commented Mar 17, 2024

Also tested Crypto. Looks like Crypto also don't have this issue. The Crypto is added add Minute solution and 3 History call for Tick returns same data:

Screenshot 2024-03-17 at 3 24 52 PM

Looks like issue only happens to Future.

@Martin-Molinero
Copy link
Member

Hey @scloudyy! Thank you for the detail report, we will check it out when we have a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants