File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ # python -c "import examples.websocket.auth.calc"
2+
3+ import os
4+
5+ from bfxapi import Client
6+ from bfxapi .types import BaseMarginInfo , FundingInfo , SymbolMarginInfo
7+
8+ bfx = Client (
9+ api_key = os .getenv ("BFX_API_KEY" ),
10+ api_secret = os .getenv ("BFX_API_SECRET" ),
11+ )
12+
13+
14+ @bfx .wss .on ("authenticated" )
15+ async def on_authenticated (_ ):
16+ await bfx .wss .inputs .calc ("margin_base" )
17+
18+ await bfx .wss .inputs .calc ("margin_sym_tBTCUSD" )
19+
20+ await bfx .wss .inputs .calc ("funding_sym_fUST" )
21+
22+
23+ @bfx .wss .on ("base_margin_info" )
24+ def on_base_margin_info (data : BaseMarginInfo ):
25+ print ("Base margin info:" , data )
26+
27+
28+ @bfx .wss .on ("symbol_margin_info" )
29+ def on_symbol_margin_info (data : SymbolMarginInfo ):
30+ if data .symbol == "tBTCUSD" :
31+ print ("Symbol margin info:" , data )
32+
33+
34+ @bfx .wss .on ("funding_info_update" )
35+ def on_funding_info_update (data : FundingInfo ):
36+ if data .symbol == "fUST" :
37+ print ("Funding info update:" , data )
38+
39+
40+ bfx .wss .run ()
You can’t perform that action at this time.
0 commit comments