Unofficial Python client for Coinglass API
Project description
Coinglass API
Unofficial Python client for Coinglass API
Wrapper around the Coinglass API to fetch data about crypto derivatives.
All data is output in pandas DataFrames (single or multi-index) and all time-series data uses a DateTimeIndex
.
Supports all Coinglass API endpoints.
Installation
pip install coinglass-api
Usage
from coinglass_api import CoinglassAPI
cg = CoinglassAPI(coinglass_secret="abcd1234")
# Get perpetual markets for BTC
perp_markets_btc = cg.perpetual_market(symbol="BTC")
# Get OI history
oi_history_btc = cg.open_interest_history(symbol="BTC", time_type="h1", currency="USD")
# Funding rate of ETH on dYdX
fr_btc_dydx = cg.funding(ex="dYdX", pair="ETH-USD", interval="h8")
# Get average funding for BTC
fr_avg_btc = cg.funding_average(symbol="BTC", interval="h4")
# Get funding OHLC for ETH-USDT on Binance
fr_ohlc_eth_binance = cg.funding_ohlc(ex="Binance", pair="ETHUSDT", interval="h4")
# Get aggregated OI OHLC data for BTC
oi_agg_eth = cg.open_interest_aggregated_ohlc(symbol="ETH", interval="h4")
# Get OHLC liquidations data for ETH-USD on dYdX
liq_ohlc_eth_dydx = cg.liquidation_pair(ex="dYdX", pair="ETH-USD", interval="h4")
# Get liquidation data for BTC
liq_btc = cg.liquidation_symbol(symbol="BTC", interval="h4")
# Get long/short ratios for BTC
lsr_btc = cg.long_short_symbol(symbol="BTC", interval="h4")
# Get GBTC market history
gbtc_history = cg.grayscale_market_history()
# and more...
Examples
>>> cg.funding(ex="dYdX", pair="ETH-USD", interval="h8").head()
time |
exchangeName |
symbol |
quoteCurrency |
fundingRate |
---|---|---|---|---|
2022-08-22 08:00:00 | dYdX | ETH | USD | -0.001151 |
2022-08-22 16:00:00 | dYdX | ETH | USD | 0.001678 |
2022-08-23 00:00:00 | dYdX | ETH | USD | 0.003743 |
2022-08-23 08:00:00 | dYdX | ETH | USD | 0.003561 |
2022-08-23 16:00:00 | dYdX | ETH | USD | 0.000658 |
>>> cg.funding(ex="dYdX", pair="ETH-USD", interval="h8").info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 500 entries, 2022-08-22 08:00:00 to 2023-02-04 16:00:00
Data columns (total 4 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 exchangeName 500 non-null object
1 symbol 500 non-null object
2 quoteCurrency 500 non-null object
3 fundingRate 500 non-null float64
dtypes: float64(1), object(3)
memory usage: 19.5+ KB
>>> cg.funding(ex="dYdX", pair="ETH-USD", interval="h8").plot(y="fundingRate")
Disclaimer
This project is for educational purposes only. You should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained here constitutes a solicitation, recommendation, endorsement, or offer by me or any third party service provider to buy or sell any securities or other financial instruments in this or in any other jurisdiction in which such solicitation or offer would be unlawful under the securities laws of such jurisdiction.
Under no circumstances will I be held responsible or liable in any way for any claims, damages, losses, expenses, costs, or liabilities whatsoever, including, without limitation, any direct or indirect damages for loss of profits.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file coinglass_api-1.0.1.tar.gz
.
File metadata
- Download URL: coinglass_api-1.0.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73a5f5b9c98ef63f79d7ba5f663441c7897390e68e975fbe0ee08b62703ee28 |
|
MD5 | d63aff600e2bd2cd5d391e45807ee6ed |
|
BLAKE2b-256 | 4fc70d3085fc0edf95595e590d5eddf92b81395c11ea39a6ba93a87fe2407667 |
Provenance
File details
Details for the file coinglass_api-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: coinglass_api-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.11.2 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40974c29bcbaf5797ca8ce597ca142c51639a21b240a05c761b0b80bc360e3ae |
|
MD5 | 2e280202eb1668b49bd9185e12bbfdf8 |
|
BLAKE2b-256 | 6e3a60338008fc97f19f01725802ecd2cfcc2777d3f7addad368a9b47a9d983e |