Skip to content
Browse files

much improved README

  • Loading branch information
stnbu committed Sep 19, 2018
1 parent 8171e66 commit 0fbe8e77ce5e722cf3a602cfc06452dbbf6e66c9
Showing with 118 additions and 4 deletions.
  1. +118 −4
@@ -1,6 +1,120 @@

The idea is simple: periodically fetch price stuff via an API, store it in a local db, generate SVG graphs graphing the price over time.
# coincharts

This is "for fun". There are better implementations of this kind of thing out there.

[`coincharts`]( is a Django app that displays the normalized value of Ethereum (in US Dollars), vs the average of the normalized price of a "basket" of others. Price information is fetched from ever six hours (for now), using their REST API.

A daemon that fetches and stores data locally is included.

You can see it in action here:

## Usage/Installation

### Installation

Install the package as you would any other python package

pip install git+

Requirements are _not_ handled automatically. You can install them with

pip install -r /path/to/coincharts/requirements.txt

### API

If you have not already, sign up for and acquire a authentication token [here](

Create a file at `~/.coincharts/API_KEY` with your key.

Of course this file should be readable by the daemon but *security is up to you*. Be careful out there.

### Database changes

Prepare your database schema by running the Django migration tool.

```bash makemigrations coincharts && python migrate

(Don't forget to backup your data first!)

### Run the daemon

The daemon _requires_ the presence of the `DJANGO_SETTINGS_MODULE` environment variable. Set it to the name of your site's setting's module (the same value that Django calculates/expects). Note that this is the _module's name_, not its path.

DJANGO_SETTINGS_MODULE='my_site.settings' coincharts-daemon --daemon /some/path

A PID file and a log file will be written to `/some/path` (syslog is used also but may not work on all platforms.) This directory need not be special in any way other than be writable by the user running `coincharts-daemon`.

You may wish to do something fancy like have the web server launch and manage this daemon, although this probably has some security implications. Contributions welcome.

### Modify your ``

A good start would be:

import svg_graph
def index(request):
# this is the totally intuitive way of getting the ISO8601 formatted date for one week ago UTC
one_week_ago = datetime.datetime.fromtimestamp(
time.time() - 7 * 24 * 60 * 60,
symbols = config['history_symbols']
comparison = SymbolComparison()
for symbol in symbols:
comparison[symbol] = SymbolInfo(symbol, since=one_week_ago)
history_generator = comparison.normalized_history_averages()
eth = comparison.pop('BITSTAMP_SPOT_ETH_USD')
graph = svg_graph.LineGraph(
title='Price history averages',
svg_graph.Points(eth.normalized_history, color='green'),
svg_graph.Points(history_generator, color='black'),
context = {
'graph': graph.to_xml(),
return render(request, 'coincharts/index.html', context)

### Modifying your template

In the `<head>` place a conditional to include the CSS

{% if graph %}
<link rel="stylesheet" type="text/css" href="{% static 'coincharts/style.css' %}">
{% endif %}

Include the `coincharts` template in the body of _your_ template where appropriate

{% if graph %}
{% graph|safe %}
{% endif %}

Known issues, limitations

* _You_ must run the daemon. You may wish to use your OS's "supervisor" or similar.
* Records are never updated, so if a commit or a repository description changes for example, you'll need to go and delete the corresponding row yourself.
* It's not very pluggable for a "plug-in" (contributions welcome!)
* You must set `myapp.settings.TEMPLATES['APP_DIRS']=True` or work out access to the template yourself.
* I've had all kinds of problems with syslog. It would be great if it "just worked".
* Automating some install stuff would be nice.
* The daemon requires the presence of the DJANGO_SETTINGS_MODULE environment variable. There might be better ways...

0 comments on commit 0fbe8e7

Please sign in to comment.