Skip to content

Commit bb5d4b5

Browse files
authored
Update orders.py
1 parent 180595d commit bb5d4b5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

orders.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from config import ORDER_BASE_URL
2+
13
class Orders:
24
def __init__(self, client):
35
self.client = client
6+
self.base_url = ORDER_BASE_URL
47

58
def get_orders(self, account_hash, max_results=100, from_entered_time=None, to_entered_time=None, status=None):
69
"""Retrieve a list of orders for a specified account."""
@@ -10,25 +13,25 @@ def get_orders(self, account_hash, max_results=100, from_entered_time=None, to_e
1013
'toEnteredTime': to_entered_time.isoformat() if to_entered_time else None,
1114
'status': status
1215
}
13-
endpoint = f'/trader/v1/accounts/{account_hash}/orders'
16+
endpoint = f"{self.base_url}/{account_hash}/orders"
1417
return self.client.get(endpoint, params=params)
1518

1619
def place_order(self, account_hash, order_details):
1720
"""Place a new order for an account."""
18-
endpoint = f'/trader/v1/accounts/{account_hash}/orders'
21+
endpoint = f"{self.base_url}/{account_hash}/orders"
1922
return self.client.post(endpoint, data=order_details)
2023

2124
def get_order(self, account_hash, order_id):
2225
"""Retrieve details for a specific order."""
23-
endpoint = f'/trader/v1/accounts/{account_hash}/orders/{order_id}'
26+
endpoint = f"{self.base_url}/{account_hash}/orders/{order_id}"
2427
return self.client.get(endpoint)
2528

2629
def cancel_order(self, account_hash, order_id):
2730
"""Cancel a specific order."""
28-
endpoint = f'/trader/v1/accounts/{account_hash}/orders/{order_id}'
31+
endpoint = f"{self.base_url}/{account_hash}/orders/{order_id}"
2932
return self.client.delete(endpoint)
3033

3134
def replace_order(self, account_hash, order_id, new_order_details):
3235
"""Replace an existing order with new details."""
33-
endpoint = f'/trader/v1/accounts/{account_hash}/orders/{order_id}'
36+
endpoint = f"{self.base_url}/{account_hash}/orders/{order_id}"
3437
return self.client.put(endpoint, data=new_order_details)

0 commit comments

Comments
 (0)