forked from sammchardy/python-binance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_oco_order.py
More file actions
92 lines (83 loc) · 2.81 KB
/
Copy pathcreate_oco_order.py
File metadata and controls
92 lines (83 loc) · 2.81 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import os
import sys
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(root)
from binance.client import Client
api_key = "" # your api_key here
secret = "" # your secret here
client = Client(api_key, secret, testnet=True)
# create oco order
def create_oco_order():
order = client.create_oco_order(
symbol="LTCUSDT",
side="SELL",
quantity=0.3,
aboveType="LIMIT_MAKER",
belowType="STOP_LOSS",
abovePrice=200,
belowStopPrice=120,
)
print(order)
# {
# "orderListId": 9365,
# "contingencyType": "OCO",
# "listStatusType": "EXEC_STARTED",
# "listOrderStatus": "EXECUTING",
# "listClientOrderId": "x-HNA2TXFJa9965a63237a3621d3f9df",
# "transactionTime": 1733229295138,
# "symbol": "LTCUSDT",
# "orders": [
# {
# "symbol": "LTCUSDT",
# "orderId": 5836416,
# "clientOrderId": "MxXFhDAC8h13wH8X3rXNKG",
# },
# {
# "symbol": "LTCUSDT",
# "orderId": 5836417,
# "clientOrderId": "a2UltweB2UB1XOdUTqOrzw",
# },
# ],
# "orderReports": [
# {
# "symbol": "LTCUSDT",
# "orderId": 5836416,
# "orderListId": 9365,
# "clientOrderId": "MxXFhDAC8h13wH8X3rXNKG",
# "transactTime": 1733229295138,
# "price": "0.00000000",
# "origQty": "0.30000000",
# "executedQty": "0.00000000",
# "origQuoteOrderQty": "0.00000000",
# "cummulativeQuoteQty": "0.00000000",
# "status": "NEW",
# "timeInForce": "GTC",
# "type": "STOP_LOSS",
# "side": "SELL",
# "stopPrice": "120.00000000",
# "workingTime": -1,
# "selfTradePreventionMode": "EXPIRE_MAKER",
# },
# {
# "symbol": "LTCUSDT",
# "orderId": 5836417,
# "orderListId": 9365,
# "clientOrderId": "a2UltweB2UB1XOdUTqOrzw",
# "transactTime": 1733229295138,
# "price": "200.00000000",
# "origQty": "0.30000000",
# "executedQty": "0.00000000",
# "origQuoteOrderQty": "0.00000000",
# "cummulativeQuoteQty": "0.00000000",
# "status": "NEW",
# "timeInForce": "GTC",
# "type": "LIMIT_MAKER",
# "side": "SELL",
# "workingTime": 1733229295138,
# "selfTradePreventionMode": "EXPIRE_MAKER",
# },
# ],
# }
def main():
create_oco_order()
main()