[英]How to send multiple orders to binance at incrementally decreasing prices in python using FOR loop
I am using python-binance to connect to binance cryptocurrency exchange.我正在使用 python-binance 连接到币安加密货币交易所。 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.我能够得到一个 FOR 循环来发送正确数量的订单,但我需要该范围内的每个订单以低于最后一个订单 5% 的价格发送订单。 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.我目前的想法是这样的,但是它以低于投标价 5% 的价格发送所有 10 个订单,而不是低于每个先前订单的 5%。
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.只需要在 API 调用后更新价格。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.