This Python command-line application calculates the daily volatility of cryptocurrencies against a fiat currency. It fetches data from a cryptocurrency exchange, processes it, and outputs the results in a CSV file or on the screen.
- Exchange Support: Currently supports Binance (via the CCXT library) for fetching market data.
- Daily Volatility Calculation: Calculates daily volatility using historical price data and a standard formula.
- Configurable Parameters: The exchange, fiat currency, and the number of days to analyze can be configured through a
config.jsonfile. - Logging: Logs activities, such as data fetching and calculations, in the console.
- CSV Output: Optionally outputs results to a CSV file containing:
- Cryptocurrency symbol
- Fiat currency symbol
- Calculated daily volatility
- Last traded price
- Average trading volume over the selected period
- Install Required Packages: The project uses
ccxtfor fetching data,pandasfor data handling andnumpyfor calculation. Install these dependencies using pip:pip install ccxt pandas numpy
To run the program, simply execute main.py:
python3 main.pyThe script will fetch cryptocurrency data from the exchange (defined in the configuration file), calculate the daily volatility, and output the results.
The script reads parameters from a config.json file located in the root directory. Below is an example of the configuration file:
{
"exchange_name": "binance",
"fiat_currency": "EUR",
"days": 10
}exchange_name: The name of the exchange to fetch data from (e.g., "binance").fiat_currency: The fiat currency against which to calculate cryptocurrency volatility (e.g., "EUR").days: The number of days to use for calculating the volatility.
Ensure that you update these parameters as needed before running the script.
The results, including cryptocurrency volatility, last price, and average volume, will be displayed on the console.
Optionally, the program can output the results to a CSV file. The file will include the following columns:
base: The cryptocurrency symbol (e.g., BTC).quote: The fiat currency symbol (e.g., EUR).daily_volatility: The calculated daily volatility.last_price: The last traded price of the cryptocurrency.average_volume: The average trading volume over the selected period.
base,quote,daily_volatility,last_price,average_volume
GRT,EUR,0.003769628628923544,0.1347,180011.8
EOS,EUR,0.025981724346163023,0.762,34726.71
All activities during execution are logged to the console. Example log messages include data fetching status, volatility calculations, and file output notifications.
ccxtfor cryptocurrency market data fetching.pandasfor data manipulation and CSV output.numpyfor mathematical calculations.
Special thanks to the team at Vesper Aerospace for the opportunity and proposition of this project.
Tobias SAVARY