forked from bmoscon/cryptofeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_multicb.py
30 lines (19 loc) · 897 Bytes
/
demo_multicb.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
28
29
30
'''
Copyright (C) 2017-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.callback import TradeCallback
from cryptofeed.defines import TRADES
from cryptofeed.exchanges import Coinbase
async def trade(feed, symbol, order_id, timestamp, side, amount, price, receipt_timestamp):
print("Timestamp: {} Feed: {} Pair: {} ID: {} Side: {} Amount: {} Price: {}".format(timestamp, feed, symbol, order_id, side, amount, price))
async def trade2(feed, symbol, order_id, timestamp, side, amount, price, receipt_timestamp):
print("Trade2 Callback")
def main():
f = FeedHandler()
f.add_feed(Coinbase(subscription={TRADES: ['BTC-USD']}, callbacks={TRADES: [TradeCallback(trade), TradeCallback(trade2)]}))
f.run()
if __name__ == '__main__':
main()