Git Product home page Git Product logo

plnx-grabber's Introduction

plnx-grabber

Transfer trade history from Poloniex into a local MongoDB database

  • Every pair and time period
  • Chunk wise without using much RAM
  • One time, multiple times or continuous
  • Smart outputs on history available on Poloniex as well as locally

Installation

pip install https://github.com/polakowo/plnx-grabber/archive/master.zip

Setup

import plnxgrabber
from pymongo import MongoClient
import logging

logging.basicConfig(format='%(asctime)s - %(name)s - %(funcName)s() - %(levelname)s - %(message)s',
                    datefmt='%d/%m/%Y %H:%M:%S',
                    level=logging.INFO)
# or your preferred logger

client = MongoClient('localhost:27017')
db = client['TradeHistory']
mongo_ts = plnxgrabber.MongoTS(db)
grabber = plnxgrabber.Grabber(mongo_ts)

Usage

General

Get information on history available on Poloniex:

grabber.remote_info(['USDT_BTC', 'USDT_ETH', 'USDT_LTC', 'USDT_BCH])

Get information on pairs stored locally:

grabber.db_info()

Get progress of currently stored history relative to overall available on Poloniex:

grabber.progress()

Grab one pair

To collect trade history for a single pair, use Grabber.one()

Collect the entire history:

grabber.one('USDT_BCH')

# or grabber.one('USDT_BCH', from_dt=plnxgrabber.begin(), to_dt=plnxgrabber.now())

Collect the history between 1/9/2017 12:00:00 to 1/9/2017 18:00:00:

from datetime import datetime
import pytz

from_dt = datetime(2017, 9, 1, 12, 0, 0, tzinfo=pytz.utc)
to_dt = datetime(2017, 9, 1, 18, 0, 0, tzinfo=pytz.utc)
grabber.one('USDT_BTC', from_dt=from_dt, to_dt=to_dt)

Collect the last hour:

grabber.one('USDT_BTC', from_dt=plnxgrabber.ago(hours=1))

# or grabber.one('USDT_BTC', from_dt=plnxgrabber.ago(hours=1), to_dt=plnxgrabber.now())
  • If collection not empty, it gets extended
  • Use oldest to auto-fill the timestamp of the oldest record in the collection
  • Use newest to auto-fill the timestamp of the youngest record

Collect everything below the oldest record in the collection (backward):

grabber.one('USDT_BTC', to_dt='oldest')

# or grabber.one('USDT_BTC', from_dt=plnxgrabber.begin(), to_dt='oldest')

Collect everything above the newest record in the collection (forward):

grabber.one('USDT_BTC', from_dt='newest')

# or grabber.one('USDT_BTC', from_dt='newest', to_dt=plnxgrabber.now())

Drop currently stored pair and recollect:

grabber.one('USDT_BCH', from_dt='oldest', to_dt='newest', drop=True)

Grab row of pairs

To collect trade history for a row of pairs, use Grabber.row()

For the following 4 pairs, collect the history from 1/9/2017 12:00:00 to 1/9/2017 18:00:00:

from_dt = datetime(2017, 9, 1, 12, 0, 0, tzinfo=pytz.utc)
to_dt = datetime(2017, 9, 1, 18, 0, 0, tzinfo=pytz.utc)
grabber.row(['USDT_BTC', 'USDT_ETH', 'USDT_LTC', 'USDT_BCH'], from_dt=from_dt, to_dt=to_dt)
  • Pass 'ticker' instead of pair to perform an action on all pairs traded on Poloniex
  • Pass 'db' to perform an action on all pairs stored locally
  • Or use Regex

For each pair in the current ticker, collect the last 5 minutes:

grabber.row('ticker', from_dt=plnxgrabber.ago(minutes=5))

Recollect each collection:

grabber.row('db', from_dt='oldest', to_dt='newest', drop=True)

For each ETH pair, collect the last minute:

grabber.row(r'(ETH_+)', from_dt=plnxgrabber.ago(minutes=1))

Update row of pairs

To constantly collect the most recent records for a row of pairs, use Grabber.ring()

Keep updating a row of pairs every 60 sec:

grabber.ring(["USDT_BTC", "USDT_ETH"], every=60)

Update continuously:

grabber.ring(["USDT_BTC", "USDT_ETH"])

Continue updating all collections:

grabber.ring('db')

plnx-grabber's People

Contributors

polakowo avatar

Watchers

James Cloos 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.