-
-
Notifications
You must be signed in to change notification settings - Fork 720
/
Copy pathdemo_elastic.py
36 lines (27 loc) · 1.05 KB
/
demo_elastic.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
31
32
33
34
35
36
'''
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.elastic import BookElastic, FundingElastic, TradeElastic
from cryptofeed.defines import FUNDING, L2_BOOK, TRADES
from cryptofeed.exchanges import Bitmex, Coinbase
"""
after writing, you can query all the trades out with the following curl:
curl -X GET "localhost:9200/book/book/_search" -H 'Content-Type: application/json' -d'
{
"size": 50,
"query": {
"match_all": {}
}
}
'
"""
def main():
f = FeedHandler()
f.add_feed(Coinbase(channels=[L2_BOOK, TRADES], symbols=['BTC-USD'], callbacks={L2_BOOK: BookElastic('http://localhost:9200', numeric_type=float), TRADES: TradeElastic('http://localhost:9200', numeric_type=float)}))
f.add_feed(Bitmex(channels=[FUNDING], symbols=['BTC-USD'], callbacks={FUNDING: FundingElastic('http://localhost:9200', numeric_type=float)}))
f.run()
if __name__ == '__main__':
main()