Metadata-Version: 2.1
Name: fundcrunch
Version: 0.1.1
Summary: The Fundcrunch.Tech library for market data processing in real time or on history.
Home-page: https://github.com/fundcrunch-tech/fundcrunch_py
Author: Sergey Bryukov
Author-email: hello@fundcrunch.tech
License: MIT
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: requests
Requires-Dist: websockets
Requires-Dist: ccxt
Requires-Dist: pyzmq
Requires-Dist: pandas

# Fundcrunch library

* connect directly to various exchanges and bind they stream into single local socket endpoint
* connector to Fundcrunch.Tech data streaming socket and REST endpoints

## Installation

```bash
$ pip install fundcrunch
```

## Install from source

```bash
$ git clone git@github.com:fundcrunch-tech/fundcrunch_py.git
$ cd fundcrunch_py
```


```bash
$ python3.7 -m venv .venv
$ source .venv/bin/activate
$ python setup.py install
```

```bash
$ cd examples
$ python feeder.py
```

## Streaming

```python
import json
from fundcrunch import Feeder

feeder_conf = { 'port': [9001, 8010, 7001],
               'addr': '0.0.0.0',
               'exchanges': [{'name': 'binance',
                              'pairs': ['BTC/USDT'],
                              'mode': ['order_book', 'trades', 'ohlc']}]
             }

subscribe = ['ohlc-binance-BTC_USDT',
             'ob-binance-BTC_USDT',
             'trade-binance-BTC_USDT',]

feeder = Feeder(config=feeder_conf, subscribe=subscribe)
feeder.start()

while True:
  rcv = feeder.output.get()
  topic, payload = rcv.split(b'@',1)
  print(topic, json.loads(payload).keys())

```

## History

```python
from fundcrunch.utils import History

exhanges = ['binance', 'bittrex']
ohlc = ['1h', '1d']

history = History()

for i in exhanges:
    for j in ohlc:
        history.update_ohlc(i, j, ['BTC/USDT'])

for i in history.exchanges():
    markets = history.exchange_symbols(i)
    print('binance', markets)

symbol =  history.get_symbol('binance', 'BTC/USDT')
print(symbol['ohlc']['1d'].tail())
print(symbol['ohlc']['1h'].tail())
```

