Open-High-Low-Close (OHLC) prices data from different brokers
Project description
pricehub
pricehub is a Python package for retrieving OHLC (Open-High-Low-Close) data across various brokers' APIs with a unified interface.
It supports multiple markets, including spot and futures, and provides flexible timestamp inputs and a wide range of intervals.
Effective 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.
Key Features
- Unified Interface: Supports multiple brokers and markets (spot, futures) with a single interface.
- Unified Intervals: Use the same interval format across all brokers.
- Timestamp Flexibility: Accepts timestamps (start, end) in various formats (int, float, string, Arrow, pandas, datetime).
- No Credential Requirement: Fetch public market data without authentication.
- Extended Date Ranges: This package will paginate and collect all data across large date ranges.
- All fields from official API: Retrieve all fields available in the official API (e.g.,
Number of trades
,Taker buy base asset volume
).
Supported Brokers
- Binance Spot
- Binance Futures
- Bybit Spot
Supported Intervals
- Minutes:
1m
,3m
,5m
,15m
,30m
- Hours:
1h
,2h
,4h
,6h
,12h
- Days:
1d
,3d
- Weeks:
1w
- Months:
1M
Installation
pip install pricehub
Quick Start
Example Usage
Retrieve OHLC data from Binance Spot for a 6-hour interval
from pricehub import get_ohlc
df = get_ohlc(
broker="binance_spot",
symbol="BTCUSDT",
interval="6h",
start="2024-10-01",
end="2024-10-02"
)
print(df)
Open High Low Close Volume Close time Quote asset volume Number of trades Taker buy base asset volume Taker buy quote asset volume Ignore
Open time
2024-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
2024-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
2024-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
2024-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
2024-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
Retrieve OHLC data from Bybit Spot for a 1-day interval
from pricehub import get_ohlc
df = get_ohlc(
broker="bybit_spot",
symbol="ETHUSDT",
interval="1d",
start=1727740800.0, # Unix timestamp in seconds for "2024-10-01"
end=1728086400000, # Unix timestamp in ms for "2024-10-05"
)
print(df)
Open High Low Close Volume Turnover
Open time
2024-10-01 2602.00 2659.31 2413.15 2447.95 376729.77293 9.623060e+08
2024-10-02 2447.95 2499.82 2351.53 2364.01 242498.88477 5.914189e+08
2024-10-03 2364.01 2403.50 2309.75 2349.91 242598.38255 5.716546e+08
2024-10-04 2349.91 2441.82 2339.15 2414.67 178050.43782 4.254225e+08
2024-10-05 2414.67 2428.69 2389.83 2414.54 106665.69595 2.573030e+08
Function Reference
def get_ohlc(broker: SupportedBroker, symbol: str, interval: Interval, start: Timestamp, end: Timestamp) -> pd.DataFrame
Retrieves OHLC data for the specified broker, symbol, interval, and date range.
-
Parameters:
broker
: The broker to fetch data from (e.g.,binance_spot
,bybit_spot
).symbol
: The trading pair symbol (e.g.,BTCUSDT
).interval
: The interval for OHLC data (1m
,1h
,1d
, etc.).start
: Start time of the data (supports various formats).end
: End time of the data.
-
Returns:
pandas.DataFrame
: A DataFrame containing OHLC data withOpen time
as the index.
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 pricehub-0.0.2.tar.gz
.
File metadata
- Download URL: pricehub-0.0.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dc9e1124c8e99d409d988a1b305f001b51bd3a21ff216d9729ef80eb0276359 |
|
MD5 | 93c6fc3269f9c666e9d46bdd339f9dbd |
|
BLAKE2b-256 | ead036291e406146d1bebfceac4dbc6f1b6afdd8ea4eeba702938912091de32f |
Provenance
File details
Details for the file pricehub-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pricehub-0.0.2-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 776a7f174e2bcb0159adcb70c6d9e3e5aeca9d85c525b3713c29dfcd59b3f91a |
|
MD5 | 7f81a35625bb1080ab46f773f655ed31 |
|
BLAKE2b-256 | 47456e29eab8fdf294671d74aaf2c78e6d0c9d5cefe378fb4d5480c1b861213a |