This repository has been archived by the owner on Oct 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
orders.py
67 lines (62 loc) · 2.66 KB
/
orders.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
import ccxt
import APIkeys_fetching
from GUI import errorMessage, validationMessage
from PyQt5 import QtCore, QtGui, QtWidgets
#Ordres ouverts
def openOrders(exchange: str):
apikey = APIkeys_fetching()
df = apikey.get()
for i, row in df.iterrows():
if df.loc[i]['exchange'] == exchange:
apikey = df.loc[i,'apikey']
secret = df.loc[i,'secret']
exec('exchange = ccxt.' + exchange + "({'apikey':" + apikey + "'secret':" + secret + "})" )
if exchange.has['fetchOpenOrders']:
exchange.options["warnOnFetchOpenOrdersWithoutSymbol"] = False
openOders = []
orders = exchange.fetchOpenOrders()
for openOrder in orders:
openOders.append([openOrder['id'], openOrder['symbol'], openOrder['side'], openOrder['price'], openOrder['amount']])
return openOders#liste de liste [id, symbol, SELL/BUY, price, amount]
#Cancel order:
def cancelOrder(exchange: str, orderId, symbol: str): #ex: cancelOrder(binance, 11480381, 'MFT/BTC')
apikey = APIkeys_fetching()
df = apikey.get()
for i, row in df.iterrows():
if df.loc[i]['exchange'] == exchange:
apikey = df.loc[i,'apikey']
secret = df.loc[i,'secret']
exec('exchange = ccxt.' + exchange + "({'apikey':" + apikey + "'secret':" + secret + "})" )
try:
exchange.cancelOrder(orderId, symbol)
return str('Order canceled')
except: #if there is an error
import sys
app = QtWidgets.QApplication(sys.argv)
Responsemessage = QtWidgets.QDialog()
ui = errorMessage.Ui_Responsemessage()
errorMessage.ui.setupUi(Responsemessage)
Responsemessage.show()
sys.exit(app.exec_())
#(ex: cancelOrder(binance, 11480381, 'MFT/BTC'))
#créer un ordre
def createOrder(exchange: str, symbol: str, amount: float, price: float, side: str, type: str):# (side= 'buy' or 'sell'), type = 'limit' or 'market'
#binance.create_order('RVN/BTC', 'limit', 'buy', amount = 1.0, price = 0.060154)
apikey = APIkeys_fetching()
df = apikey.get()
for i, row in df.iterrows():
if df.loc[i]['exchange'] == exchange:
apikey = df.loc[i,'apikey']
secret = df.loc[i,'secret']
exec('exchange = ccxt.' + exchange + "({'apikey':" + apikey + "'secret':" + secret + "})" )
try:
order = exchange.create_order(symbol, type, side, amount, price)
except:
import sys
app = QtWidgets.QApplication(sys.argv)
Responsemessage = QtWidgets.QDialog()
ui = errorMessage.Ui_Responsemessage()
errorMessage.ui.setupUi(Responsemessage)
Responsemessage.show()
sys.exit(app.exec_())
return order