This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import databento as db | |
import pandas as pd | |
client = db.Historical() | |
def rank_by_volume(top=500): | |
""" | |
Returns instrument IDs of instruments that traded most, in descending rank |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raw_symbol | median_spread | median_touch | |
---|---|---|---|
WY3Q3 C1110 | 1 | 70460.2 | |
SR3M6 | 1 | 704.5 | |
SR3M7 | 1 | 502.5 | |
SR3M8 | 1 | 256.2 | |
SR3U3 | 1 | 15647.5 | |
SR3U4 | 1 | 710.0 | |
SR3U5 | 1 | 746.0 | |
SR3U6 | 1 | 399.0 | |
SR3:AB 01Y U4 | 1 | 27.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Building high-frequency trading signals in Python with Databento and sklearn | |
# | |
# This is a simple example that demonstrates how to build high-frequency trading signals in Python, | |
# using order book and market depth data from [Databento](https://databento.com) together with | |
# machine learning models from [sklearn](https://scikit-learn.org/). | |
import databento as db | |
import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import databento as db | |
client = db.Historical() | |
data = client.timeseries.get_range( | |
dataset='GLBX.MDP3', | |
schema='definition', | |
symbols='ALL_SYMBOLS', | |
start='2023-12-27', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Gets official open interest and volume from CME options data using Databento | |
# | |
# CME has different parent symbols like E[1-4][A-D], EW, ES, LO[1-4][A-D], LO | |
# Databento provides these as E1A.OPT, E2A.OPT, ..., respectively. | |
# | |
# However, this can be tedious to fetch one at a time. Another way to fetch | |
# all options of interest is to do it yourself using `ALL_SYMBOLS` and | |
# take advantage of the 'group' column in the instrument definitions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import databento as db | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
DATE = pd.Timestamp(year=2023, month=6, day=22, tz='US/Eastern') | |
NUM_TIME_SAMPLES = 1000 | |
SYMBOL = 'NVDA' | |
WINDOW_LIMITS_US = 120 * 1e6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import databento as db | |
client = db.Historical() | |
data = client.timeseries.get_range( | |
dataset='XNAS.ITCH', | |
schema='ohlcv-1m', | |
symbols='ALL_SYMBOLS', | |
start='20230606T00:00', | |
end='20230606T14:30', | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import databento as db | |
client = db.Historical() | |
# Heating oil, gasoline and crude futures on CME and ICE | |
# .FUT parent symbology notation fetches all expirations across | |
# all outrights and multi-legged spreads etc. | |
CME_SYMBOLS = ['HO.FUT', 'RB.FUT', 'CL.FUT'] | |
ICE_SYMBOLS = ['UHO.FUT', 'UHU.FUT', 'BRN.FUT'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import databento as db | |
import pandas as pd | |
def get_df_move(date: str = '2023-06-06'): | |
end_dt = datetime.datetime.strptime(date+'T16:00', '%Y-%m-%dT%H:%M') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reddit comment 2024-04-03 | |
> See https://www.reddit.com/r/algotrading/comments/1bu59ql/comment/kxuil9a | |
There will always be some differences in the vendor’s infrastructure used to process real-time vs. historical. | |
It takes a bit of effort to make these as identical as possible. Non-exhaustive list: | |
The most common issue I’ve seen is that the vendor will retroactively clean and patch their historical data ex post in ways | |
that are not replicable in real-time. (The most obvious tell is if you report a data error and they tell you it’s patched | |
within the same day.) This is one area where Bloomberg is quite good despite doing it the “wrong” way - they have a |
OlderNewer