I am using python-binance to connect to binance cryptocurrency exchange. I am able to send orders simply using this code:
client.create_margin_order(
symbol = 'BTCUSDT',
side = Client.SIDE_BUY,
type = Client.ORDER_TYPE_LIMIT,
timeInForce = Client.TIME_IN_FORCE_GTC,
quantity = 100,
price = 10000
recvWindow = 5000,
timestamp = time.time_ns())
I am able to get a FOR loop to send the correct number of orders but i need each order in the range to send an order at 5% below the last order. How can I achieve this?
My current idea looks like this, however it sends all 10 orders at 5% below the bid price as opposed to 5% below each previous order.
for x in range(10):
client.create_margin_order(
symbol = 'BTCUSDT',
side = Client.SIDE_BUY,
type = Client.ORDER_TYPE_LIMIT,
timeInForce = Client.TIME_IN_FORCE_GTC,
quantity = 100,
price = d.Decimal(bidprice) * d.Decimal(0.95), #????????
recvWindow = 5000,
timestamp = time.time_ns())
Thank you for your suggestions!
Just need to update the price after the API call.
price=10000
for x in range(10):
print(price)
price *= .95
Output
10000
9500.0
9025.0
8573.75
8145.0625
7737.809375
7350.918906249999
6983.372960937499
6634.204312890623
6302.494097246092
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.