Skip to main content
async def retrieveOrders(only_open_orders: bool = False, market_id: int = 0):
    base_url = os.getenv("API_SERVER_URL")
    async with httpx.AsyncClient() as session:
        client = PerpetualsClient(base_url=base_url, session=session)
        try:
            address = os.getenv("ACCOUNT")
            print(market_id)
            if market_id > 0:
                orders = await client.get_orders(address=address, market=market_id)
            else:
                orders = await client.get_orders(address=address)

            return orders
        except Exception as e:
            print(f"Error getting order: {e}")
            print("\nTroubleshooting:")
            print("  - Is the server running?")
            print("  - Does this address have orders in the database?")