Manually Create a Basket File

We highly recommend that you first create a TWS basket file from a trading page using several different order types and products. Then open the sample file in Excel and use this as your starting point to edit the fields and create new rows. The key to the basket file is the relationship between the header row and order rows. The header row tells TWS what values the subsequent orders must include. A header row for a market order includes the OrderType field, while the header row for a limit order requires both the OrderType and LmtPrice fields.

The basket file is formatted as follows:  

Header Row (For order type x)
Order Row (order type x)
Order Row (order type x)
Order Row  (order type x) etc.
Header Row (For order type y)

Order Row (order type y)
Order Row (order type y) etc.

The Header Row includes field titles for each order value. The Order Row includes order values that correspond with each field title, with a one-to-one relationship between header fields and order values.

You must use multiple Header Rows in a basket file to accommodate orders with different fields. For example, a market order needs eight fields, but a limit order needs nine, since you have to define a limit price. These two order types would require different header rows, as shown below:

Action,Quantity,Symbol,SecType,Exchange,Currency,TimeInForce,OrderType
BUY,100,IBM,STK,SMART/ARCA,USD,DAY,MKT
BUY,100,GE,STK,SMART/ARCA,USD,DAY,MKT

Action,Quantity,Symbol,SecType,Exchange,Currency,TimeInForce,OrderType,LmtPrice
BUY,100,IBM,STK,SMART/ARCA,USD,DAY,LMT,14.82
BUY,100,GE,STK,SMART/ARCA,USD,DAY,LMT,18.98

The Sample Excel Basket File topic shows how a basket file with multiple order types would look in Excel.

Notes about creating basket files:

The major differences between the original and improved basket file formats include:

Old Basket File

New Basket File

Old version supported only limited number of pre-defined fields.

New version supports all TWS fields.

Old version required you to enter order values in a specific sequence.

New version does not require any specific order sequence for fields.

Old version required only order values (since the "header" fields were hard-coded into TWS).

New version requires a header row with order-specific field titles. Use multiple header rows in a single basket for order types that require different field values.

Old version required blank placeholders for values that were not required.

New version requires an exact one-to-one relationship between a header field and an order value; you cannot leave an order field blank if there is a header field defined.

Old version was saved as .bsk (TWS-specific) file.

New version uses .csv (generic) file extension.*

*Please note that TWS remains backward-compatible with the original .bsk basket file format.

Basket Fields

The table below list some of the fields you can specify in your basket order. We recommend creating sample file rows via the TWS basket creation process to see any fields you may have a question about.

 

Some Basket File Header Fields/Order Values

Contract Description Fields

Header Field

Order Values

Symbol

e.g. IBM, AMZN

SecType

The security type including stk, opt, fut, fop, war, cash, fund, efp, bag*

Use the bag security type for spreads and combination orders.

Expiry

YYYYMM

e.g. 200910 (for Oct. 2009 expiry)

Strike

e.g. 42.5 or 37.0

Right

P or C

Currency

e.g. USD

Exchange

Any valid destination, e.g. Smart, or NYSE or PHLX or VWAP or IBEFP.

NOTE: To clarify any ambiguity for Smart routed contracts, include the primary exchange along with Smart for the destination, for example: Smart/NYSE.

Basic Order Fields

Header Field

Order Values

Action

BUY or SELL

Quantity

e.g. 100 or 1

OrderType

Order types as supported in TWS.

LmtPrice

e.g. 96.47 or 96

 

For EFPs, use a decimal number for the raw price, or a percent value followed by A or C to designate Annualized or Compounded rate, for example 5.200%A.**

AuxPrice

e.g. .05 or 1.25 or 2

 

PercentOffset

Any decimal value between 0 and 1, e.g. .05  

BasketTag

Any unique string of alpha or numeric characters used to identify the basket order. This tag appears in the Order Reference field of the Trade report.

Time in Force Fields

Header Field

Order Values

TimeInForce

e.g. day, gtc, gtd, ioc, fok, opg, auc

GoodTilDate

YYYYMMDD hh:mm:ss [zzz] where zzz is an optional time zone. If you do not designate a time zone, TWS uses the time zone from which the order originated.

GoodAfter

YYYYMMDD hh:mm:ss [zzz] where zzz is an optional time zone. If you do not designate a time zone, TWS uses the time zone from which the order originated.

Advisor Fields

Header Field

Order Values

Account

Existing account number.

Group

Existing Account Group name.

Method

Allocation Method, valid if a Group is named.

  • PctChange

  • AvailableEquity

  • NetLiq

  • EqualQuantity

  • PctOfPortfolio

Percent

Use if Method = PctChange.

Profile

Existing Allocation Profile name.

Non-Cleared Fields

Header Field

Order Values

Account

Account number.

OpenClose

e.g. open, close

ShortLocation

MPID of third party

ShortSale

-1 (cust. has shares)

-2 (shares are with 3rd party)

Clearing

Identify your clearing choice.

ClearingAccount

Identity of the true beneficiary of the order.

Volatility Fields

Header Field

Order Values

ReferencePriceType

A (average of best bid/ask) or B (NBB when buying a call or selling a put;  NBO when selling a call or buying a put)

 

HedgeOrderType

Lmt, Mkt or Rel

HedgeAuxPrice

Use to set the price if HedgeOrderType is used.

StockRangeLower

Low stock price of the range used to cancel the order if the underlying price falls below.

StockRangeUpper

High stock price of the range used to cancel the order if the underlying price goes above.

ContinuousUpdate

True. If you don't want to use continuous update do not include the field in the header row.

Miscellaneous Fields

Header Field

Order Values

Algo maxPctVol

Max percent of volume for option algo.

Algo riskAversion

Get done, Aggressive, Neutral, Passive

Algo forceCompletion

True

DiscretionaryAmt

Price off the limit price to create Discretionary order.

DisplaySize

Defines the quantity of the order to be made public, creates an Iceberg order.

OutsideRth

True to allow order to trigger or fill outside regular trading hours.

BlockOrder

True

SweepToFill

True

Hidden

True

AllOrNone

True

MinimumQuantity

Number for minimum acceptable fill quantity for order to execute.

OcaGroup

Value that IDs order as part of a group.