close_short (FUTURES)
This function can only be used in trade().To put one close_short order. Each period can put at max 500# orders.
Inputβ
exchange: string;
pair: string;
amount: number;
type: OrderType;
price: number;
Check OrderType
Exampleβ
To put one close_short order with market price for 1 amount. It is not necassery to set price with market price order.
exchange, pair, base, quote = CA.get_exchange_pair()
short_position = CA.get_position(exchange, pair, CA.PositionSide.SHORT)
if short_position and short_position.available_size >= 1:
CA.close_short(exchange, pair, 1, CA.OrderType.MARKET)
To put one close_short order with limit price for 1 amount. The limit price is set as close_price.
exchange, pair, base, quote = CA.get_exchange_pair()
close_price = candles[exchange][pair][0]['close']
short_position = CA.get_position(exchange, pair, CA.PositionSide.SHORT)
if short_position and short_position.available_size >= 1:
CA.close_short(exchange, pair, 1, CA.OrderType.LIMIT, close_price)