-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcancelallorders.py
More file actions
39 lines (29 loc) · 1.29 KB
/
cancelallorders.py
File metadata and controls
39 lines (29 loc) · 1.29 KB
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
37
38
39
# cancel all own open orders on xbridge
import asyncio
import os
from definitions.logger import setup_logger
from definitions.xbridge_manager import XBridgeManager
if __name__ == '__main__':
"""
A simple script to cancel all open XBridge orders.
It initializes the necessary components to communicate with the Blocknet daemon.
"""
class MinimalXBridgeConfig:
"""A minimal mock for the xbridge config to provide a debug_level."""
debug_level = 3 # Default debug level for this script
class MinimalConfig:
def __init__(self, logger):
self.general_log = logger
self.config_xbridge = MinimalXBridgeConfig()
self.controller = None
# Setup a basic logger for this script
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
general_log, _, _ = setup_logger(strategy="cancel_script", ROOT_DIR=ROOT_DIR)
general_log.info("Initializing to cancel all orders...")
xbridge_manager = XBridgeManager(MinimalConfig(general_log))
general_log.info("Sending cancel all orders command...")
successful = asyncio.run(xbridge_manager.cancelallorders())
if successful:
general_log.info(f"Successfully cancelled {len(successful)} order(s).")
else:
general_log.info("No open orders were cancelled.")