-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_oco.py
More file actions
44 lines (39 loc) · 1.09 KB
/
test_oco.py
File metadata and controls
44 lines (39 loc) · 1.09 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
40
41
42
43
44
import requests
BASE_URL = "http://127.0.0.1:5000"
symbol = "MNQ"
limit_payload = {
"quantity": 1,
"op": 24058.75,
"tp": 24095.75,
"sl": 23987,
"symbol": symbol,
"customTag": "TEST"
}
stop_payload = {
"quantity": 1,
"op": 15650.0,
"tp": 15800.0,
"sl": 15400.0,
"symbol": symbol,
"customTag": "TEST"
}
def send_request(endpoint, payload, label):
try:
res = requests.post(f"{BASE_URL}{endpoint}", json=payload)
print(f"\n--- {label} ---")
print("Status Code:", res.status_code)
print("Response:", res.json())
except Exception as e:
print(f"{label} failed:", e)
def get_balance():
try:
res = requests.get(f"{BASE_URL}/balance")
print("\n--- Account Balance ---")
print("Status Code:", res.status_code)
data = res.json()
print("Balance:", data.get("balance"))
except Exception as e:
print("Balance fetch failed:", e)
send_request("/place-oco", limit_payload, "Limit Entry OCO")
# send_request("/place-oco-stop", stop_payload, "Stop-Market Entry OCO")
# get_balance()