-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·42 lines (34 loc) · 1.24 KB
/
test.py
File metadata and controls
executable file
·42 lines (34 loc) · 1.24 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
import pandas as pd
import numpy as np
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def send_request(endpoint, params={}):
response = requests.post(
f"https://192.168.0.104:5000/{endpoint}",
json=params,
verify=False # For self-signed certs
)
return response.json()
def test():
# Place 5 orders for different symbols
symbols = send_request("getSymbols")["response"]["symbols"]
# random 5
symbols = np.random.choice(symbols, 5, replace=False)
symbols = ["BTCUSDT", "DOGEUSDT", "ETHUSDT", "BNBUSDT", "ADAUSDT"]
# create market orders for each
order_ids = []
for symbol in symbols:
bid_ask = send_request("getBidAsk", {"symbol": symbol})["response"]
mid_price = (bid_ask["bid_price"] + bid_ask["ask_price"]) / 2
qty = 7_000 / mid_price
order_id = send_request("createOrder", {
"symbol": symbol,
"quantity": round(qty, 4),
"side": np.random.choice(["BUY", "SELL"]),
"order_type": "MARKET"
})["response"]["order_id"]
order_ids.append(order_id)
pass
if __name__ == "__main__":
test()