{"id":37230834,"url":"https://github.com/eslazarev/pricehub","last_synced_at":"2026-01-15T03:40:25.305Z","repository":{"id":260802446,"uuid":"882306071","full_name":"eslazarev/pricehub","owner":"eslazarev","description":"PriceHub: Unified Python Package for Collecting OHLC Prices from Binance, Bybit, OKX and Coinbase APIs into a DataFrame","archived":false,"fork":false,"pushed_at":"2025-07-05T14:26:02.000Z","size":253,"stargazers_count":116,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-05T15:43:40.416Z","etag":null,"topics":["algotrading","binance","broker","bybit","coinbase","crypto","crypto-trading","cryptocurrency","cryptocurrency-exchanges","ohlc","ohlc-series","ohlcv","ohlcv-data","okx","prices","quantitative-finance","trading"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pricehub/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eslazarev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-11-02T13:21:24.000Z","updated_at":"2025-07-05T14:27:18.000Z","dependencies_parsed_at":"2024-11-02T17:27:39.858Z","dependency_job_id":"f4144ef2-ae42-4eb2-ba88-ae9e20ffee3b","html_url":"https://github.com/eslazarev/pricehub","commit_stats":null,"previous_names":["eslazarev/pricehub"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/eslazarev/pricehub","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eslazarev%2Fpricehub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eslazarev%2Fpricehub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eslazarev%2Fpricehub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eslazarev%2Fpricehub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eslazarev","download_url":"https://codeload.github.com/eslazarev/pricehub/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eslazarev%2Fpricehub/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28442311,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T00:55:22.719Z","status":"online","status_checked_at":"2026-01-15T02:00:08.019Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algotrading","binance","broker","bybit","coinbase","crypto","crypto-trading","cryptocurrency","cryptocurrency-exchanges","ohlc","ohlc-series","ohlcv","ohlcv-data","okx","prices","quantitative-finance","trading"],"created_at":"2026-01-15T03:40:24.810Z","updated_at":"2026-01-15T03:40:25.299Z","avatar_url":"https://github.com/eslazarev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![CI](https://github.com/eslazarev/pricehub/workflows/CI/badge.svg)\n![Pylint](https://raw.githubusercontent.com/eslazarev/pricehub/refs/heads/main/.github/badges/pylint.svg)\n![Coverage](https://raw.githubusercontent.com/eslazarev/pricehub/refs/heads/main/.github/badges/coverage.svg)\n![Black](https://img.shields.io/badge/code%20style-black-000000.svg)\n![Python Versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)\n![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue)\n![PyPI Downloads](https://static.pepy.tech/badge/pricehub)\n\n\n# **PriceHub**: Unified Python Package for Collecting OHLC Prices from Binance, Bybit, Coinbase, OKX, Kraken, and KuCoin APIs into a DataFrame\n\nIt supports multiple markets, including spot and futures, and provides flexible timestamp inputs and a wide range of intervals.\n\nEffective trading begins with thorough data analysis, visualization, and backtesting. This package simplifies access to such data, providing a unified solution for retrieving OHLC information across various broker APIs.\n\n## Contents\n- [Supported Brokers](#supported-brokers)\n- [Key Features](#key-features)\n- [Supported Intervals](#supported-intervals)\n- [Installation](#installation)\n- [Function Reference](#function-reference)\n- [Example Usage](#example-usage)\n  - [Save data to CSV, Excel, Parquet files](#save-data-to-csv-excel-parquet-files)\n  - [Retrieve OHLC data from Binance Spot for a 6-hour interval](#retrieve-ohlc-data-from-binance-spot-for-a-6-hour-interval)\n  - [Retrieve OHLC data from Bybit Spot for a 1-day interval](#retrieve-ohlc-data-from-bybit-spot-for-a-1-day-interval)\n  - [Retrieve OHLC data from KuCoin Spot for a 1-hour interval](#retrieve-ohlc-data-from-kucoin-spot-for-a-1-hour-interval)\n  - [Retrieve OHLC data from KuCoin Futures for a 1-hour interval](#retrieve-ohlc-data-from-kucoin-futures-for-a-1-hour-interval)\n  - [Plot Close 1d data with matplotlib: BTCUSDT Futures on Binance for the last year](#plot-close-1d-data-with-matplotlib-btcusdt-futures-on-binance-for-the-last-year)\n  - [Plot OHLC 1w data with plotly: BTCUSDT Spot on Binance for the last five years](#plot-ohlc-1w-data-with-plotly-btcusdt-spot-on-binance-for-the-last-five-years)\n  - [Create custom intervals 10m for SOLUSDT Spot on Bybit for the last month](#create-custom-intervals-10m-for-solusdt-spot-on-bybit-for-the-last-month)\n\n\n### Supported Brokers\n- Binance Spot\n- Binance Futures\n- Bybit Spot\n- Bybit Linear (Futures)\n- Bybit Inverse\n- Coinbase Spot\n- OKX Spot\n- OKX Futures\n- Kraken Spot\n- KuCoin Spot\n- KuCoin Futures\n\n## Key Features\n\n- **Unified Interface**: Supports multiple brokers and markets (spot, futures) with a single interface.\n- **Unified Intervals**: Use the same interval format across all brokers.\n- **Timestamp Flexibility**: Accepts timestamps (start, end) in various formats (int, float, string, Arrow, pandas, datetime).\n- **No Credential Requirement**: Fetch public market data without authentication.\n- **Extended Date Ranges**: This package will paginate and collect all data across large date ranges.\n- **All fields from official API**: Retrieve all fields available in the official API (e.g., `Number of trades`, `Taker buy base asset volume`). \n\n## Supported Intervals\n(depends on the broker)\n- **Seconds**: `1s`\n- **Minutes**: `1m`, `3m`, `5m`, `15m`, `30m`\n- **Hours**: `1h`, `2h`, `4h`, `6h`, `12h`\n- **Days**: `1d`, `3d`\n- **Weeks**: `1w`\n- **Months**: `1M`\n\n---\n\n## Installation\n\n```bash\npip install pricehub\n```\n\n## Function Reference\n\n### `def get_ohlc(broker: SupportedBroker, symbol: str, interval: Interval, start: Timestamp, end: Timestamp) -\u003e pd.DataFrame`\n\nRetrieves OHLC data for the specified broker, symbol, interval, and date range.\n\n- **Parameters**:\n  - `broker`: The broker to fetch data from (e.g., `binance_spot`, `bybit_spot`, `okx_futures`, `kraken_spot`).\n  - `symbol`: The trading pair symbol (e.g., `BTCUSDT`).\n  - `interval`: The interval for OHLC data (`1m`, `1h`, `1d`, etc.).\n  - `start`: Start time of the data (supports various formats).\n  - `end`: End time of the data (supports various formats).\n\n- **Returns**:\n  - `pandas.DataFrame`: A DataFrame containing OHLC data.\n\n---\n\n## Example Usage\n\n### Save data to CSV, Excel, Parquet files\n```python\n\nfrom pricehub import get_ohlc\ndf = get_ohlc(\"binance_spot\", \"BTCUSDT\", \"1d\", \"2024-10-01\", \"2024-10-05\")\ndf.to_csv(\"btcusdt_1d_2024-10-01_2024-10-05.csv\") # Save to CSV\ndf.to_excel(\"btcusdt_1d_2024-10-01_2024-10-05.xlsx\") # Save to Excel\ndf.to_parquet(\"btcusdt_1d_2024-10-01_2024-10-05.parquet\") # Save to Parquet, requires 'pyarrow', 'fastparquet'\n```\n\n\n### Retrieve OHLC data from Binance Spot for a 6-hour interval\n```python\nfrom pricehub import get_ohlc\n\ndf = get_ohlc(\n    broker=\"binance_spot\",\n    symbol=\"BTCUSDT\",\n    interval=\"6h\",\n    start=\"2024-10-01\",\n    end=\"2024-10-02\"\n)\nprint(df)\n```\n\n```python\n                        Open     High      Low    Close      Volume              Close time  Quote asset volume  Number of trades  Taker buy base asset volume  Taker buy quote asset volume  Ignore\nOpen time                                                                                                                                                                                           \n2024-10-01 00:00:00  63309.0  63872.0  63000.0  63733.9   39397.714 2024-10-01 05:59:59.999        2.500830e+09          598784.0                    19410.785                  1.232417e+09     0.0\n2024-10-01 06:00:00  63733.9  64092.6  63683.1  63699.9   32857.923 2024-10-01 11:59:59.999        2.100000e+09          446330.0                    15865.753                  1.014048e+09     0.0\n2024-10-01 12:00:00  63700.0  63784.0  61100.0  62134.1  242613.990 2024-10-01 17:59:59.999        1.512287e+10         2583155.0                   112641.347                  7.022384e+09     0.0\n2024-10-01 18:00:00  62134.1  62422.3  60128.2  60776.8  114948.208 2024-10-01 23:59:59.999        7.031801e+09         1461890.0                    54123.788                  3.312086e+09     0.0\n2024-10-02 00:00:00  60776.7  61858.2  60703.3  61466.7   51046.012 2024-10-02 05:59:59.999        3.133969e+09          668558.0                    27191.919                  1.669187e+09     0.0\n```\n\n### Retrieve OHLC data from Bybit Spot for a 1-day interval\n```python\nfrom pricehub import get_ohlc\n\ndf = get_ohlc(\n    broker=\"bybit_spot\",\n    symbol=\"ETHUSDT\",\n    interval=\"1d\",\n    start=1727740800.0, # Unix timestamp in seconds for \"2024-10-01\"\n    end=1728086400000, # Unix timestamp in ms for \"2024-10-05\"\n)\nprint(df)\n```\n\n```python\n               Open     High      Low    Close        Volume      Turnover\nOpen time                                                                 \n2024-10-01  2602.00  2659.31  2413.15  2447.95  376729.77293  9.623060e+08\n2024-10-02  2447.95  2499.82  2351.53  2364.01  242498.88477  5.914189e+08\n2024-10-03  2364.01  2403.50  2309.75  2349.91  242598.38255  5.716546e+08\n2024-10-04  2349.91  2441.82  2339.15  2414.67  178050.43782  4.254225e+08\n2024-10-05  2414.67  2428.69  2389.83  2414.54  106665.69595  2.573030e+08\n```\n\n### Retrieve OHLC data from KuCoin Spot for a 1-hour interval\n```python\nfrom pricehub import get_ohlc\n\ndf = get_ohlc(\n    broker=\"kucoin_spot\",\n    symbol=\"BTC-USDT\",\n    interval=\"1h\",\n    start=\"2024-10-01\",\n    end=\"2024-10-02\"\n)\nprint(df)\n```\n\n### Retrieve OHLC data from KuCoin Futures for a 1-hour interval\n```python\nfrom pricehub import get_ohlc\n\ndf = get_ohlc(\n    broker=\"kucoin_futures\",\n    symbol=\"XBTUSDTM\",\n    interval=\"1h\",\n    start=\"2024-10-01\",\n    end=\"2024-10-02\"\n)\nprint(df)\n```\n\n### Plot Close 1d data with matplotlib: BTCUSDT Futures on Binance for the last year\n```python\nfrom datetime import datetime, timedelta\n\nimport matplotlib.pyplot as plt\nfrom pricehub import get_ohlc\n\nnow = datetime.now()\ndf = get_ohlc(\"binance_futures\", \"BTCUSDT\", \"1d\", now - timedelta(days=365), now)\ndf[\"Close\"].plot()\nplt.show()\n```\n![binance_btcusdt_futures.png](https://raw.githubusercontent.com/eslazarev/pricehub/refs/heads/main/.github//images/binance_btcusdt_futures.png)\n\n\n### Plot OHLC 1w data with plotly: BTCUSDT Spot on Binance for the last five years\n```python\nfrom datetime import datetime, timedelta\nimport plotly.graph_objects as go\nfrom pricehub import get_ohlc\n\nnow = datetime.now()\ndf = get_ohlc(\"binance_spot\", \"BTCUSDT\", \"1w\", now - timedelta(days=365 * 5), now)\n\nfig = go.Figure(data=go.Candlestick(x=df.index, open=df['Open'], high=df['High'], low=df['Low'], close=df['Close']))\n\nfig.update_layout()\nfig.show()\n```\n![binance_btc_usdt_spot_1w_5_years.png](https://raw.githubusercontent.com/eslazarev/pricehub/refs/heads/main/.github/images/binance_btc_usdt_spot_1w_5_years.png)\n\n\n\n### Create custom intervals 10m for SOLUSDT Spot on Bybit for the last month\n```python\nfrom datetime import datetime, timedelta\nfrom pricehub import get_ohlc\nnow = datetime.now()\ndf = get_ohlc(\"bybit_spot\", \"SOLUSDT\", \"5m\", now - timedelta(days=31), now)\ndf_10m = (\n    df.resample(\n        \"10min\",\n    ).agg(\n        {\n            \"Open\": \"first\",\n            \"High\": \"max\",\n            \"Low\": \"min\",\n            \"Close\": \"last\",\n            \"Volume\": \"sum\",\n        }\n    )\n)\nprint(df.head())\nprint(df_10m.head())\n```\n\n\n```python\n#5m\n                      Open    High     Low   Close    Volume      Turnover\nOpen time                                                                  \n2024-11-07 17:40:00  194.13  194.66  194.03  194.54  3391.378  6.592576e+05\n2024-11-07 17:45:00  194.54  195.48  194.44  195.41  6075.927  1.184312e+06\n2024-11-07 17:50:00  195.41  195.71  195.06  195.69  4073.276  7.961276e+05\n2024-11-07 17:55:00  195.69  196.16  195.59  195.93  8774.224  1.719060e+06\n2024-11-07 18:00:00  195.93  196.83  195.73  196.34  5075.807  9.973238e+05\n\n#10m\n                       Open    High     Low   Close     Volume\nOpen time                                                     \n2024-11-07 17:40:00  194.13  195.48  194.03  195.41   9467.305\n2024-11-07 17:50:00  195.41  196.16  195.06  195.93  12847.500\n2024-11-07 18:00:00  195.93  196.83  194.66  195.29  12506.671\n2024-11-07 18:10:00  195.29  196.13  194.70  195.58  20437.030\n2024-11-07 18:20:00  195.58  196.00  194.84  195.81  16388.688\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feslazarev%2Fpricehub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feslazarev%2Fpricehub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feslazarev%2Fpricehub/lists"}