Skip to content
This repository has been archived by the owner on Jan 16, 2020. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
June 8, 2017 00:30
June 8, 2017 00:30
June 8, 2017 00:30
January 15, 2013 12:34
June 8, 2017 00:30
June 8, 2017 00:30
March 17, 2013 21:53
January 15, 2020 10:10
June 8, 2017 00:30
June 8, 2017 00:30
June 8, 2017 00:30
June 8, 2017 00:30
May 20, 2013 23:52
June 8, 2017 00:30
June 8, 2017 00:30
June 8, 2017 00:30

prometheus-api travis


Prometheus-API is the Flask (About Flask) powered RESTful API behind Prometheus (About Prometheus).


Prometheus-API has been tested and known to work on the following configurations:

  • MacOS X 10.9.5
  • Ubuntu 14.04 LTS
  • Python 2.7, 3.5, and 3.6


Flask Extensions

Production Server

Quick Start

Clone the repo

git clone

Install requirements

cd prometheus-api
pip install -r base-requirements.txt

Run API server

manage serve

Now view the API documentation at http://localhost:5000


Prometheus-API comes with a built in script manager Use it to start the server, run tests, and initialize the database.


manage <command> [command-options] [manager-options]


Start server

manage serve

Run tests

manage test

Run linters

manage lint

Initialize the dev database

manage initdb

Populate the production database

manage popdb -m Production

Manager options

-m MODE, --cfgmode=MODE  set the configuration mode, must be one of
                         ['Production', 'Development', 'Test'] defaults
                         to 'Development'. See `` for details
-f FILE, --cfgfile=FILE  set the configuration file (absolute path)


checkstage  Checks staged with git pre-commit hook
cleardb     Removes all content from database
createdb    Creates database if it doesn't already exist
initdb     Removes all content from database and creates new tables
serve   Runs the Flask development server i.e.
runtests    Run nose tests
shell       Runs a Python shell inside Flask application context.

Command options

Type manage <command> -h to view any command's options

manage manage serve -h
usage: manage serve [-h] [-t HOST] [-p PORT] [--threaded]
                             [--processes PROCESSES] [--passthrough-errors]
                             [-d] [-r]

Runs the Flask development server i.e.

optional arguments:
  -h, --help              show this help message and exit
  -t HOST, --host HOST
  -p PORT, --port PORT
  --processes PROCESSES
  -d, --no-debug
  -r, --no-reload


Start production server on port 1000

manage serve -p 1000 -m Production


Config Variables

The following configurations settings are available in

variable description default value
__YOUR_EMAIL__ your email address <user>
API_METHODS allowed HTTP verbs ['GET', 'POST', 'DELETE', 'PATCH', 'PUT']
API_ALLOW_FUNCTIONS allow sqlalchemy function evaluation TRUE
API_ALLOW_PATCH_MANY allow patch requests to effect all instances of a given resource TRUE
API_MAX_RESULTS_PER_PAGE the maximum number of results returned per page 1000
API_URL_PREFIX string to prefix each resource in the api url ''

See the Flask-Restless docs for a complete list of settings.

Environment Variables

Prometheus-API will reference the SECRET_KEY environment variable in if it is set on your system.

To set this environment variable, do the following:

echo 'export SECRET_KEY=value' >> ~/.profile


For a list of available resources, example requests and responses, and code samples, view the online documentation. View the Flask-Restless guide for more request/response examples and directions on making search queries.


The Prometheus API is separated into different services, each responsible for performing a specific set of tasks.

service description
Hermes price/event data aggregate
Cronus portfolio performance analytics and allocation engine
Icarus portfolio risk profiler (coming soon)
Oracle random portfolio generator (coming soon)
Lynx portfolio x-ray engine (coming soon)
Rosetta 3rd party portfolio data converter (coming soon)

Advanced Installation

Virtual environment setup

Ideally, you should install python modules for every project into a virtual environment. This setup will allow you to use different versions of the same module in different projects without worrying about adverse interactions.

sudo pip install virtualenv virtualenvwrapper

Add the following to your ~/.profile

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/

Create your new API virtualenv

cd prometheus-api
mkvirtualenv --no-site-packages prometheus-api
sudo easy_install pip
sudo pip install -r base-requirements.txt

Production Server

Getting Gevent up and running is a bit tricky so follow these instructions carefully.

To use gevent, you first need to install libevent.


apt-get install libevent-dev

Mac OS X via homebrew

brew install libevent

Mac OS X via macports

sudo port install libevent

Mac OS X via DMG

download on Rudix

Now that libevent is handy, install the remaining requirements

sudo pip install -r requirements.txt

Or via the following if you installed libevent from macports

sudo CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent
sudo pip install -r requirements.txt

Finally, install foreman

sudo gem install foreman

Now, you can run the application locally

foreman start

You can also specify what port you'd prefer to use

foreman start -p 5555


If you haven't signed up for Heroku, go ahead and do that. You should then be able to add your SSH key to Heroku, and also heroku login from the commandline.

Install heroku and create your app

sudo gem install heroku
heroku create -s cedar app_name

Add the database

heroku addons:add heroku-postgresql:dev

Push to Heroku and initialize the database

git push heroku master
heroku run python createdb -m Production

Start the web instance and make sure the application is up and running

heroku ps:scale web=1
heroku ps

Now, we can view the application in our web browser

heroku open

And anytime you want to redeploy, it's as simple as git push heroku master. Once you are done coding, deactivate your virtualenv with deactivate.

Directory Structure

tree . | sed 's/+----/├──/' | sed '/.pyc/d' | sed '/.DS_Store/d'
     ├──Procfile                        (heroku process)
     ├──README.rst                      (this file)
     |    ├──                (main app module)
     |    ├──                  (manager/test helper functions)
     |    ├──LICENSE
     |    ├──                (pypi includes)
     |    ├──models
     |    |    ├──
     |    |    ├──             (portfolio analytics engine models)
     |    |    ├──             (price/event data aggregator models)
     |    ├──README.rst                 (symlink for pypi)
     |    ├──                   (pypi settings)
     |    ├──tests
     |         ├──           (main tests module)
     |         ├──standard.rc           (pylint config)
     |         ├──               (git pre-commit hook)
     |         ├──        (hermes model tests)
     |         ├──          (site tests)
     ├──app.db                          (app development database)
     ├──                       (app config)
     ├──                       (flask-script)
     ├──requirements.txt                (python module requirements)
     ├──runtime.txt                     (python version)
     ├──schema.png                      (database relationship model)
     ├──setup.cfg                       (unit test settings)


First time

  1. Fork
  2. Clone
  3. Code (if you are having problems committing because of git pre-commit hook errors, just run manage checkstage to see what the issues are.)
  4. Use tabs not spaces
  5. Add upstream git remote add upstream
  6. Rebase git rebase upstream/master
  7. Test manage runtests
  8. Push git push origin master
  9. Submit a pull request


  1. Code (if you are having problems committing because of git pre-commit hook errors, just run manage checkstage to see what the issues are.)
  2. Use tabs not spaces
  3. Update upstream git fetch upstream
  4. Rebase git rebase upstream/master
  5. Test manage runtests
  6. Push git push origin master
  7. Submit a pull request


git shortlog -sn
commits: 430
  430  Reuben Cummings

About Prometheus

Prometheus tells you how your stock portfolio has performed over time, gives insight into how to optimize your asset allocation, and monitors your portfolio for rebalancing or performance enhancing opportunities.

About Flask

Flask is a BSD-licensed microframework for Python based on Werkzeug, Jinja2 and good intentions.


Prometheus API is distributed under the BSD License, the same as Flask on which this program depends.