Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

currency and other utilities

Project description

denarius

currency and other utilities

If you don’t find a way to make money while you sleep, you will work until you die. – Warren Buffett

introduction

denarius is a project, not a finished product. It features various utilities for collating cryptocurrency, mining, financial and other data, for plotting data and for accessing bank accounts. It features analyses of data for systematic descriptions, for predictions, for arbitrage etc.

setup

sudo apt-get install sqlite

wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-linux64.tar.gz
tar -xvzf geckodriver-v0.19.1-linux64.tar.gz
rm geckodriver-v0.19.1-linux64.tar.gz
chmod +x geckodriver
sudo cp geckodriver /usr/local/bin/

sudo pip install denarius

Bitcoin values

The function ticker_Bitcoin returns data of the following form:

{'volume': 2050.1665002833397, 'last': 992.2553834529656, 'timestamp': 1487551580.0, 'bid': 991.8303740083114, 'vwap': 993.3415187004156, 'high': 1002.9278428409522, 'low': 981.3656970154892, 'ask': 992.2553834529656, 'open': 993.3887419720438}

It accesses data from Bitstamp.

feature description
last last Bitcoin price
high last 24 hours price high
low last 24 hours price low
vwap last 24 hours volume weighted average price
volume last 24 hours volume
bid highest buy order
ask lowest sell order
timestamp UNIX timestamp date and time
open first price of the day

The function data_historical_Bitcoin returns by default data of the following form:

{'bpi': {'2017-02-17': 992.1077, '2017-02-16': 969.2414, '2017-02-15': 952.6512, '2017-02-14': 954.1432, '2017-02-13': 940.7982, '2017-02-12': 940.1764, '2017-02-11': 949.3397, '2017-02-10': 933.4325, '2017-02-19': 991.254, '2017-02-18': 997.0854}, 'time': {'updated': 'Feb 20, 2017 00:20:08 UTC', 'updatedISO': '2017-02-20T00:20:08+00:00'}, 'disclaimer': 'This data was produced from the CoinDesk Bitcoin Price Index. BPI value data returned as EUR.'}

With the option return_list, it returns data of the following form:

[['2017-02-10', 933.4325], ['2017-02-11', 949.3397], ['2017-02-12', 940.1764], ['2017-02-13', 940.7982], ['2017-02-14', 954.1432], ['2017-02-15', 952.6512], ['2017-02-16', 969.2414], ['2017-02-17', 992.1077], ['2017-02-18', 997.0854], ['2017-02-19', 991.254]]

With the option return_UNIX_times, it returns data of the following form:

[[1486684800, 933.4325], [1486771200, 949.3397], [1486857600, 940.1764], [1486944000, 940.7982], [1487030400, 954.1432], [1487116800, 952.6512], [1487203200, 969.2414], [1487289600, 992.1077], [1487376000, 997.0854], [1487462400, 991.254]]

LocalBitcoins

LocalBitcoins data is available via its API. For example, the following URL gives data on current trades in GBP available by national bank transfer:

The data returned by the API is of a form like this.

The function values_Bitcoin_LocalBitcoin returns the price values returned by calling the API in this way.

import denarius
denarius.values_Bitcoin_LocalBitcoin()

The script loop_save_LocalBitcoins_values_to_database.py loop records LocalBitcoins data to database. To address closed gateways arising from repeat calls, the script could be used in a way like the following:

while true; do
    loop_save_LocalBitcoins_values_to_database.py --timeperiod=3600
    sleep 5400
done

databases

A database of Bitcoin values can be saved in the following ways:

import denarius
denarius.save_database_Bitcoin(filename = "database.db")
import denarius
denarius.save_database_Bitcoin(filename = "database_Bitcoin_EUR.db", currency = "EUR")
denarius.save_database_Bitcoin(filename = "database_Bitcoin_GBP.db", currency = "GBP")

graphs

The function save_graph_Bitcoin creates a graph of Bitcoin historical values over a specified time. The function save_graph_LocalBitcoins creates a graph of LocalBitcoins Bitcoin lowest prices in GBP as recorded in a database by the script loop_save_LocalBitcoins_values_to_database.py.

denarius_graph_Bitcoin

The script denarius_graph_Bitcoin.py displays a PyQt GUI with a graph of the last Bitcoin values.

denarius_graph_Bitcoin.py --help
denarius_graph_Bitcoin.py
denarius_graph_Bitcoin.py --currency=EUR --days=100

LocalBitcoins

A graph can be generated of Bitcoin GBP value versus LocalBitcoins GBP lowest value:

import denarius
denarius.save_graph_Bitcoin_LocalBitcoins()

A graph can be generated of Bitcoin GBP value versus LocalBitcoins GBP lowest 5 values:

import denarius
denarius.save_graphs_Bitcoin_LocalBitcoins()

A graph can be generated of LocalBitcoins normalized prices over days:

A graph can be generated of LocalBitcoins normalized prices over weeks:

A graph can be generated of LocalBitcoins non-normalized prices over weeks:

Bollinger bands

KanoPool

KanoPool records for addresses can be recorded to CSV in a way like the following:

denarius_loop_save_KanoPool.py --help

denarius_loop_save_KanoPool.py --addresses=1Miner7R28PKcTRbEDwQt4ykMinunhTehs --interval=10

The CSV data can be analysed using the Jupyter Notebook KanoPool.ipynb.

Slush Pool

Slush Pool records for an address can be recorded to CSV in a way like the following:

denarius_loop_save_SlushPool.py --help

denarius_loop_save_SlushPool.py --addresses=1Miner7R28PKcTRbEDwQt4ykMinunhTehs --interval=60 --alarm=11800000 --slushloginname=user --slushworkername=worker1

The CSV fields are, in order, as follows:

  • address
  • hash rate
  • shares
  • UNIX timestamp
  • unconfirmed reward in Bitcoin
  • confirmed reward in Bitcoin
  • total reward (confirmed + unconfirmed) in Bitcoin
  • total payout since script launch in Bitcoin
  • number of blocks found since script launch

The CSV data can be analysed using the Jupyter Notebook SlushPool.ipynb.

RBS

The RBS module provides utilities for getting the balance and recent transactions of an RBS account using the RBS banking web interface, Selenium and Firefox. For convenience, account details can be stored in a credentials file, which is assumed by default to be ~/.rbs. The account code is an alphanumeric code extracted from the web interface. The content of a credentials file is of the following form, which is Python code:

customer_number = "XXXXXXXXXX"
PIN             = "XXXXXX"
passcode        = "XXXXXXXXXXXXXXXXXXXX"
account_code    = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

A dictionary of the current balance and a pandas DataFrame of recent transactions is returned by the function RBS.account_status.

import RBS

status  = RBS.account_status()
balance = status["balance"]
df      = status["transactions"]

The DataFrame features the fields date, description and amount. A transaction containing a certain reference or description could be selected in the following way:

df[df["description"].str.contains("transaction reference 123")]

The existence of a transaction can be tested in a way like the following:

if df[df["description"].str.contains("transaction reference 123")].values.any():

    print("transaction found")

else:

    print("transaction not found")

The script get_account_balance_RBS.py is available to open an RBS account web interface and to display the current balance and recent transactions in the terminal, optionally in a loop.

get_account_balance_RBS.py --loop

The script detect_transaction_RBS.py is available to search for a transaction or transactions with a specified reference.

detect_transaction_RBS.py --reference=123

arbitrage

The script loop_save_arbitrage_data_Kraken_LocalBitcoins_UK.py records data for arbitrage between Kraken and LocalBitcoins UK.

The script loop_display_arbitrage_data.py is available for display of recorded data and current prices for arbitrage between Kraken and LocalBitcoins UK.

paper wallets for Bitcoin, QR codes of keys

The script create_QR_codes_of_public_and_private_keys.py creates a QR code for a specified public key and private key and enables optional specification of the size of the resulting PNG images. It loads the keys from a Python file (keys.py by default) which defines the string variables key_public and key_private.

The script create_paper_wallet.py creates a QR code for a specified public key and private key. It then creates an image of a Bitcoin paper wallet. It loads the keys from a Python file (keys.py by default) which defines the string variables key_public and key_private.

Project details


Release history Release notifications

History Node

2018.6.17.613

History Node

2018.6.3.1905

History Node

2018.6.3.1902

History Node

2018.6.3.1854

History Node

2018.6.3.1848

History Node

2018.5.3.1919

History Node

2018.4.19.2327

History Node

2018.4.18.547

History Node

2018.4.16.1225

History Node

2018.4.16.34

History Node

2018.4.15.2324

History Node

2018.4.15.2226

History Node

2018.4.15.214

History Node

2018.4.6.1611

History Node

2018.4.5.2347

History Node

2018.4.5.2217

History Node

2018.4.4.1650

History Node

2018.4.4.1419

History Node

2018.4.4.1401

History Node

2018.4.3.2341

History Node

2018.4.3.2119

History Node

2018.3.25.2227

History Node

2018.3.13.2151

History Node

2018.3.8.42

History Node

2018.3.2.244

History Node

2018.2.7.53

History Node

2018.2.6.1956

History Node

2018.1.31.1732

History Node

2018.1.31.1721

History Node

2018.1.31.24

History Node

2018.1.30.2238

History Node

2018.1.26.536

History Node

2018.1.26.310

History Node

2018.1.25.2013

History Node

2018.1.25.135

History Node

2018.1.23.1907

History Node

2018.1.23.1820

History Node

2018.1.23.1815

History Node

2018.1.23.1644

History Node

2018.1.23.11

History Node

2018.1.21.227

History Node

2018.1.20.2345

History Node

2018.1.20.2227

History Node

2018.1.20.2215

History Node

2018.1.18.1452

History Node

2018.1.16.2213

History Node

2018.1.14.2009

History Node

2018.1.14.3

This version
History Node

2018.1.13.1931

History Node

2018.1.12.2154

History Node

2018.1.5.1727

History Node

2017.12.25.2154

History Node

2017.12.21.1910

History Node

2017.11.29.1856

History Node

2017.11.28.1853

History Node

2017.10.18.1930

History Node

2017.7.10.1020

History Node

2017.7.10.1019

History Node

2017.7.9.108

History Node

2017.7.7.1543

History Node

2017.6.29.1658

History Node

2017.6.21.1952

History Node

2017.6.21.1942

History Node

2017.6.21.1935

History Node

2017.6.13.1607

History Node

2017.5.30.1701

History Node

2017.5.11.1551

History Node

2017.5.11.1148

History Node

2017.4.18.1308

History Node

2017.3.17.1555

History Node

2017.3.14.1606

History Node

2017.3.14.55

History Node

2017.3.8.1411

History Node

2017.3.7.2350

History Node

2017.3.7.1840

History Node

2017.2.20.1919

History Node

2017.2.20.1911

History Node

2017.1.20.21

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
denarius-2018.1.13.1931.tar.gz (192.4 kB) Copy SHA256 hash SHA256 Source None Jan 13, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page