Schwab Trader API - Streamer Guide
Schwab Trader API - Streamer Guide
The Streamer API enables clients to connect into different services to stream market data and
account activity with JSON-formatting via WebSockets. Authentication and entitlements are
provided via the Access token generated from the POST Token endpoint. Streamer information to
establish the connection can be found on the GET User Preference endpoint. Client as referenced
throughout this document is in reference to the application.
Contents
1. API Contract
Command Name
LOGIN Initial request when opening a new connection. This must be successful before
sending other commands.
SUBS Subscribes to a set of symbols or keys for a particular service. This overwrites all
previously subscribed symbols for that service. This is a convenient way to wipe out
old subscription list and start fresh, but it's not the most efficient. If you only want to
add one symbol to 300 already subscribed, use an ADD instead.
For example:
ADD Adds a new symbol for a particular service. This does NOT wipe out previous symbols
that were already subscribed. It is OK to use ADD for first subscription command
instead of SUBS.
For example:
UNSUBS This unsubscribes a symbol to a list of subscribed symbol for a particular service.
VIEW This changes the field subscription for a particular service. It will apply to all symbols
for that particular service.
LOGOUT Logs out of the streamer connection. Streamer will close the connection.
Example:
One Request
{
"requestid": "0",
"service": "LEVELONE_EQUITIES",
"command": "SUBS",
"SchwabClientCustomerId": "Someone",
"SchwabClientCorrelId": "3be0b7e7-5b8b-4fd3-9bed-7f49106cfe1",
"parameters": {
"keys": "AAPL",
"fields":
"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27
,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,5
2,53,54"
}
}
Multiple Requests
{
"requests": [
{
"requestid": "1",
"service": "ADMIN",
"command": "LOGIN",
"SchwabClientCustomerId": "Someone",
"SchwabClientCorrelId": "2be0b7e7-5b8b-4fd3-9bed-7f49106cfe1",
"parameters": {
"Authorization": "PN",
"SchwabClientChannel": "IO",
"SchwabClientFunctionId": "Tradeticket"
}
},
{
"requestid":"3",
"service":"LEVELONE_EQUITIES",
"command":"SUBS",
"SchwabClientCustomerId":"Someone",
"SchwabClientCorrelId":"2be0b7e7-5b8b-4fd3-9bed-7f49106cfe1",
"parameters":{
"keys":"AAPL",
"fields":"0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19"
}
}
]
}
A client response will consist of an array of one or more responses. Each response will include:
Response Request Name Parameter
Type
{"notify":[{"heartbeat":"1668715930582"}]}
{
"response": [
{
"service": "LEVELONE_EQUITIES",
"command": "SUBS",
"requestid": "0",
"SchwabClientCorrelId": "3be0b7e7-5b8b-4fd3-9bed-7f49106cfe1",
"timestamp": 1668715930582,
"content": {
"code": 0,
"msg": "SUBS command succeeded"
}
}
]
}
{
"data": [
{
"service": "LEVELONE_EQUITIES",
"timestamp": 1668715930585,
"command": "SUBS",
"content": [
{
"1": 149.81,
"2": 149.82,
"3": 149.811,
"4": 4,
"5": 2,
"6": "Q",
"7": "P",
"8": 56049058,
"9": 300,
"10": 151.48,
"11": 146.15,
"12": " ",
"13": 142.41,
"14": "Q",
"15": false,
"16": "APPLE INC",
"17": "D",
"18": 146.43,
"19": 7.401,
"20": 182.94,
"21": 129.04,
"22": 0.04062,
"23": 0,
"24": 0,
"25": 0,
"26": "NASDAQ",
"27": "",
"28": true,
"29": true,
"30": 149.811,
"31": 300,
"32": 7.401,
"33": "Normal",
"34": 149.811,
"35": 1668715930570,
"36": 1668715930345,
"37": 1668715930345,
"38": 1668715930570,
"39": 1668715930522,
"40": "XNAS",
"41": "ARCX",
"42": "XADF",
"43": 5.19696651,
"44": 5.19696651,
"45": 7.401,
"46": 5.19696651,
"key": "AAPL",
"delayed": false
}
]
}
]
}
Common causes:
• Client does not wait for a
successful LOGIN response
and issues a command
immediately after the
LOGIN command. There
could be a race condition
where the SUB is processed
before the LOGIN.
• Client
modifies SchwabClientCusto
merId or
SchwabClientCorrelId after
logging in.
• Streamer has disconnected
the client while processing
the command.
22 FAILED_COMMAND_SUBS Subscribe No
Should be investigated by Trader API
command
team. Please contact
could not
TraderAPI@Schwab.com if you see
be
this with the `schwabClientCorrelId`
completed
of subscription.
successfull
y Common causes:
23 FAILED_COMMAND_UNSUBS Unsubscrib
e
command
could not
be • Two or more commands are
completed processed in parallel
successfull causing one to fail.
y
24 FAILED_COMMAND_ADD Add
command
could not
be
completed
successfull
y
25 FAILED_COMMAND_VIEW View
command
could not
be
completed
successfull
y
27 SUCCEEDED_COMMAND_UN Unsubscrib
SUBS e
command
completed
successfull
y
28 SUCCEEDED_COMMAND_AD Add
D command
completed
successfull
y
29 SUCCEEDED_COMMAND_VIE View
W command
completed
successfull
y
All Sequence All data is streamed to the client and includes a sequence number. Data is not conflated
by the streamer although the underlying source of the data may conflate.
Change Only fields that clients are interested in, and have changed, are streamed to the
client. Data is conflated by the streamer.
All Sequence All data is streamed to the client and includes a sequence number. Data is not conflated
by the streamer although the underlying source of the data may conflate.
2 Admin Services
service ADMIN
command LOGIN
{
"response": [
{
"service": "ADMIN",
"command": "LOGIN",
"requestid": "1",
"SchwabClientCorrelId": "5be0b7e7-5b8b-4fd3-9bed-7f49106cfe96",
"timestamp": 1669828276886,
"content": {
"code": 0,
"msg": "server=s0166bdv-1;status=PN"
}
}
]
}
Login Denied
{
"response": [
{
"service": "ADMIN",
"command": "LOGIN",
"requestid": "1",
"SchwabClientCorrelId": "5be0b7e7-5b8b-4fd3-9bed-7f49106cfe96",
"timestamp": 1669828982588,
"content": {
"code": 3,
"msg": "Login Denied.: token is invalid or has expired."
}
}
]
}
2.3 Logout request
Streamer Contract name Type Length Description
requestid Integer Variable Unique number that will identify this request.
SchwabClientCustomerId String Variable Identifies the page or source in the channel where
quote is being called from (5 alphanumeric).
service ADMIN
command LOGOUT
{
"response": [
{
"service": "ADMIN",
"command": "LOGOUT",
"requestid": "0",
"SchwabClientCorrelId": "5be0b7e7-5b8b-4fd3-9bed-7f49106cfe95",
"timestamp": 1669830137089,
"content": {
"code": 0,
"msg": "SUCCESS"
}
}
]
}
3 LEVELONE Services
3.1 LEVELONE_EQUITIES
Level One Equities Request
e.g. AAPL,TSLA,IBM
Outside of fields that can be subscribed to, Streamer also returns initial data that indicates whether the
data is real time or NFL (delayed).
Field Name Type Field Description Notes, Examples
Source
assetSubType String Asset sub type ADR, CEF, COE, ETF, ETN, GDR, OEF, PRF, RGT,
UIT, WAR
cusip String 9 digits CUSIP CUSIP number for the instrument, such
as 594918104
4 Bid Size int Number of shares for bid Units are "lots" (typically 100 shares
per lot)
5 Ask Size int Number of shares for ask See bid size notes.
8 Total Volume long Aggregated shares traded Volume is set to zero at 7:28am ET.
throughout the day, including
pre/post market hours.
9 Last Size long Number of shares traded with Units are shares
last trade
10 High Price double Day's high trade price According to industry standard,
only regular session trades set the
High and Low.
11 Low Price double Day's low trade price See High Price notes
12 Close Price double Previous day's closing price Closing prices are updated from
the DB at 3:30 AM ET.
13 Exchange ID char Primary "listing" Exchange As long as the symbol is valid, this
data is always present
Indicator : Realtime
Only
Indices 0 Realtime
Only
Mutual 3 Realtime
Fund Only
NASDAQ Q Both
NYSE N Both
Pacific P Both
Pinks 9 Realtime
Only
OTCBB U Realtime
Only
15 Description String A company, index or fund Once per day descriptions are
name loaded from the database at
7:29:50 AM ET.
19 52 Week High double Higest price traded in the past Calculated by merging intraday
12 months, or 52 weeks high (from fh) and 52-week high
(from db)
20 52 Week Low double Lowest price traded in the past Calculated by merging intraday low
12 months, or 52 weeks (from fh) and 52-week low (from
db)
34 Quote Time in Long Last time a bid or ask updated The difference, measured in
Long in milliseconds since Epoch milliseconds, between the time an
event occurs and midnight, January
1, 1970 UTC.
35 Trade Time in Long Last trade time in milliseconds The difference, measured in
Long since Epoch milliseconds, between the time an
event occurs and midnight, January
1, 1970 UTC.
37 Bid Time long Last bid time in milliseconds The difference, measured in
since Epoch milliseconds, between the time an
event occurs and midnight, January
1, 1970 UTC.
38 Ask Time long Last ask time in milliseconds The difference, measured in
since Epoch milliseconds, between the time an
event occurs and midnight, January
1, 1970 UTC.
0 = false
1 = true
0 = false
3.2 LEVELONE_OPTIONS
RRRRRRYYMMDDsWWWWWddd
Where:
If a stock
does not
trade in the
regular
session, high
and low will
be zero.
High/low
reset to zero
at 3:30am ET
6 Low Price double Day's low trade price Yes No See High
Price notes
13 Multiplier double
In the pre-
market
session, open
is blank
because pre-
market
session
trades do not
set the open.
Open is set
to ZERO at
7:28 ET.
22 Underlying String
23 Expiration int
Month
24 Deliverables String
28 Delta double
29 Gamma double
30 Theta double
31 Vega double
32 Rho double
34 Theoretical double
Option Value
35 Underlying double
Price
36 UV Expiration char
Type
45 Mark Price Net double Mark price net change Yes Yes 7.97
Change
48 isPennyPilot boolean
3.3 LEVELONE_FUTURES
Schwab-standard format:
Common roots:
28 Future Price String Display in N/A N/A Set from FSP Config
Format fraction or
decimal format is <numerator
format. decimals to
display>,<implied
denominator>
price=101.8203125
=101 +
0.8203125 (split into
whole and fractional)
=101 +
26.25/32 (Multiply
fractional by implied
denomiator)
=101 +
26.2/32 (round to
numerator decimals to
display)
=101'262 (
display in fractional format)
36 Expiration String
Style
If the DST-flag is present for Futures Trading Hours (field 29), please see the following hours for DST
days:
https://www.cmegroup.com/confluence/display/EPICSANDBOX/Fractional+Pricing+-
+Display+Examples
3.4 LEVELONE_FUTURES_OPTIONS
Schwab-standard format:
• F: January
• G: February
• H: March
• J: April
• K: May
• M: June
• N: July
• Q: August
• U: September
• V: October
• X: November
• Z: December
e.g.: ./OZCZ23C565
6 Bid ID char Exchange with the Yes Yes Currently "?" for
bid unknown as all quotes
are CME
7 Ask ID char Exchange with the Yes Yes Currently "?" for
ask unknown as all quotes
are CME
18 Open double
Interest
27 Expiration String
Style
28 Contract Char
Type
29 Security String Yes Yes Indicates a symbol's
Status current trading status:
Normal, Halted, Closed
3.5 LEVELONE_FOREX
e.g.: EUR/USD,USD/JPY,AUD/CAD
13 Exchange char
26 Market String
Maker
4 BOOK Services
e.g.: AAPL,TSLA,IBM
2 Bid Side Levels Price Levels Array Bid side price levels
3 Ask Side Levels Price Levels Array Ask side price levels
Field #
2 Market Maker Count int Number of Market Makers in this price level
3 Array of Market Array Array of market maker sizes for this price level
Makers
Book Market Makers Sub-Field for Streamer
Field #
1 Size long Size of the Market Maker for this price level
2 Quote Time long Quote time in milliseconds for this Market Maker's quote
5 CHART Services
5.1 CHART_EQUITY
Chart Equity Request for Streamer
e.g.: AAPL,TSLA,IBM
5.2 CHART_FUTURES
Chart Futures Request for Streamer
Schwab-standard format:
• F: January
• G: February
• H: March
• J: April
• K: May
• M: June
• N: July
• Q: August
• U: September
• V: October
• X: November
• Z: December
Common roots:
6 SCREENER services
(PREFIX)_(SORTFIELD)_(FREQUENCY)
• VOLUME, TRADES,
PERCENT_CHANGE_UP,
PERCENT_CHANGE_DOWN,
AVERAGE_PERCENT_VOLUME
• 0, 1, 5, 10, 30 60 minutes (0 is
for all day)
7 ACCOUNT services
7.1 ACCT_ACTIVITY
Account Activity Request for Streamer
Example:
{
"requests": [
{
"service": "ACCT_ACTIVITY",
"requestid": "2",
"command": "SUBS",
"SchwabClientCustomerId": "Someone",
"SchwabClientCorrelId": "f308b89-19a7-2d18-4a0a-1c5e7120336",
"parameters": {
"keys": "Account Activity",
"fields": "0,1,2,3"
}
}
]
}
Response:
Fields Field Type Value
Name
"seq" Sequence Integer This field identifies the message number. If client reconnects and
receives the same seq number again, it can choose to ignore the
duplicate.
"key" Key String Passed back to the client from the request to identify a subscription
this response belongs to.
3 Message String The core data for the message. Either JSON-formatted data
Data describing the update, NULL in some cases, or plain text in case of
ERROR.