Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoscon committed Mar 17, 2020
1 parent c4bce66 commit 4e5704e
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 28 deletions.
1 change: 0 additions & 1 deletion cryptofeed/backends/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Please see the LICENSE file for the terms and conditions
associated with this software.
'''
import time
from decimal import Decimal

from cryptofeed.defines import BID, ASK
Expand Down
2 changes: 1 addition & 1 deletion cryptofeed/backends/influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, addr: str, db=None, key=None, create_db=True, numeric_type=st
token: str (For InfluxDB 2.0 compatibility)
Token string for authentication
precision: str (For InfluxDB 2.0 compatibility)
Precision level among (s, ms, us, ns)
Precision level among (s, ms, us, ns)
"""
super().__init__(addr, **kwargs)
if org and bucket and token:
Expand Down
1 change: 0 additions & 1 deletion cryptofeed/backends/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
associated with this software.
'''
from datetime import datetime as dt
from decimal import Decimal
import json

import asyncpg
Expand Down
3 changes: 1 addition & 2 deletions cryptofeed/exchange/binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Please see the LICENSE file for the terms and conditions
associated with this software.
'''
import asyncio
import json
import logging
from decimal import Decimal
Expand All @@ -15,7 +14,7 @@

from cryptofeed.feed import Feed
from cryptofeed.defines import TICKER, TRADES, BUY, SELL, BID, ASK, L2_BOOK, BINANCE
from cryptofeed.standards import pair_exchange_to_std, timestamp_normalize, feed_to_exchange
from cryptofeed.standards import pair_exchange_to_std, timestamp_normalize


LOG = logging.getLogger('feedhandler')
Expand Down
6 changes: 3 additions & 3 deletions cryptofeed/exchange/upbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def _ticker(self, msg: dict, timestamp: float):
'its': False,
'l52wdt': '2019-03-17',
'l52wp': 4384000.0,
'ms': 'ACTIVE', // Market Status 'ACTIVE' or
'ms': 'ACTIVE', // Market Status 'ACTIVE' or
'msfi': None,
'mw': 'NONE', // Market warning 'NONE' or
'scp': -81000.0,
Expand Down Expand Up @@ -189,10 +189,10 @@ async def subscribe(self, websocket):
Examples (Note that the positions of the base and quote currencies are swapped.)
1. In order to get TRADES of "BTC-KRW" and "XRP-BTC" markets.
1. In order to get TRADES of "BTC-KRW" and "XRP-BTC" markets.
> [{"ticket":"UNIQUE_TICKET"},{"type":"trade","codes":["KRW-BTC","BTC-XRP"]}]
2. In order to get ORDERBOOK of "BTC-KRW" and "XRP-BTC" markets.
2. In order to get ORDERBOOK of "BTC-KRW" and "XRP-BTC" markets.
> [{"ticket":"UNIQUE_TICKET"},{"type":"orderbook","codes":["KRW-BTC","BTC-XRP"]}]
3. In order to get TRADES of "BTC-KRW" and ORDERBOOK of "ETH-KRW"
Expand Down
22 changes: 11 additions & 11 deletions examples/demo_influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ def main():
f.add_feed(Coinbase(channels=[L2_BOOK], pairs=['BTC-USD'], callbacks={L2_BOOK: BookInflux('http://localhost:8086', 'example', numeric_type=float), BOOK_DELTA: BookDeltaInflux('http://localhost:8086', 'example', numeric_type=float)}))
f.add_feed(Coinbase(channels=[TICKER], pairs=['BTC-USD'], callbacks={TICKER: TickerInflux('http://localhost:8086', 'example', numeric_type=float)}))

"""
"""
# Uncomment Here When Using InfluxDB 2.0
# For InfluxDB 2.0, provide additional org, bucket(instead of db), token and precision(optional)
# [Note] In order to use visualization and aggregation, numeric_type with float is strongly recommended.
# For InfluxDB 2.0, provide additional org, bucket(instead of db), token and precision(optional)
# [Note] In order to use visualization and aggregation, numeric_type with float is strongly recommended.
ADDR = 'https://localhost:9999'
ORG='my-org'
BUCKET = 'my-bucket'
TOKEN = 'token-something-like-end-with-=='
f = FeedHandler()
funding_influx = FundingInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
trade_influx = TradeInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
book_influx = BookInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
bookdelta_influx = BookDeltaInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
ticker_influx = TickerInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
funding_influx = FundingInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
trade_influx = TradeInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
book_influx = BookInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
bookdelta_influx = BookDeltaInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
ticker_influx = TickerInflux(ADDR, org=ORG, bucket=BUCKET, token=TOKEN, numeric_type=float)
f.add_feed(Bitmex(channels=[FUNDING, L2_BOOK],pairs=['XBTUSD'], callbacks={FUNDING: funding_influx, L2_BOOK: book_influx, BOOK_DELTA: bookdelta_influx}))
f.add_feed(Coinbase(channels=[TRADES], pairs=['BTC-USD'], callbacks={TRADES: trade_influx}))
f.add_feed(Coinbase(channels=[L2_BOOK], pairs=['BTC-USD'], callbacks={L2_BOOK: book_influx, BOOK_DELTA: bookdelta_influx}))
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_pair_separator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cryptofeed.callback import TickerCallback, TradeCallback, BookCallback
from cryptofeed import FeedHandler
from cryptofeed.exchanges import Coinbase, Gemini
from cryptofeed.defines import TRADES, TICKER, COINBASE, GEMINI, L2_BOOK, L3_BOOK, BID, ASK
from cryptofeed.defines import TRADES, TICKER, COINBASE, L2_BOOK, L3_BOOK, BID, ASK
from cryptofeed.pairs import set_pair_separator


Expand Down
5 changes: 2 additions & 3 deletions examples/demo_rabbitmq.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from multiprocessing import Process
import json

from cryptofeed import FeedHandler
from cryptofeed.backends.rabbitmq import BookRabbit, TradeRabbit
from cryptofeed.backends.rabbitmq import BookRabbit
from cryptofeed.exchanges import Kraken
from cryptofeed.defines import L2_BOOK, TRADES
from cryptofeed.defines import L2_BOOK


def callback(ch, method, properties, body):
Expand Down
6 changes: 3 additions & 3 deletions examples/demo_upbit.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from cryptofeed.callback import TradeCallback, BookCallback, TickerCallback
from cryptofeed.callback import TradeCallback, BookCallback
from cryptofeed import FeedHandler

from cryptofeed.exchanges import Bybit, Upbit
from cryptofeed.defines import TRADES, L2_BOOK, BID, ASK, TICKER
from cryptofeed.exchanges import Upbit
from cryptofeed.defines import TRADES, L2_BOOK, BID, ASK


async def trade(feed, pair, order_id, timestamp, side, amount, price, receipt_timestamp):
Expand Down
3 changes: 1 addition & 2 deletions examples/demo_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
from cryptofeed import FeedHandler
from cryptofeed.exchanges import Kraken, Coinbase

from cryptofeed.defines import L2_BOOK, TRADES, TICKER
from cryptofeed.defines import L2_BOOK, TICKER


def receiver(port):
import zmq
import time
addr = 'tcp://127.0.0.1:{}'.format(port)
ctx = zmq.Context.instance()
s = ctx.socket(zmq.SUB)
Expand Down

0 comments on commit 4e5704e

Please sign in to comment.