https://github.com/polakowo/plnx-grabber
Grabber of trade history from Poloniex exchange
https://github.com/polakowo/plnx-grabber
grabber poloniex trade-history
Last synced: 3 months ago
JSON representation
Grabber of trade history from Poloniex exchange
- Host: GitHub
- URL: https://github.com/polakowo/plnx-grabber
- Owner: polakowo
- License: gpl-3.0
- Created: 2017-09-10T09:32:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-16T19:30:49.000Z (almost 8 years ago)
- Last Synced: 2025-05-07T10:52:14.867Z (5 months ago)
- Topics: grabber, poloniex, trade-history
- Language: Python
- Homepage:
- Size: 287 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```python
import plnxgrabber
from pymongo import MongoClient
import logginglogging.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 loggerclient = 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:
```python
grabber.remote_info(['USDT_BTC', 'USDT_ETH', 'USDT_LTC', 'USDT_BCH])
```Get information on pairs stored locally:
```python
grabber.db_info()
```Get progress of currently stored history relative to overall available on Poloniex:
```python
grabber.progress()
```### Grab one pair
To collect trade history for a single pair, use `Grabber.one()`
Collect the entire history:
```python
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:
```python
from datetime import datetime
import pytzfrom_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:
```python
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 recordCollect everything below the oldest record in the collection (backward):
```python
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):
```python
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:
```python
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:
```python
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 RegexFor each pair in the current ticker, collect the last 5 minutes:
```python
grabber.row('ticker', from_dt=plnxgrabber.ago(minutes=5))
```Recollect each collection:
```python
grabber.row('db', from_dt='oldest', to_dt='newest', drop=True)
```For each ETH pair, collect the last minute:
```python
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:
```python
grabber.ring(["USDT_BTC", "USDT_ETH"], every=60)
```Update continuously:
```python
grabber.ring(["USDT_BTC", "USDT_ETH"])
```Continue updating all collections:
```python
grabber.ring('db')
```