client
drift_data.client
#
Client
#
Bases: BaseModel
Client to interact with Drift Data API.
This client allows you to hit the Drift Data API. The playground is a good place to start exploring the API endpoints. There is also some documentation for the API, but it is not very detailed.
The client supports two clusters: mainnet and devnet. Although support for
devnet does not seem to be fully implemented yet, so it may not replicate all
functionality available on mainnet.
get_contracts
#
Get all contracts from the Drift Data API.
This method retrieves all contracts from the Drift Data API. It returns a list
of ContractRaw objects.
Returns:
| Type | Description |
|---|---|
list[ContractRaw]
|
list[ContractRaw]: A list of raw contract data. |
Source code in drift_data/client.py
get_funding_rates
#
get_funding_rates(symbol: str, year: int | None = None, month: int | None = None, day: int | None = None) -> list[FundingRateRecord]
Get funding rates for a given symbol.
This method retrieves funding rates for a specific symbol. You can get the last
30 days of funding rates by default, or you can specify a specific date by
providing the year, month, and day parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
The symbol to get funding rates for. |
required |
year
|
int
|
The year to get funding rates for. Defaults to None. |
None
|
month
|
int
|
The month to get funding rates for. Defaults to None. |
None
|
day
|
int
|
The day to get funding rates for. 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_data/client.py
model_post_init
#
Perform tasks after the model is instantiated and fields are validated.
This is a Pydantic model hook that does the following:
Override this method to perform additional initialization after init and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.