Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need some help understand USDT Cross margin trade placement #71

Open
djangoengine opened this issue Nov 9, 2021 · 0 comments
Open

Need some help understand USDT Cross margin trade placement #71

djangoengine opened this issue Nov 9, 2021 · 0 comments

Comments

@djangoengine
Copy link

Hi Mate,
You have done a very decent job of creating this project.
I have actually coded for binance futures trading and I have excellent strategies I would like to use on Huobi futures.
I am bit confused with integrating my strategy into your strategy section.

Could you please explain how to place an order based on my strategy for example rsi>70 sell and rsi <30 buy .

if existing buy order is there to close this and open sell order and if existing sell order is present to close it and place buy order.

also I need to decide based on kline data and ticker data.

I take kline to analyse and create strategy and then use ticker data to exit trade.

Could up please explain how to use this method , do I need to override it or modify it based on the need?

`async def place_orders(self):
""" 下单
"""
orders_data = []
if self.trader.position and self.trader.position.short_quantity:
# 平空单
price = round(self.ask1_price - 0.1, 1)
quantity = -self.trader.position.short_quantity
action = ORDER_ACTION_BUY
new_price = str(price) # 将价格转换为字符串,保持精度
if quantity:
orders_data.append({"price": new_price, "quantity": quantity, "action": action, "order_type": ORDER_TYPE_LIMIT, "lever_rate": 5})
self.last_ask_price = self.ask1_price
if self.trader.assets and self.trader.assets.assets.get(self.raw_symbol):
# 开空单
price = round(self.bid1_price + 0.1, 1)
volume = int(float(self.trader.assets.assets.get(self.raw_symbol).get("free")) * 5/ price / self.contract_size)
if volume >= 1:
quantity = - volume # 空1张
action = ORDER_ACTION_SELL
new_price = str(price) # 将价格转换为字符串,保持精度
if quantity:
orders_data.append({"price": new_price, "quantity": quantity, "action": action, "order_type": ORDER_TYPE_LIMIT, "lever_rate": 5})
self.last_bid_price = self.bid1_price

    if orders_data:
        order_nos, error = await self.trader.create_orders(orders_data)
        if error:
            logger.error(self.strategy, "create future order error! error:", error, caller=self)
        logger.info(self.strategy, "create future orders success:", order_nos, caller=self)

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant