forked from antonpenev/python-binance-arbitrage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.py
More file actions
56 lines (40 loc) · 1.28 KB
/
order.py
File metadata and controls
56 lines (40 loc) · 1.28 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
"""
Functions to make binance api orders
"""
from binance.enums import SIDE_BUY
from binance.exceptions import BinanceAPIException
import config
def make(connection, step, options):
""" Makes order to given market """
print('in make', step, options)
symbol = step['symbol']
precision = config.get('binance_max_precision')
lot_size = options.get('lot_size')
if not lot_size:
raise 'No lot_size given'
amount = float(format(step['amount'], precision))
step_size = amount % lot_size
amount = amount - step_size
# round up
if step_size > 0:
amount = amount + lot_size
quantity = format(amount, precision)
make_market_order(
connection,
symbol=symbol,
side_type=step['type'],
quantity=quantity)
def make_market_order(connection, symbol, side_type, quantity):
""" Make Binance Buy/Sell Market order """
# print('in make_market_order. STOP HERE ', symbol, side_type, quantity)
# return ''
if side_type == SIDE_BUY:
order = connection.order_market_buy(
symbol=symbol,
quantity=quantity)
else:
order = connection.order_market_sell(
symbol=symbol,
quantity=quantity)
print('market order', type, order)
return order