This project fetches historical candlestick data for Cryptocurrency (like BTC) from the Binance API and saves it to a CSV file. The data can be used for analysis, backtesting trading strategies, or any other purpose that requires historical price information.
- Fetches candlestick data for Cryptocurrency over a customizable date range.
- Writes the data directly to a CSV file to minimize memory usage.
- Handles pagination to ensure all available data is retrieved.
- Python 3.x
requestslibrarypandaslibrary
-
Clone the repository:
git clone https://github.com/yuzaiakira/binance-python-candle-fetcher.git cd binance-python-candle-fetcher -
Install the required libraries:
pip install requests pandas
-
Open the
get_price.pyfile in your preferred code editor. -
Modify the following variables to suit your needs:
- symbol: Change this to the cryptocurrency symbol you want to fetch data for (e.g., 'BTCUSDT' for Bitcoin).
- interval: Set this to the desired candlestick interval (e.g., '15m' for 15 minutes).
- start_year: Update this to the year from which you want to start fetching historical data (e.g., 2017).
-
After making your changes, save the file and run the script to fetch the data:
python get_price.py
-
The script will create a CSV file named
{symbol}_15m_data_{start_year}_{end_time}.csvin the same directory, containing the historical candlestick data.
- Set Up Command-Line Interface
- Make as linux Command
- Modify Documentation
- Write Test 😭