===== Flatten Order =====
A **Flatten Order** can be used to flatten a current position regardless of what that position is.
The **T4 FIX API** server determines the volume and Buy/Sell parameters.
If a position does not currently exist for the **SecurityID** (Tag 48) of the submitted flatten order, the order is rejected.
A Flatten Order is entered with the **New Order Single** (Tag 35=D) message.
Following are the most relevant tags to build a Flatten Order:
^ Tag ^ Field ^ Description ^
| 40=F | OrdType | Specifier of Flatten Order Type |
| 38 | OrderQty | Set to 0 to have the T4 FIX API server determine the volume needed to flatten the position. A finite quantity may also be entered. |
| 54 | Side | Set to 0 (NONE) to have the T4 FIX API server determine whether to Buy or Sell to flatten. A finite side may also be entered. |
| 48 | SecurityID | Market for which the order is sent |
| 55 | Symbol | Contract for which the order is sent |
| 207 | SecurityExchange | Exchange for which the order is sent |
| 167 | SecurityType | Security Type (e.g. Futures) of this specific market |
----
**OrderQty Considerations**
* **OrderQty = 0** – Allows the API server to bypass certain risk management checks.
- Example: If Max Clip Size = 10 and Max Position = 20, and the current position is long 15, the server can submit a 15-lot sell without being rejected due to the clip size limit.
* **OrderQty > 0** – Acts as a maximum volume to submit.
- Example: If position = long 15 and OrderQty = 12, only a 12-lot order would be submitted.
- Risk management checks will be applied; order may be rejected if it violates limits (e.g. exceeds Max Clip Size).
----
**Side Considerations**
* **Side = 0 (NONE)** – Lets the server determine the side needed to flatten.
* **Side = BUY (1) or SELL (2)** – Server will only flatten if the position is in the correct direction.
- Example: If holding a long position and sending a flatten order with **Side = BUY (1)**, the server will reject the order.
----
**Sample**
In this example, the Flatten order is submitted by setting **OrdType** (Tag 40) = **F**.
Price (**Tag 44**) is not entered, **Side** (Tag 54) = **0** (NONE), and **OrderQty** (Tag 38) = **0**.
Flatten Order
>> 2/22/2013 12:51:28 PM [FIXNEWORDER] 34=153|49=T4Example|56=T4|50=TraderName|52=20130222-18:51:28.207|1=Account1|11=fn-634971342882072305|48=CME_20130300_ZCH3|55=ZC|207=CME_C|54=0|38=0|40=F|59=0|167=FUT|21=1|60=20130222-18:51:28.207|204=0|
[FIXNEWORDER]
[MsgSeqNum] 34 = 153
[SenderCompID] 49 = T4Example
[TargetCompID] 56 = T4
[SenderSubID] 50 = TraderName
[SendingTime] 52 = 20130222-18:51:28.207
[Account] 1 = Account1
[ClOrdID] 11 = fn-634971342882072305
[SecurityID] 48 = CME_20130300_ZCH3
[Symbol] 55 = ZC
[SecurityExchange] 207 = CME_C
[Side] 54 = 0 (NONE)
[OrderQty] 38 = 0
[OrdType] 40 = F (FLATTEN)
[TimeInForce] 59 = 0 (DAY)
[SecurityType] 167 = FUT (FUTURE)
[HandlInst] 21 = 1 (AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION)
[TransactTime] 60 = 20130222-18:51:28.207
[CustomerOrFirm] 204 = 0 (CUSTOMER)
Flatten Order Response - Awaiting Trigger
<< 2/22/2013 12:51:28 PM [fixexecutionreport] 34=536|49=T4|56=T4Example|50=T4FIX|52=20130222-18:51:28.207|143=UK|1=Account1|11=fn-634971342882072305|17=0.634971342895618750.2.1.DF0E0564|150=A|37=DF0E0564-9063-4C02-8F21-071C4DE1C419|39=A|48=CME_20130300_ZCH3|55=ZC|207=CME_C|200=201303|59=0|107=Corn Mar13|54=0|167=FUT|38=0|40=F|58=Flatten Awaiting Trigger|60=20130222-18:51:29.561|21=1|204=0|
[FIXEXECUTIONREPORT]
[MsgSeqNum] 34 = 536
[SenderCompID] 49 = T4
[TargetCompID] 56 = T4Example
[SenderSubID] 50 = T4FIX
[SendingTime] 52 = 20130222-18:51:28.207
[TargetLocationID] 143 = UK
[Account] 1 = Account1
[ClOrdID] 11 = fn-634971342882072305
[ExecID] 17 = 0.634971342895618750.2.1.DF0E0564
[ExecType] 150 = A (PENDING_NEW)
[OrderID] 37 = DF0E0564-9063-4C02-8F21-071C4DE1C419
[OrdStatus] 39 = A (PENDING_NEW)
[SecurityID] 48 = CME_20130300_ZCH3
[Symbol] 55 = ZC
[SecurityExchange] 207 = CME_C
[MaturityMonthYear] 200 = 201303
[TimeInForce] 59 = 0 (DAY)
[SecurityDesc] 107 = Corn Mar13
[Side] 54 = 0 (NONE)
[SecurityType] 167 = FUT (FUTURE)
[OrderQty] 38 = 0
[OrdType] 40 = F (FLATTEN)
[Text] 58 = Flatten Awaiting Trigger
[TransactTime] 60 = 20130222-18:51:29.561
[HandlInst] 21 = 1 (AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION)
[CustomerOrFirm] 204 = 0 (CUSTOMER)
Flatten Order Response
<< 2/22/2013 12:51:28 PM [fixexecutionreport] 34=537|49=T4|56=T4Example|50=T4FIX|52=20130222-18:51:28.254|143=UK|1=Account1|11=fn-634971342882072305|17=48085.7016210353_ZCH3.6349713428968100006.1.DF0E0564|150=0|37=DF0E0564-9063-4C02-8F21-071C4DE1C419|39=0|48=CME_20130300_ZCH3|55=ZC|207=CME_C|200=201303|59=0|107=Corn Mar13|54=2|167=FUT|38=1|40=1|60=20130222-18:51:29.681|21=1|204=0|
[FIXEXECUTIONREPORT]
[MsgSeqNum] 34 = 537
[SenderCompID] 49 = T4
[TargetCompID] 56 = T4Example
[SenderSubID] 50 = T4FIX
[SendingTime] 52 = 20130222-18:51:28.254
[TargetLocationID] 143 = UK
[Account] 1 = Account1
[ClOrdID] 11 = fn-634971342882072305
[ExecID] 17 = 48085.7016210353_ZCH3.6349713428968100006.1.DF0E0564
[ExecType] 150 = 0 (NEW)
[OrderID] 37 = DF0E0564-9063-4C02-8F21-071C4DE1C419
[OrdStatus] 39 = 0 (NEW)
[SecurityID] 48 = CME_20130300_ZCH3
[Symbol] 55 = ZC
[SecurityExchange] 207 = CME_C
[MaturityMonthYear] 200 = 201303
[TimeInForce] 59 = 0 (DAY)
[SecurityDesc] 107 = Corn Mar13
[Side] 54 = 2 (SELL)
[SecurityType] 167 = FUT (FUTURE)
[OrderQty] 38 = 1
[OrdType] 40 = 1 (MARKET)
[TransactTime] 60 = 20130222-18:51:29.681
[HandlInst] 21 = 1 (AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION)
[CustomerOrFirm] 204 = 0 (CUSTOMER)
Flatten Order Fill
<< 2/22/2013 12:51:28 PM [fixexecutionreport] 34=538|49=T4|56=T4Example|50=T4FIX|52=20130222-18:51:28.472|143=UK|1=Account1|11=fn-634971342882072305|17=70184:6787286TN0120234.63497134289681000021.2.DF0E0564|150=F|37=DF0E0564-9063-4C02-8F21-071C4DE1C419|39=2|48=CME_20130300_ZCH3|55=ZC|207=CME_C|200=201303|59=0|107=Corn Mar13|54=2|167=FUT|38=1|40=1|31=69475|32=1|14=1|151=0|60=20130222-18:51:29.827|21=1|204=0|337=TRADE|375=CME000A|
[FIXEXECUTIONREPORT]
[MsgSeqNum] 34 = 538
[SenderCompID] 49 = T4
[TargetCompID] 56 = T4Example
[SenderSubID] 50 = T4FIX
[SendingTime] 52 = 20130222-18:51:28.472
[TargetLocationID] 143 = UK
[Account] 1 = Account1
[ClOrdID] 11 = fn-634971342882072305
[ExecID] 17 = 70184:6787286TN0120234.63497134289681000021.2.DF0E0564
[ExecType] 150 = F
[OrderID] 37 = DF0E0564-9063-4C02-8F21-071C4DE1C419
[OrdStatus] 39 = 2 (FILLED)
[SecurityID] 48 = CME_20130300_ZCH3
[Symbol] 55 = ZC
[SecurityExchange] 207 = CME_C
[MaturityMonthYear] 200 = 201303
[TimeInForce] 59 = 0 (DAY)
[SecurityDesc] 107 = Corn Mar13
[Side] 54 = 2 (SELL)
[SecurityType] 167 = FUT (FUTURE)
[OrderQty] 38 = 1
[OrdType] 40 = 1 (MARKET)
[LastPx] 31 = 69475
[LastShares] 32 = 1
[CumQty] 14 = 1
[LeavesQty] 151 = 0
[TransactTime] 60 = 20130222-18:51:29.827
[HandlInst] 21 = 1 (AUTOMATED_EXECUTION_ORDER_PRIVATE_NO_BROKER_INTERVENTION)
[CustomerOrFirm] 204 = 0 (CUSTOMER)
[ContraTrader] 337 = TRADE
[ContraBroker] 375 = CME000A
Further details on the tags used for this order type are described in the dictionary of the New Order Single message.
[[developers:legacy_fix_api|T4 FIX API Home]]