Skip to main content

No project description provided

Project description

Publish to PyPI PyPI version PyPI version

This is a Python client for the Quantsight Data API, which allows you to fetch historical funding rates, candle data, and perform custom queries from supported exchanges. The client is easy to use and supports fetching data into a Pandas DataFrame for further analysis.

Key features:

✅ Pull data from API directly as a pandas DataFrame

✅ Automatically cached data for faster retrieval and saved credits

✅ Integrated OpenAI for querying data using natural language prompts

Installation

To install the Quantsight Data API Python client, use pip:

pip install quantsight

Usage

First, import the QuantsightDataAPI class and create an instance with your API key:

import quantsight as qs

api_key = "your_api_key"
qs = qs.Quantsight(api_key)

Then, you can use the following methods to fetch data from the Quantsight Data API:

Get funding rate

To fetch historical funding rates from a supported exchange, use the get_funding_rate method:

funding_rate_df = qs.get_funding_rate(
    exchange="okx",
    limit=1e6,
)

Get OHLCV data

To fetch candle data from a supported exchange, use the get_ohlcv method:

ohlcv_df = qs.get_ohlcv(
    period="1d",
    exchange="okx",
    limit=1e6,
)

Get OHLCV data around time

To fetch candle data around a specific point in time, use the get_ohlcv_around_time method:

ohlcv_around_time_df = qs.get_ohlcv_around_time(
    period="1d",
    exchange="okx",
    target_time=time(9,0,0),
    sample_count=10,
    limit=1e6,
)

Endpoint is useful for execution optimisation or seasonality analysis

Custom query (BETA)

To perform a custom query, use the custom_query method:

custom_query_df = qs.custom_query(
    "SELECT close FROM {{okx.ohlcv.swap.1d}} LIMIT 10", 
    dry_run=True, 
    use_legacy_sql=False
)

Each method returns a Pandas DataFrame containing the fetched data.

Caching

Queries are cached both in BigQuery and on the client side in order to maximise your data allowance.

By default the local cache location is stored next to the clien.py file but you may change it when initialising the client:

qs = qs.Quantsight(
    api_key=api_key,
    cache_path=Path("root/your/custom/cache/location")
)

You can retrieve cache metadata like so:

qs.read_cache_metadata()

You can delete all cache like so:

qs.clear_cache()

Pandas cache is handled by the data-cache library.

Documentation

The documentation for each endpoints can be found here: https://api.quantsight.dev/docs

License

This project is licensed under the MIT License. See the GNU GENERAL PUBLIC LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quantsight-0.1.11.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quantsight-0.1.11-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file quantsight-0.1.11.tar.gz.

File metadata

  • Download URL: quantsight-0.1.11.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for quantsight-0.1.11.tar.gz
Algorithm Hash digest
SHA256 e07781cb2406b854a4068636281c4def010b1e84f8580625811da152f7a552a4
MD5 f7e9affb04e40d506e7664b04a292d53
BLAKE2b-256 5a49d3206ad5405f4cb636ae964c818bd4c40f1b051e5dc178f39199b2be8cce

See more details on using hashes here.

File details

Details for the file quantsight-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: quantsight-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for quantsight-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 569077e6b081ea75fcd4a1f5a5534d3994ea8137cae13b6d7b4e5fdb89f82a7a
MD5 e90a9062e699719297c4c79c2f8f7a81
BLAKE2b-256 74dd2b3f0e5fa6cf82f209fdeee38c8074e3929bdeb6bd4467b2839b20307e33

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page