place_order
This function can only be used in trade() or on_tradingview_signal().To put an order. Each period can put at max 500# orders.
Inputβ
exchange: string;
pair: string;
action: "buy" | "sell" | "open_long" | "open_short" | "close_long" | "close_short";
limit: number;
amount: number;
percent: number;
client_order_id: string;
profit: number;
loss: string;
conditional_order_type: "OTO";
child_conditional_orders: Input[];
notional: number;
limit (optional)β
set limit
to place a LIMIT order.
amount (optional)β
quantity based on a fixed quantity. if neither of quantity, percent and notional is set, use percent:100
. Quantity has higher priority than percent.
percent (optional)β
quantity based on a percentage of total balance. if neither of quantity, percent and notional is set, use percent:100
. Quantity has higher priority than percent.
client_order_id (optional)β
place / cancel an order with client_order_id
.
profit (optional)β
Live Tradewhen the order has been filled, place a TAKE_PROFIT order with stop price profit
.
loss (optional)β
Live Tradewhen the order has been filled, place a STOP_LOSS order with stop price loss
.
conditional_order_type (optional)β
place a conditional order with the conditional_order_type
.
child_conditional_orders (optional)β
place a conditional order with the following types:
OTO (One-Triggers-the-Other order)β
an OTO order consists of a primary order and a child order. the child order will be placed only if the primary order is fully filled (Order.status becomes OrderStatus.FILLED).
OCO (One-Cancels-the-Other order)β
In Progressan OCO order consists of two child orders. when one of them is fully filled (Order.status becomes OrderStatus.FILLED), the other will be canceled automatically.
notional (optional)β
buy, open_long, open_shortquantity based on a notional value to. if neither of quantity, percent and notional is set, use percent:100
. Quantity has higher priority than percent.
Exampleβ
A buy market order to buy with 100% of total balanceβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy')
A buy limit order to buy with 100% of total balanceβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', limit=1234)
A buy market order to buy 0.1 size/contractβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', amount=0.1)
A buy limit order to buy 0.1 size/contractβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', limit=1234, amount=0.1)
A buy market order to buy with 50% of total balanceβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', percent=50)
A buy limit order to buy with 50% of total balanceβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', limit=1234, percent=50)
A buy market order to buy with 100 USDTβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='buy', notional=100)
An OTO order to close long, and open short after close-long order is fully filledβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='close_long', conditional_order_type='OTO', child_conditional_orders=[{
'action': 'open_short'
}])
An OTO order to close short, and open long after close-short order is fully filledβ
exchange, pair, base, quote = CA.get_exchange_pair()
CA.place_order(exchange, pair, action='close_short', conditional_order_type='OTO', child_conditional_orders=[{
'action': 'open_long'
}])