Пример #1
0
def main():
    f = FeedHandler()
    f.add_feed(
        FTX(symbols=FTX.info()['symbols'],
            channels=[OPEN_INTEREST, LIQUIDATIONS],
            callbacks={
                OPEN_INTEREST: OpenInterestCallback(oi),
                LIQUIDATIONS: LiquidationCallback(liquidations)
            }))
    symbols = [
        s for s in BinanceFutures.info()['symbols'] if 'PINDEX' not in s
    ]
    f.add_feed(
        BinanceFutures(symbols=symbols,
                       channels=[OPEN_INTEREST, LIQUIDATIONS],
                       callbacks={
                           OPEN_INTEREST: OpenInterestCallback(oi),
                           LIQUIDATIONS: LiquidationCallback(liquidations)
                       }))

    f.add_feed(
        Deribit(symbols=['BTC-USD-PERPETUAL', 'ETH-USD-PERPETUAL'],
                channels=[LIQUIDATIONS, OPEN_INTEREST],
                callbacks={
                    OPEN_INTEREST: OpenInterestCallback(oi),
                    LIQUIDATIONS: LiquidationCallback(liquidations)
                }))
    f.run()
Пример #2
0
def main(proxy):
    futures_symbols = BinanceFutures.info()['symbols']
    futures_symbols = [
        symbol for symbol in futures_symbols if 'PINDEX' not in symbol
    ]
    shuffle(futures_symbols)
    futures_symbols = futures_symbols[:20]

    # use high volume pairs for quick l2_book updates
    book_symbols = [
        'ETH-BTC', 'LTC-BTC', 'ADA-BTC', 'BTC-USDT', 'ETH-USDT', 'LTC-USDT',
        'BNB-BTC', 'BNB-ETH'
    ]

    f = FeedHandler()
    counter = Counter(f)
    f.add_feed(
        Binance(depth_interval='1000ms',
                http_proxy=proxy,
                max_depth=1,
                symbols=book_symbols,
                channels=[L2_BOOK],
                callbacks={
                    L2_BOOK:
                    counter.callback(BINANCE, L2_BOOK, book_symbols, False)
                }))
    f.add_feed(
        Binance(depth_interval='1000ms',
                http_proxy=proxy,
                max_depth=1,
                symbols=book_symbols,
                channels=[L2_BOOK],
                callbacks={
                    L2_BOOK: counter.callback(BINANCE, L2_BOOK, book_symbols,
                                              True)
                }))
    f.add_feed(
        BinanceFutures(http_proxy=proxy,
                       open_interest_interval=1.0,
                       symbols=futures_symbols,
                       channels=[OPEN_INTEREST],
                       callbacks={
                           OPEN_INTEREST:
                           counter.callback(BINANCE_FUTURES, OPEN_INTEREST,
                                            futures_symbols, False)
                       }))
    f.add_feed(
        BinanceFutures(http_proxy=proxy,
                       open_interest_interval=1.0,
                       symbols=futures_symbols,
                       channels=[OPEN_INTEREST],
                       callbacks={
                           OPEN_INTEREST:
                           counter.callback(BINANCE_FUTURES, OPEN_INTEREST,
                                            futures_symbols, True)
                       }))

    f.run()
Пример #3
0
import asyncio
from datetime import datetime
from collections import defaultdict
from multiprocessing import Process
from yapic import json

from cryptofeed import FeedHandler
from cryptofeed.backends.zmq import FundingZMQ
from cryptofeed.defines import L2_BOOK, FUNDING, PERPETUAL
from cryptofeed.exchanges import BinanceFutures, BinanceDelivery

binance_delivery_data_info = BinanceDelivery.info()
binance_futures_data_info = BinanceFutures.info()

import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())


def receiver(port):
    async def listen():
        while True:
            data = await s.recv_string()
            print(data)
            key, msg = data.split(" ", 1)
            print(key)
            # print(json.loads(msg))
            msg = json.loads(msg)
            res[msg['feed']][msg['symbol']] = msg['rate']
            d = res[msg['feed']]
            res[msg['feed']] = dict(