coinglass-api


Namecoinglass-api JSON
Version 1.3.0 PyPI version JSON
download
home_pagehttps://github.com/dineshpinto/coinglass-api
SummaryUnofficial Python client for Coinglass API
upload_time2023-11-25 05:54:06
maintainer
docs_urlNone
authordineshpinto
requires_python>=3.10,<4.0
licenseMIT
keywords coinglass api crypto cryptocurrency bitcoin ethereum binance dydx okex
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Coinglass API

[![PyPi version](https://img.shields.io/pypi/v/coinglass-api)](https://pypi.python.org/pypi/coinglass-api/)
[![Downloads](https://static.pepy.tech/badge/coinglass-api)](https://pepy.tech/project/coinglass-api)
[![Python 3.10](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/)
[![codecov](https://codecov.io/gh/dineshpinto/coinglass-api/branch/main/graph/badge.svg?token=XTJRRU2W1T)](https://codecov.io/gh/dineshpinto/coinglass-api)
[![API unittest](https://github.com/dineshpinto/coinglass-api/actions/workflows/api_unitests.yml/badge.svg)](https://github.com/dineshpinto/coinglass-api/actions/workflows/api_unitests.yml)

## Unofficial Python client for Coinglass API

Wrapper around the [Coinglass API](https://coinglass.com/pricing) 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.

![Example Plot](https://github.com/dineshpinto/coinglass-api/blob/main/examples/example_plot.jpg?raw=true)

## Installation

```bash
pip install coinglass-api
```

## Usage

```python
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()
```

| <br/>time           | exchangeName<br/> | symbol<br/> | quoteCurrency<br/> | fundingRate<br/> |
|:--------------------|:------------------|:------------|:-------------------|:-----------------|
| 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")
```

![funding_rate](https://github.com/dineshpinto/coinglass-api/blob/main/examples/funding_rate.jpg?raw=true)

## 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dineshpinto/coinglass-api",
    "name": "coinglass-api",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "coinglass,api,crypto,cryptocurrency,bitcoin,ethereum,binance,dydx,okex",
    "author": "dineshpinto",
    "author_email": "annual.fallout_0z@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3a/ca/24a0bbcde5db996ae1ef41a0fde36cbe2f594974c19b2dab58d4a5a7ac13/coinglass_api-1.3.0.tar.gz",
    "platform": null,
    "description": "# Coinglass API\n\n[![PyPi version](https://img.shields.io/pypi/v/coinglass-api)](https://pypi.python.org/pypi/coinglass-api/)\n[![Downloads](https://static.pepy.tech/badge/coinglass-api)](https://pepy.tech/project/coinglass-api)\n[![Python 3.10](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/)\n[![codecov](https://codecov.io/gh/dineshpinto/coinglass-api/branch/main/graph/badge.svg?token=XTJRRU2W1T)](https://codecov.io/gh/dineshpinto/coinglass-api)\n[![API unittest](https://github.com/dineshpinto/coinglass-api/actions/workflows/api_unitests.yml/badge.svg)](https://github.com/dineshpinto/coinglass-api/actions/workflows/api_unitests.yml)\n\n## Unofficial Python client for Coinglass API\n\nWrapper around the [Coinglass API](https://coinglass.com/pricing) to fetch data about crypto derivatives.\nAll data is output in pandas DataFrames (single or multi-index) and all time-series data uses a `DateTimeIndex`.\nSupports all Coinglass API endpoints.\n\n![Example Plot](https://github.com/dineshpinto/coinglass-api/blob/main/examples/example_plot.jpg?raw=true)\n\n## Installation\n\n```bash\npip install coinglass-api\n```\n\n## Usage\n\n```python\nfrom coinglass_api import CoinglassAPI\n\ncg = CoinglassAPI(coinglass_secret=\"abcd1234\")\n\n# Get perpetual markets for BTC\nperp_markets_btc = cg.perpetual_market(symbol=\"BTC\")\n\n# Get OI history\noi_history_btc = cg.open_interest_history(symbol=\"BTC\", time_type=\"h1\", currency=\"USD\")\n\n# Funding rate of ETH on dYdX\nfr_btc_dydx = cg.funding(ex=\"dYdX\", pair=\"ETH-USD\", interval=\"h8\")\n\n# Get average funding for BTC\nfr_avg_btc = cg.funding_average(symbol=\"BTC\", interval=\"h4\")\n\n# Get funding OHLC for ETH-USDT on Binance\nfr_ohlc_eth_binance = cg.funding_ohlc(ex=\"Binance\", pair=\"ETHUSDT\", interval=\"h4\")\n\n# Get aggregated OI OHLC data for BTC\noi_agg_eth = cg.open_interest_aggregated_ohlc(symbol=\"ETH\", interval=\"h4\")\n\n# Get OHLC liquidations data for ETH-USD on dYdX\nliq_ohlc_eth_dydx = cg.liquidation_pair(ex=\"dYdX\", pair=\"ETH-USD\", interval=\"h4\")\n\n# Get liquidation data for BTC\nliq_btc = cg.liquidation_symbol(symbol=\"BTC\", interval=\"h4\")\n\n# Get long/short ratios for BTC\nlsr_btc = cg.long_short_symbol(symbol=\"BTC\", interval=\"h4\")\n\n# Get GBTC market history\ngbtc_history = cg.grayscale_market_history()\n\n# and more...\n```\n\n## Examples\n\n```\n>>> cg.funding(ex=\"dYdX\", pair=\"ETH-USD\", interval=\"h8\").head()\n```\n\n| <br/>time           | exchangeName<br/> | symbol<br/> | quoteCurrency<br/> | fundingRate<br/> |\n|:--------------------|:------------------|:------------|:-------------------|:-----------------|\n| 2022-08-22 08:00:00 | dYdX              | ETH         | USD                | -0.001151        |\n| 2022-08-22 16:00:00 | dYdX              | ETH         | USD                | 0.001678         |\n| 2022-08-23 00:00:00 | dYdX              | ETH         | USD                | 0.003743         |\n| 2022-08-23 08:00:00 | dYdX              | ETH         | USD                | 0.003561         |\n| 2022-08-23 16:00:00 | dYdX              | ETH         | USD                | 0.000658         |\n\n```\n>>> cg.funding(ex=\"dYdX\", pair=\"ETH-USD\", interval=\"h8\").info()\n```\n\n```\n<class 'pandas.core.frame.DataFrame'>\nDatetimeIndex: 500 entries, 2022-08-22 08:00:00 to 2023-02-04 16:00:00\nData columns (total 4 columns):\n #   Column         Non-Null Count  Dtype  \n---  ------         --------------  -----  \n 0   exchangeName   500 non-null    object \n 1   symbol         500 non-null    object \n 2   quoteCurrency  500 non-null    object \n 3   fundingRate    500 non-null    float64\ndtypes: float64(1), object(3)\nmemory usage: 19.5+ KB\n```\n\n```\n>>> cg.funding(ex=\"dYdX\", pair=\"ETH-USD\", interval=\"h8\").plot(y=\"fundingRate\")\n```\n\n![funding_rate](https://github.com/dineshpinto/coinglass-api/blob/main/examples/funding_rate.jpg?raw=true)\n\n## Disclaimer\n\nThis project is for educational purposes only. You should not construe any such information or other material as legal,\ntax, investment, financial, or other advice. Nothing contained here constitutes a solicitation, recommendation,\nendorsement, or offer by me or any third party service provider to buy or sell any securities or other financial\ninstruments in this or in any other jurisdiction in which such solicitation or offer would be unlawful under the\nsecurities laws of such jurisdiction.\n\nUnder no circumstances will I be held responsible or liable in any way for any claims, damages, losses, expenses, costs,\nor liabilities whatsoever, including, without limitation, any direct or indirect damages for loss of profits.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unofficial Python client for Coinglass API",
    "version": "1.3.0",
    "project_urls": {
        "Homepage": "https://github.com/dineshpinto/coinglass-api",
        "Repository": "https://github.com/dineshpinto/coinglass-api"
    },
    "split_keywords": [
        "coinglass",
        "api",
        "crypto",
        "cryptocurrency",
        "bitcoin",
        "ethereum",
        "binance",
        "dydx",
        "okex"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0f5a6c08482c44981c4778789221e8edc4c2466cb2ddf28e6f97c230df43b7e",
                "md5": "0118052dd8f71756cd90af7429df8847",
                "sha256": "6a168aa00c2b5d54476c50cc8abf3e39924f410dfe5e5162c3e2890b55bf2c9e"
            },
            "downloads": -1,
            "filename": "coinglass_api-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0118052dd8f71756cd90af7429df8847",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 8898,
            "upload_time": "2023-11-25T05:54:04",
            "upload_time_iso_8601": "2023-11-25T05:54:04.300720Z",
            "url": "https://files.pythonhosted.org/packages/d0/f5/a6c08482c44981c4778789221e8edc4c2466cb2ddf28e6f97c230df43b7e/coinglass_api-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3aca24a0bbcde5db996ae1ef41a0fde36cbe2f594974c19b2dab58d4a5a7ac13",
                "md5": "fdef62df3e288d07d8ecb117d2d86013",
                "sha256": "8486b8a11ca720885e984f805e8d1fdb4f35634796dc48cf400cec214c788903"
            },
            "downloads": -1,
            "filename": "coinglass_api-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "fdef62df3e288d07d8ecb117d2d86013",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 9670,
            "upload_time": "2023-11-25T05:54:06",
            "upload_time_iso_8601": "2023-11-25T05:54:06.583382Z",
            "url": "https://files.pythonhosted.org/packages/3a/ca/24a0bbcde5db996ae1ef41a0fde36cbe2f594974c19b2dab58d4a5a7ac13/coinglass_api-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-25 05:54:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dineshpinto",
    "github_project": "coinglass-api",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "coinglass-api"
}
        
Elapsed time: 0.14732s