CMCLogger - Coin Market Cap Cryptocurreny Data Logger
A python API and script for requesting, parsing and storing the latest cryptocurrency data availalbe using the Coin Market Cap Free API. Data entries are stored in a SQLite3 database, with CLI features for querying data and logger status.
TLDR - Just Get Some Data
# Install the module and script
pip install CMCLogger
# Initialise the required configuration, supplying your API key. (Made above)
CMCLogger -a 'your-api-key' -g
# Start the logger. Use 'nohup CMCLogger' to start detached, 'CMCLogger &' to start in background.
CMCLogger
# Query the latest stored price information for ticker 'BTC'
CMCLogger -q BTC
'BTC: $11676.55 (3.53%)'
# Same as above, but more detailed.
CMCLogger -dq BTC
'BTC: $11676.55 1H: -0.22% 1D: 3.53% 7D: 4.77% 24h Volume: 66.65 Billion'
# Get the logger status. Health is the moving average success rate of the last 30 calls.
CMCLogger -s
'Last successful call 1 minutes ago, health 100.0%.'
# Stop the logger
CMCLogger -k
# Copy the SQLite database to an excel file
CMCLogger -x
Stored Data
When the logger is initialised, it creates a directory structure inside $XDG_CONFIG_HOME. This could be ~/.local/share/CMCLogger or ~/.config/CMCLogger, use echo $XDG_CONFIG_HOME to find the location on your system.
The directory structure is as follows:
CMCLogger
├── config.ini
└── data
├── cryptoData.db
├── log
└── status.ini
config.ini
Contains configuration parameters used. Change any of these settings and restart the logger to apply them. Values shown are the default.
[CMC_API]
api_private_key = your-private-key-here
conversion_currency = AUD
curreny_symbol = $
rank_start_index = 1
rank_end_index = 200
request_interval = 5
[General]
status_file_format = ini
cryptoData.db
A SQLite3 database containing all data retreived by the logger. The database contains a separate table, named afeter the cryptocurrency symbol for each individual currecy collected. SQLitebrower, is a good tool for browsing databases, or use CMCLogger -x to convert the database to an Excel file for viewing.
status.ini
Contains information on the status of the logger. This information is queried and returned when using CMCLogger -s or CMCLogger -ds
[Last Successful Call]
timestamp = 2020-04-23 23:10:55.275000+03:00
error_code = 0
error_message = None
elapsed = 17
credit_count = 1
[Last Failed Call]
timestamp = 2020-04-23 22:39:26.646297+03:00
error_code = 255
error_message = No network connections available.
elapsed = 0
credit_count = 0
[Current Session]
health = 100.0
successful_calls = 35644
failed_calls = 587
success_rate = 98.38
[All Time]
successful_calls = 35746
failed_calls = 589
success_rate = 98.38
log
Runtime logs stored by the Python logging module.
Polybar / I3WM Integration
I3WM
Add to .i3/config to start the logger on login.
exec --no-startup-id CMCLogger
Polybar
Add a polybar module for the target bar:
[module/crypto]
type = custom/script
exec = ~/bin/crypto
tail = true
interval = 300
The target script simply cycles through a set of symbols, a blank string is returned if the last entry was more than 10 minutes ago.
#!/bin/bash
queryArray=("BTC" "LTC" "ETH")
TEMPFILE="/tmp/tmp.CMCLOGGER"
source $TEMPFILE 2> /dev/null
function getNextSymbol {
position=0
for symbol in ${queryArray[@]}; do
((position++))
if [[ "$symbol" == "$LAST_SYMBOL" ]]; then
size=${#queryArray[@]}
position=$((position%size))
CURRENT_SYMBOL=${queryArray[$position]}
break
fi
CURRENT_SYMBOL=${queryArray[0]}
done
echo "LAST_SYMBOL=$CURRENT_SYMBOL" > $TEMPFILE
}
function checkStatus {
jsonStatus=$(CMCLogger -js 2> /dev/null)
lastCall=$(echo "$jsonStatus" | jq -r '.last_call')
if (( $lastCall > 10 )); then
echo ''
exit
fi
}
getNextSymbol
checkStatus
CMCLogger -q $CURRENT_SYMBOL
Metadata
Release files for CMCLogger 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| CMCLogger-0.0.1.tar.gz | 20.1 kB | Without provenance | Details for CMCLogger-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| CMCLogger-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for CMCLogger-0.0.1-py3-none-any.whl |
Total release size: 44.4 kB
Release files / CMCLogger-0.0.1.tar.gz
| Download URL | CMCLogger-0.0.1.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
561bc3a0053baa7079c64b45b9c1d3b71a4d2c1da2301d81520d0c6bc0f5650e
|
|
BLAKE2b-256 checksum How to use checksums |
61e0a49b7e54ceb94ca3e347ccb709041ba927bac9946fc2059a7df6ec02dd95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|
Release files / CMCLogger-0.0.1-py3-none-any.whl
| Download URL | CMCLogger-0.0.1-py3-none-any.whl |
|---|---|
| Size | 24.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
948bf564f5389cbc83fa94d738f2385184dc9cf5fa84f28f35e00a5dd356a6a2
|
|
BLAKE2b-256 checksum How to use checksums |
8fac6f3a46ed5236af2c73ea5d91a87503ff31f23d1f48bcccfe6f34cc035f9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2
|
Security for CMCLogger 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.