Giter VIP home page Giter VIP logo

ccxt-websockets-db-updater's Introduction

CCXT websockets DB updater

A Python 3 command line program to subscribe cryptocurrency exchanges websockets and save order books in real time in a database.

YouTube Demo

This project is based on CCXT lfern/websockets-multiple fork.

To speed up installation, as the CCXT repository is huge and takes a long time to download, I created a repository containing just the transpiled files from lfern's branch: https://github.com/firepol/ccxt-websockets When the branch will be forked in the official CCXT project, this temporary branch won't be needed anymore.

Credits for the websockets implementations: lfern and his collaborators.

If you are looking for an alternative in Java, check my other similar project: Cryptows.

Installation

# Clone this repository
git clone https://github.com/firepol/ccxt-websockets-db-updater.git

# Enter the repository dir
cd ccxt-websockets-db-updater

# Create a `data` directory (needed to store exchange settings and websockets you want to subscribe to)
mkdir data

# Copy the sample settings.ini into data/
cp samples/settings.ini data/

# Create a python 3.6 virtual environment
virtualenv -p /usr/bin/python3.6 env

# Activate the python virtual environment
source ~/env/ccxtws/bin/activate

# Install all required dependencies
pip install -r requirements.txt

Update

To get the latest updates from https://github.com/firepol/ccxt-websockets:

# Unintall the old version of CCXT
pip uninstall ccxt

# Get all missing dependencies (this will fetch the latest CCXT version linked in requirements.txt)
pip install -r requirements.txt

Quick start

Note: If you are using Windows the python commands written in this document may not work for you. In that case just call the command prefixed with python, like this:

python script_name.py

Inside the repo, you can run this command to get an overview of all the command line parameters:

./ob_tester.py -h

Then test the BTC/USDT websocket connection to binance:

./ob_tester.py -e binance -s ETH/BTC --verbose

Configuration

First of all, copy samples/settings.ini to data/settings.ini.

[config]: this is the main configuration section.

db_url: database connection string.

Examples:

  • PostgreSQL: postgres://postgres:postgres@localhost:5432/cryptows
  • SQLite: sqlite:///cryptows.db

order_book_entries: (by default: 1) limit of order books to fetch (e.g. 5 means 5 bids and 5 asks).

Exchanges and pairs you want to fetch:in square brackets write the exchange name, in the following line insert a list of symbols, as follows:

[bitstamp]
symbols: ETH/BTC
         BTC/USD
         ETH/USD

You can comment (with ";" at the beginning of the line) sections and single lines, e.g.:

[bitstamp]
symbols: ETH/BTC
;         BTC/USD
         ETH/USD

Some exchanges (like cex.io) need to be authenticated via api key / secret. Add your api keys in the data/exchange_api_keys.json file (you find a template in the samples folder).

Usage

The usage of the websocket database updater is quite straightforward:

./ob_updater.py

The program checks the exchanges configured in the data/settings.ini file and creates a websocket connection for each pair.

Add --debug to see when an order book update occurs.
Add --verbose to see the order book update values. Add --reset_db to delete all records in the order_book table before subscribing the websockets.

License

MIT License

ccxt-websockets-db-updater's People

Contributors

firepol avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.