Table of Contents
I wanted to start logging various crypto prices on a regular cadence. This tool was created specificaly for me, but could be customized easily for your own use case.
It currently tracks the prices for:
- Ethereum
- Polygon
- Python
- MySQL
- SqlAlchemy ORM
- Kraken Public API
To get this running for your own use you'll need to set up a few things.
- You'll need to know how to set up a database and access to it.
- Have a modern version of Python installed
- MySQL
- Create a mysql database if you don't want to modify the code.
sudo mysql -p
create database some_database;
create 'some_user'@'%' identified by 'some_password';
grant all privileges on some_database.* TO 'some_user'@'%';
-
Clone the repo
git clone https://github.com/zackoch/crypto_tracker.git
-
Create a virtual environment
cd crypto_tracker && python3 -m venv venv
-
Install required packages via pip
source venv/bin/activate pip install -r requirements.txt
-
Modify environment variables
mv sample.env .env nano .env
replace
some_user
,some_password
,host
, andsome_database
to match the database and user you created in the prerequisitesDB_CON_STRING='mysql+pymysql://some_user:some_password@host/some_database'
-
Create the tables
python
from models import * Base.metadata.create_all(engine) exit()
- You can call the script directly which will insert the data into your db one time (useful to test)
source venv/bin/activate python main.py
OR
- You can schedule it as a cronjob to run at a specific time / cadence
sudo crontab -e
- Modify your crontab to include an entry similar to below (runs every minute):
* * * * * cd /home/zac/crypto_tracker && /home/zac/crypto_tracker/venv/bin/python /home/zac/crypto_tracker/main.py
- see Crontab.Guru to make your own schedule