-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestapi
More file actions
47 lines (40 loc) · 1.29 KB
/
testapi
File metadata and controls
47 lines (40 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
40
41
42
43
44
45
46
47
import okx.Trade as Trade
api_key = "xxxx"
secret_key = "xxxx"
passphrase = "xxx"
import okx.Funding as Funding
import okx.Account as Account
import okx.MarketData as MarketData
import okx.Trade as Trade
flag = "0" # live trading: 0, demo trading: 1
tradeAPI = Trade.TradeAPI(api_key, secret_key, passphrase, False, flag)
accountAPI = Account.AccountAPI(api_key, secret_key, passphrase, False, flag)
##result = accountAPI.get_account_balance()
##fundingAPI = Funding.FundingAPI(api_key, secret_key, passphrase, False, flag)
##result = fundingAPI.get_currencies()
##result = accountAPI.get_account_config()
##print(result)
#marketDataAPI = MarketData.MarketAPI(flag = flag)
#result = marketDataAPI.get_tickers(instType = "SWAP")
#print(result)
# limit order
result = accountAPI.set_leverage(
instId = "SUI-USDT-SWAP",
lever = "5",
mgnMode = "isolated"
)
print(result)
result = tradeAPI.place_order(
instId = "SUI-USDT-SWAP",
tdMode = "isolated",
side = "sell",
posSide = "net",
ordType = "limit",
px = "2.0",
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"])