forked from bmoscon/cryptofeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_victoriametrics.py
27 lines (20 loc) · 1.09 KB
/
demo_victoriametrics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'''
Copyright (C) 2018-2025 Bryant Moscon - [email protected]
Please see the LICENSE file for the terms and conditions
associated with this software.
'''
from cryptofeed import FeedHandler
from cryptofeed.backends.victoriametrics import TradeVictoriaMetrics, TickerVictoriaMetrics, BookVictoriaMetrics, CandlesVictoriaMetrics
from cryptofeed.defines import TRADES, TICKER, L2_BOOK, CANDLES
from cryptofeed.exchanges import Coinbase, Binance
def main():
addr = 'tcp://localhost'
port = 8189
f = FeedHandler()
f.add_feed(Coinbase(channels=[TRADES], symbols=['BTC-USD'], callbacks={TRADES: TradeVictoriaMetrics(addr, port, 'demo-trades')}))
f.add_feed(Coinbase(channels=[TICKER], symbols=['BTC-USD'], callbacks={TICKER: TickerVictoriaMetrics(addr, port, 'demo-tickers')}))
f.add_feed(Coinbase(channels=[L2_BOOK], symbols=['BTC-USD'], callbacks={L2_BOOK: BookVictoriaMetrics(addr, port, 'demo-book')}))
f.add_feed(Binance(channels=[CANDLES], symbols=['BTC-USDT'], callbacks={CANDLES: CandlesVictoriaMetrics(addr, port, 'demo-candles')}))
f.run()
if __name__ == '__main__':
main()