-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcli_linear.py
161 lines (140 loc) · 5.36 KB
/
cli_linear.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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import bybit_usdt_execution_linear as bybit
import binance_spot_execution_linear as binance_spot
def binance_cli():
client = binance_spot.auth()
usdt_tickers = binance_spot.get_spot_tickers(client)
print("Connected to >> Binance SPOT")
exit = False
while not exit:
print("What do you want to do:"
"\n 1 >> display positions"
"\n 2 >> buy/sell spot"
"\n 0 >> exit - binance spot"
"\n 99 >> restart client and refresh tickers")
mode = int(input("input number >>> "))
if mode == 0:
exit = True
print("Binance SPOT - closing")
else:
if mode == 1:
print("\n")
print("Current positions")
open_positions = binance_spot.get_spot_balances(client)
binance_spot.display_positions(open_positions)
print("\n")
elif mode == 2:
print("\n")
print("Open position mode selected")
print("Select order type:"
"\n twap >> 1"
"\n market order >> 2")
order_mode = int(input("input number >>> "))
if order_mode == 1:
print("twap mode selected")
binance_spot.basic_twap(client, usdt_tickers)
elif order_mode == 2:
print("market order mode selected")
binance_spot.market_order(client, usdt_tickers)
print("\n")
elif mode == 3:
print("\n")
print("Close position mode selected")
print("Select order type:"
"\n twap >> 1"
"\n market order >> 2")
order_mode = int(input("input number >>> "))
if order_mode == 1:
print("twap mode selected")
bybit.basic_twap_close(client)
elif order_mode == 2:
print("market order mode selected")
bybit.market_close(client)
print("\n")
elif mode == 99:
print("\n")
print("Reconnecting client and refreshing tickers")
client = binance_spot.auth()
usdt_tickers = binance_spot.get_spot_tickers(client)
print("\n")
def bybit_cli():
client = bybit.auth()
usdt_tickers = bybit.get_usdt_tickers(client)
print("Connected to >> Bybit USDT perps")
exit = False
while not exit:
print("What do you want to do:"
"\n 1 >> display positions"
"\n 2 >> open position"
"\n 3 >> close position"
"\n 4 >> modify positions"
"\n 0 >> exit - bybit usdt perps"
"\n 99 >> restart client and refresh tickers")
mode = int(input("input number >>> "))
if mode == 0:
exit = True
print("Bybit USDT perps - closing")
else:
if mode == 1:
print("\n")
print("Current positions")
open_positions = bybit.get_open_positions(client)
bybit.display_positions(open_positions)
print("\n")
elif mode == 2:
print("\n")
print("Open position mode selected")
print("Select order type:"
"\n twap >> 1"
"\n market order >> 2")
order_mode = int(input("input number >>> "))
if order_mode == 1:
print("twap mode selected")
bybit.basic_twap(client, usdt_tickers)
elif order_mode == 2:
print("market order mode selected")
bybit.market_order(client, usdt_tickers)
print("\n")
elif mode == 3:
print("\n")
print("Close position mode selected")
print("Select order type:"
"\n twap >> 1"
"\n market order >> 2")
order_mode = int(input("input number >>> "))
if order_mode == 1:
print("twap mode selected")
bybit.basic_twap_close(client)
elif order_mode == 2:
print("market order mode selected")
bybit.market_close(client)
print("\n")
elif mode == 4:
print("\n")
print("Modify mode selected")
bybit.set_position_sl_tp(client)
print("\n")
elif mode == 99:
print("Reconnecting client and refreshing tickers")
client = bybit.auth()
usdt_tickers = bybit.get_usdt_tickers(client)
print("\n")
def main():
exit = False
while not exit:
print("\n")
print("Select exchange:"
"\n 1 >> Binance SPOT"
"\n 2 >> Bybit USDT perps"
"\n 0 >> exit terminal")
mode = int(input("input number >>> "))
if mode == 0:
exit = True
print("Terminal closing")
elif mode == 1:
print("\n")
binance_cli()
elif mode == 2:
print("\n")
bybit_cli()
if __name__ == "__main__":
main()