Skip to content

Need some help understand USDT Cross margin trade placement #71

@djangoengine

Description

@djangoengine

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)

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions