【发布时间】:2021-09-03 23:08:54
【问题描述】:
我在项目中使用了一个名为“python-binance”的模块 它在开仓时效果很好,但是我找不到正确关闭它们的方法。
from config import Connect
import time
class Main:
def __init__(self):
self.client = Connect().make_connection()
print("logged in")
amount = float(input("Hesaptaki para miktarı:"))
symbol = input("Coin İsmi:")
orderType= input("Emir tipi(1,2):")
leverage = int(input("Kaldıraç boyutu:"))
self.client.futures_change_leverage(symbol=symbol, leverage=leverage)
price=float(self.client.get_symbol_ticker(symbol=symbol)["price"])
print(price)
quantity = amount*leverage*price
quantity = int(quantity)
print(quantity)
if orderType == "2":
Price = float(input("Limit fiyatı:"))
print(Price)
sellPrice= Price+(Price*0.5/100)
self.client.futures_create_order(symbol=symbol,type="LIMIT",timeInForce="GTC",side="BUY",price=Price,quantity=quantity)
self.client.futures_create_order(symbol=symbol,type="LIMIT",timeInForce="GTC",side="SELL",price=sellPrice,quantity=quantity)
else:
Price=self.client.get_symbol_ticker(symbol=symbol)["price"]
Price=float(Price)
print(Price)
sellPrice = Price+(Price*0.5/100)
self.client.futures_create_order(symbol=symbol,type="MARKET",side="BUY",quantity=quantity,)
self.client.futures_create_order(symbol=symbol,type="LIMIT",timeInForce="GTC",side="SELL",price=sellPrice,quantity=quantity)
print(self.client.futures_position_information(symbol=symbol))
print(self.client.futures_get_position_mode())
Main()
这是我的代码,当我尝试按照代码开多头头寸或做空其开仓头寸时,它的一部分起作用
self.client.futures_create_order(symbol=symbol,type="MARKET",side="BUY",quantity=quantity,)
但是在这段代码之后,我想给出另一个代码来设置限价单来关闭这个订单 如果你知道期货交易系统,我想用这个 api 设置 tp/sl 点 我该怎么做呢
我已经告诉过这段代码有一些错误,其中另一个是数量,我也需要帮助我想用任何硬币自动设置数量,但我找不到公式以及如何编码到了
感谢您的帮助
【问题讨论】: