offline file with IDs of openned trigger orders

This commit is contained in:
2025-08-05 21:09:45 +02:00
parent 19f920bb53
commit 064fd7b9ce
4 changed files with 640 additions and 71 deletions

View File

@ -161,6 +161,62 @@ def cancel_trigger_order(account_id, market, order_id):
return None
def list_trigger_orders(account_id, market):
"""
List all trigger orders for a specific account and market
Args:
account_id (int): Account ID to get orders for
market (str): Market to get orders for (e.g., BASE_MARKET_ETH_USD)
Returns:
list: List of trigger orders with their details, or empty list if method not available
"""
try:
client = Client(
eth_private_key=PRIVATE_KEY,
rpc_url=RPC_URL
)
# Check if the method exists before calling it
if not hasattr(client.private, 'get_all_orders'):
print(f'⚠️ get_all_orders method not available in FlexTrade SDK')
print(f' Cannot list existing trigger orders - this is expected with some SDK versions')
return []
orders = client.private.get_all_orders(account_id, market)
if orders:
print(f'Found {len(orders)} trigger orders for account {account_id} in market {market}:')
for i, order in enumerate(orders, 1):
order_id = order.get('orderIndex', 'N/A')
action = order.get('action', 'N/A')
size = order.get('size', 'N/A')
trigger_price = order.get('triggerPrice', 'N/A')
trigger_above = order.get('triggerAbove', 'N/A')
is_reduce_only = order.get('isReduceOnly', 'N/A')
print(f' {i}. Order ID: {order_id}')
print(f' Action: {action}')
print(f' Size: {size}')
print(f' Trigger Price: ${trigger_price}')
print(f' Trigger Above: {trigger_above}')
print(f' Reduce Only: {is_reduce_only}')
print()
else:
print(f'No trigger orders found for account {account_id} in market {market}')
return orders if orders else []
except AttributeError as e:
print(f"⚠️ Method not available in FlexTrade SDK: {e}")
print(f" Skipping trigger order listing - continuing with position check")
return []
except Exception as e:
print(f"❌ Error listing trigger orders: {e}")
return []
async def main():
client = Client(
eth_private_key=PRIVATE_KEY,