This program, aggr_max_vol_01.py, analyzes Bitcoin (BTC) trading data from compressed CSV files (.gz) to detect significant trading volume spikes. It then stores these spikes in a local SQLite database for later analysis.
The program reads compressed CSV files containing BTC trade data from a specified directory. It filters the data, aggregates it into 1-minute intervals, identifies volume spikes, and stores them in a database.
- Data Input: Reads compressed CSV files (
.gz) from a designated directory (/home/astroill/BTC/aggr-server/databy default). - Data Filtering: Filters data by date (
START_DATE) and minimum volume (MORE_BTC_THRESHOLD). - Data Aggregation: Resamples data into 1-minute intervals and calculates summary statistics.
- Spike Detection: Identifies volume spikes above a defined threshold (
MAXIMUM_VOLUME_THRESHOLD). - Database Storage: Stores spike information in a local SQLite database (
btc.db). - Duplicate Prevention: Avoids saving duplicate records with the same timestamp.
- Error Handling: Includes robust error handling and logging to manage potential issues.
- Logging: Includes robust logging to
aggr_max_vol.logfile. - Output: Prints the time, closing price, volume for each spike and the timestamp of the most recent record in the database.
- Python 3.x
- Required Python libraries:
pandas
dbiLL.db_btc
- Clone or download the repository.
- Install the required Python packages:
Also you need to add
pip install pandas
dbiLL.db_btc.
- Place Data: Ensure that your compressed CSV (
.gz) data files are in the directory specified by theDATA_PATHconstant in the script. By default it is:/home/astroill/BTC/aggr-server/data. Files should have date in the name. - Run the Script:
python aggr_max_vol_01.py
- Logging
All errors and warnings will be logged to
aggr_max_vol.log - Check for spikes. The program will print spikes into console.
- Check DB
The detected spikes will be saved in
btc.db.
The following constants in aggr_max_vol_01.py can be adjusted:
MORE_BTC_THRESHOLD: The minimum trading volume for a record to be considered. Default:10.MAXIMUM_VOLUME_THRESHOLD: The minimum volume for a spike to be identified. Default:500.DATA_PATH: The directory where the compressed CSV files are located. Default:/home/astroill/BTC/aggr-server/data.START_DATE: The minimum date for the files that will be processed. Default:2025-03-04.
- Console Output:
- Prints the exchange/pair, timestamp, closing price, and volume for each detected volume spike.
- Prints the timestamp of the most recent record saved in the database.
- Database:
- Saves detected spikes in the
btc.dbSQLite database. - Stores
time,close,vol,dir,liqfor each record.
- Saves detected spikes in the
- Logging:
- All errors and warnings will be saved in
aggr_max_vol.log
- All errors and warnings will be saved in
- File should be in
.gzformat. - Each file's name is expected to include a date (YYYY-MM-DD) at the beginning of the name.
- Each
.gzfile contains data about BTC trades with the following space-separated columns:time,close,vol,dir,liq.
[MIT License]