File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import logging
2+ import asyncio
3+ import lighter
4+ from utils import default_example_setup
5+
6+
7+ async def main ():
8+ client , api_client , _ = default_example_setup ()
9+ logging .basicConfig (level = logging .INFO )
10+
11+ account_api = lighter .AccountApi (api_client )
12+ response = await account_api .account (by = "index" , value = str (client .account_index ))
13+ if len (response .accounts ) == 0 :
14+ raise "No account found"
15+
16+ account = response .accounts [0 ]
17+ # Note: cross-account value does not take into account isolated positions, but total does
18+ print ("=== perp assets ===" )
19+ print (f"total: { account .total_asset_value } available: { account .available_balance } " )
20+ print (f"cross: { account .cross_asset_value } isolated: { float (account .total_asset_value ) - float (account .cross_asset_value )} " )
21+
22+ # Spot Assets
23+ print ("=== spot assets ===" )
24+ for asset in account .assets :
25+ print (f"{ asset .symbol } total: { asset .balance } available: { float (asset .balance ) - float (asset .locked_balance )} " )
26+
27+ await client .close ()
28+ await api_client .close ()
29+
30+ if __name__ == "__main__" :
31+ asyncio .run (main ())
You can’t perform that action at this time.
0 commit comments