Skip to main content

TP & SL Condition

Fubon Neo API supports TP & SL orders.

Take-Profit and Stop-Loss Mechanism: Once a triggered condition order is executed, the stop-loss and take-profit monitoring mechanism will be activated. When the take-profit condition is met, the stop-loss will be deactivated; conversely, if the stop-loss condition is met, the take-profit will be deactivated (similar to the commonly known OCO mechanism).

TPSL

程式範例

# 設計條件內容
condition = Condition(
market_type = TradingType.Reference,
symbol = "TXO20000E4",
trigger = TriggerContent.MatchedPrice,
trigger_value = "100",
comparison = Operator.LessThan
)

order = FutOptConditionOrder(
buy_sell = BSAction.Buy,
symbol = "TXO20000E4",
price = "100",
lot = 1,
market_type = FutOptConditionMarketType.Option,
price_type = FutOptConditionPriceType.Limit,
time_in_force = TimeInForce.ROD,
order_type = FutOptConditionOrderType.New
)

tp = FutOptTPSLOrder(
time_in_force=TimeInForce.ROD,
price_type=FutOptConditionPriceType.Limit,
order_type=FutOptConditionOrderType.Close,
target_price="85",
price="85"
)


sl = FutOptTPSLOrder(
time_in_force=TimeInForce.ROD,
price_type=FutOptConditionPriceType.Limit,
order_type=FutOptConditionOrderType.Close,
target_price="60",
price="60"
)

tpsl = FutOptTPSLWrapper(
stop_sign= StopSign.Full,
tp=tp, # optional field
sl=sl, # optional field
end_date="20240517"
)


sdk.futopt.single_condition(account, "20240426", "20240430", StopSign.Full, condition, order, tpsl)