drift-cataloger Prefect Flow Tasks#
drift_cataloger.get_funding_rate_records
#
Fetch funding rate records for a given symbol from the Drift API.
This function retrieves funding rate records for a specific trading pair symbol. If a specific date is provided, it fetches funding rates for that date; otherwise, it fetches all available funding rates for the symbol from the last 31 days. This is specified in the Drift API playground.
The entire list of supported symbols can be found on the GET /contracts
endpoint, but the recommended symbols to use are SOL-PERP, BTC-PERP, and
ETH-PERP.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
The trading pair symbol to fetch funding rates for. |
required |
date_
|
date | None
|
The specific day to fetch funding rates for. If None, fetches all available funding rates for the symbol from the last 31 days. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[FundingRateRecord]
|
list[FundingRateRecord]: A list of funding rate records for the specified symbol and date. |
Source code in drift_cataloger/data_api.py
drift_cataloger.publish_funding_rates_to_db
#
publish_funding_rates_to_db(records: Sequence[FundingRateRecord], engine: Engine | None = None) -> None
Publish funding rate records to the database, merging them with existing records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
Sequence[FundingRateRecord]
|
A sequence of funding rate records to publish to the database. |
required |
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|
Source code in drift_cataloger/data_api.py
drift_cataloger.publish_funding_rate_data
#
publish_funding_rate_data(symbol: str, date_: date | None = None, engine: Engine | None = None) -> None
Fetch and publish funding rate data for a specific symbol.
This function retrieves funding rate records for a given trading pair symbol from the Drift API. If a specific date is provided, it fetches funding rates for that date; otherwise, it fetches all available funding rates for the symbol from the last 31 days. The fetched records are then checked against the database to see if they have already been published. If not, the new records are published to the database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
The trading pair symbol to fetch funding rates for. |
required |
date_
|
date | None
|
The specific day to fetch funding rates for. If None, fetches all available funding rates for the symbol from the last 31 days. Defaults to None. |
None
|
engine
|
Engine | None
|
SQLAlchemy engine, if not provided, the default engine will be used. Defaults to None. |
None
|