-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
35 lines (27 loc) · 940 Bytes
/
test.py
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
import okx.MarketData as MarketData
import okx.Account as Account
import okx.Trade as Trade
flag = "1" # live trading: 0, demo trading: 1
accountAPI = Account.AccountAPI(api_key, secret_key, passphrase, False, flag)
marketDataAPI = MarketData.MarketAPI(flag = flag)
tradeAPI = Trade.TradeAPI()
result = marketDataAPI.get_tickers(instType = "SWAP")
print(result)
import okx.Account as Account
flag = "1" # live trading:0, demo trading: 1
result = accountAPI.get_account_balance()
print(result)
# market order
result = tradeAPI.place_order(
instId = "BTC-USDT-SWAP",
tdMode = "isolated",
side = "buy",
posSide = "net",
ordType = "market",
sz = "100"
)
print(result)
if result["code"] == "0":
print("Successful order request,order_id = ",result["data"][0]["ordId"])
else:
print("Unsuccessful order request,error_code = ",result["data"][0]["sCode"], ", Error_message = ", result["data"][0]["sMsg"])