Ally Invest API Documentation
Build your application to connect to our investment platform and the 250,000 traders connected to it.
Trading
This page contains FIXML examples of trades that can be made through the Ally Invest API. Currently OTO and OCO orders are unsupported by the API. You can use accounts/:id/orders/preview to preview orders and accounts/:id/orders to check the status and place orders.
Common Stock Actions
Common stock actions are delimited by the FIXML attribute Side.
Buy Order
Example Place a day order to buy 1 share of F at market price on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="1" Side="1" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Sell Order
Example Place a day order to sell 1 share of F at market price on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="1" Side="2" Acct="12345678">
<Instrmt SecTyp="CS" Sym="IBM"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Sell Short (opening a short position)
Example Place a day order to sell short 1 share of F at $22.00 on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="5" Px="22" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Buy to Cover (closing a short position)
Example Place a day order to buy to cover 1 share of F at $13 on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="1" AcctTyp="5" Px="13" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Modifying Stock Orders
Change Order
You can cancel/replace any open order.
Example Place a new day order to buy 1 share of F at a limit price of $15 on account 12345678 replacing the original order number SVI-12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<OrdCxlRplcReq TmInForce="0" Typ="2" Side="1" Px="15" Acct="12345678" OrigID="SVI-12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</OrdCxlRplcReq>
</FIXML>
Cancel Order
Example Cancel the order SVI-12345678 on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<OrdCxlReq TmInForce="0" Typ="2" Side="1" OrigID="SVI-12345678" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</OrdCxlReq>
</FIXML>
Option Actions
With option actions the FIXML attribute Side and PosEfct are the key differentiators.
Buy to Open (opening a long option purchase)
Example Place a limit order buying to open 4 contracts of IBM Jan 18, 2014 $190 Call at a limit of 21.00 on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="1" Px="21.00" PosEfct="O" Acct="12345678">
<Instrmt CFI="OC" SecTyp="OPT" MatDt="2014-01-18T00:00:00.000-05:00" StrkPx="190" Sym="IBM"/>
<OrdQty Qty="4"/>
</Order>
</FIXML>
Sell to Open (opening a short option sell)
Example Place a 5.10 limit order to sell to open 7 contracts of the COST Jan 19, 2013 $90.00 Call on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="1" Typ="2" Side="2" Px="5.10" PosEfct="O" Acct="12345678">
<Instrmt CFI="OC" SecTyp="OPT" MatDt="2013-01-19T00:00:00.000-05:00" StrkPx="90.00" Sym="COST"/>
<OrdQty Qty="7"/>
</Order>
</FIXML>
Buy to Close (closing a previously opened short option)
Example Place a market order buying to close 1 contract of F at a limit of .19 with strike price $16, expiring Feb. 11th 2011 on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="1" Px=".19" PosEfct="C" Acct="12345678">
<Instrmt CFI="OC" SecTyp="OPT" MatDt="2011-02-11T00:00:00.000-05:00" StrkPx="16" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Sell to Close (closing a previously opened long option)
Example Place a market order selling to close 1 contract of F at a limit of .19 with strike price $16, expiring Feb. 11th 2011 on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="2" Px=".19" PosEfct="C" Acct="12345678">
<Instrmt CFI="OC" SecTyp="OPT" MatDt="2011-02-11T00:00:00.000-05:00" StrkPx="16" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Modifying Option Orders
Change Order
Example Place a change order buying to open 4 contracts of IBM Jan 18, 2014 $190 Call at a limit of 21.20 on account 12345678 for order id SVI-56657005.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<OrdCxlRplcReq TmInForce="0" Typ="2" Side="1" Px="21.20" PosEfct="O" Acct="12345678" OrigID="SVI-56657005">
<Instrmt CFI="OC" SecTyp="OPT" MatDt="2014-01-18T00:00:00.000-05:00" StrkPx="190" Sym="IBM"/>
<OrdQty Qty="4"/>
</OrdCxlRplcReq>
</FIXML>
Cancel order
Example Place a cancel request on order that is buying to open 4 contracts of IBM Jan 18, 2014 $190 Call at a limit of 21.20 on account 12345678 for order id SVI-56657005/2.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<OrdCxlReq TmInForce="0" Typ="2" Side="1" OrigID="SVI-56657005/2" Acct="12345678"> <Instrmt CFI="OC" SecTyp="OPT" MatDt="2014-01-18T00:00:00.000-05:00" StrkPx="190" Sym="IBM"/>
<OrdQty Qty="4"/>
</OrdCxlReq>
</FIXML>
Multi-leg Orders
For multi-leg orders, leg information is repeated for each leg of the order (see example below). Note: Multi-leg orders can be placed as:
-
Market (OrdTyp="1")
-
Limit as a Debit, Credit, or Even (OrdTyp="2")
-
Debits are entered as a negative number like the example below (Px="-3.10"). o Credits are entered as a positive number (Px="3.10")
-
Even would be entered as a 0 value (Px="0")
-
New Order
Example Place an IBM Call spread order, buying 4 contracts to open the Jan 18, 2014 $190 Call and selling 4 contracts to open the Jan 18, 2014 $200 Call at a 3.10 debit good for the day.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<NewOrdMleg TmInForce="0" Px="-3.10" OrdTyp="2" Acct="12345678">
<Ord OrdQty="4" PosEfct="O">
<Leg Side="1" Strk="190" Mat="2014-01-18T00:00:00.000-05:00" MMY="201401" SecTyp="OPT" CFI="OC" Sym="IBM"/>
</Ord>
<Ord OrdQty="4" PosEfct="O">
<Leg Side="2" Strk="200" Mat="2014-01-18T00:00:00.000-05:00" MMY="201401" SecTyp="OPT" CFI="OC" Sym="IBM"/>
</Ord>
</NewOrdMleg>
</FIXML>
Request to change a multi-leg order
Example Request to change the IBM call spread (from the new order example above).
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<MlegOrdCxlRplc TmInForce="0" Px="-3.60" OrdTyp="2" Acct="12345678" OrigClOrdID="SVI-56656615">
<Ord OrdQty="4" PosEfct="O">
<Leg Side="1" Strk="190" Mat="2014-01-18T00:00:00.000-05:00" MMY="201401" SecTyp="OPT" CFI="OC" Sym="IBM"/>
</Ord>
<Ord OrdQty="4" PosEfct="O">
<Leg Side="2" Strk="200" Mat="2014-01-18T00:00:00.000-05:00" MMY="201401" SecTyp="OPT" CFI="OC" Sym="IBM"/>
</Ord>
</MlegOrdCxlRplc>
</FIXML>
Request to cancel a multi-leg order
Example Request to cancel the IBM call spread (from the new order example above).
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<OrdCxlReq OrigID="SVI-56656487" Acct="12345678">
<Instrmt SecTyp="MLEG" Sym="IBM"/>
</OrdCxlReq>
</FIXML>
Trade Parameters
Type
Different trade price types are delimited by FIXML attribute Typ. (or OrdTyp for multi-leg option orders).
Market
An order to buy or sell an investment immediately at the best available current price.
Example Place a day order to buy 1 share of F at market price on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="1" Side="1" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Limit
An order placed with a brokerage to buy or sell a set number of shares at a specified price or better.
Example Place a day order to buy 1 share of F at a limit price of $15 on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="2" Side="1" Px="15" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Stop
An order to buy or sell a security when its price surpasses a particular point, thus ensuring a greater probability of achieving a predetermined entry or exit price. Once the price surpasses the predefined entry/exit point, the stop order becomes a market order.
Example Place a day order to buy 1 share of F with a stop price of $18 on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="3" Side="1" StopPx="18" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Stop Limit
A stop-limit order will be executed at a specified price (or better) after a given stop price has been reached. Once the stop price is reached, the stop-limit order becomes a limit order to buy (or sell) at the limit price or better.
Example Place a day order to buy 1 share of F with a stop price of $18 and a limit price of $19 on account 12345678.
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="4" Side="1" Px="19" StopPx="18" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Term
Trade terms are delimited by the FIXML attribute TmInForce.
Day
Any order to buy or sell a security that automatically expires if not executed on the day the order is placed.
Example Place a day order to buy 1 share of F at market price on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="0" Typ="1" Side="1" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
Market on Close (SecTyp=CS only)
A market order to be executed as near to the end of the exchange day as possible. This is only possible on common stock orders.
Example Place market on close order to buy 1 share of F on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="7" Typ="1" Side="1" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/>
<OrdQty Qty="1"/>
</Order>
</FIXML>
GTC (Good 'Til Canceled)
An order to buy or sell that remains open in your account for 60 calendar days from the original date placed, unless executed or canceled. Changes or edits to a GTC order will not affect the original order date.
Example Place a good 'til canceled order to buy 1 share of F at a limit price of $18 on account 12345678
<FIXML xmlns="http://www.fixprotocol.org/FIXML-5-0-SP2">
<Order TmInForce="1" Typ="2" Side="1" Px="18" Acct="12345678">
<Instrmt SecTyp="CS" Sym="F"/> <OrdQty Qty="1"/>
</Order>
</FIXML>
Disclaimer:
Any mention of actual symbols are to be used for coding purposes only and do not imply a recommendation or solicitation to buy or sell a particular security or to engage in any particular investment strategy.
At the time of publication and in the preceding month, Ally Invest did not have ownership greater than 1% in any stocks mentioned here and does not have any other actual, material conflict of interest known at the time of publication.
Ally Invest did not receive compensation from a public offering or from investment banking services related to any companies mentioned here within the past 12 months, or expects to receive any in the next 3 months. Ally Invest did not engage in market making in the securities mentioned here.
Ally Invest Securities' background can be found at FINRA's BrokerCheck . Options involve risk and are not suitable for all investors.
Review the Characteristics and Risks of Standardized Options brochure before you begin trading options. Options investors may lose the entire amount of their investment in a relatively short period of time.