MBT Historical API 1.0 - MB Trading
MBT Historical API 1.0 - MB Trading
MBT Historical API 1.0 - MB Trading
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
__________________________________________________________________________________________<br />
<strong><strong>MB</strong>T</strong><br />
<strong>Historical</strong> <strong>API</strong> <strong>1.0</strong><br />
<strong>MB</strong> <strong>Trading</strong><br />
1926 E. Maple 1st Floor<br />
El Segundo, CA 90245-3001<br />
Reference Number Version <strong>1.0</strong><br />
Drafted 10/05/2009<br />
Last Updated 10/06/2009<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Table Of Contents<br />
Introduction..................................................................................................................................................3<br />
Connection....................................................................................................................................................3<br />
Request Format............................................................................................................................................4<br />
Required parameters............................. .........................................................................................................4<br />
Optional parameters........................................................................................................................................4<br />
Response Format..........................................................................................................................................5<br />
Success Responses............................................................................................................................................5<br />
Error responses.................................................................................................................................................5<br />
Tick Bars.......................................................................................................................................................6<br />
Minute Bars..................................................................................................................................................7<br />
Day Bars........................................................................................................................................................8<br />
Appendices....................................................................................................................................................9<br />
Appendix A: HistErrorType............................................................................................................................................9<br />
Appendix B: Indicator values.......................................................................................................................................10<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Introduction<br />
This document details the expected and supported inbound and outbound message formats<br />
encountered specific to the <strong><strong>MB</strong>T</strong> <strong>Historical</strong> Server.<br />
Connection<br />
The <strong><strong>MB</strong>T</strong> <strong>Historical</strong> Server accepts standard http connections, currently using port 80. Connections<br />
are stateless, with a single request, acknowledged by a single response. There is no continuing<br />
session, and the socket will be closed when data (or error information) has been returned. Data may<br />
be requested in both XML and CSV format, both using optional ZLIB compression.<br />
To obtain the proper IP/dns name for the target historical data server and session token, prior to<br />
login, a client application must send a secure https POST request to:<br />
https://www.mbtrading.com/secure/getquoteserverxml.asp?<br />
username=EnterMyUsername&password=EnterMyPassword<br />
along with two required parameters, 'username' and 'password'. Both of these parameters must be<br />
sent in plain text (though the request URL is secure). The webserver will return an XML record set in<br />
the following format (demo credential used in example):<br />
<br />
<br />
<br />
This script may return an IP or DNS name, as well as a folder (as shown), which may or may not end<br />
in ‘/’ so clients should code defensively. Only the hist_server IP/path applies to historical requests.<br />
The SessionToken returned has an associated expiration returned in SessionTokenExpire, after which<br />
time further requests will result in error responses. It is suggested that client applications proactively<br />
keep track of the expiration time, requerying this script immediately prior to the next request after<br />
expiration.<br />
The following html page demonstrates this request using a browser-based form, though a direct https<br />
request is what most clients will likely utilize:<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Request Format<br />
Requests are sent to the server in the form of http GET requests, with the format of:<br />
http://[ip or dns_including_folder]/[request handler].ashx/?[one-or-more-field=value-parameters]<br />
Most parameters are common amongst all request types, though Period, which applies to only Day<br />
and Minute Bars, has special meaning depending upon the request type.<br />
Required parameters<br />
SessionToken - session value obtained from a prior GetQuoteServer request.<br />
Symbol - security symbol in standard <strong><strong>MB</strong>T</strong> format.<br />
Optional parameters<br />
StartTime - Date/time for first record in EST/EDT [YYYY-MM-DD HH:MM:SS]<br />
EndTime - Date/time for last record in EST/EDT [YYYY-MM-DD HH:MM:SS]<br />
Optionally, the space between date and time may be replaced with ‘T’; it may also be escaped as<br />
‘%20’. Only the date portion of either Time parameter is required for DayBars. Data is streamed<br />
from beginning with the most recent records (EndTime), going back in time.<br />
MaxRecs - Integer: the maximum # of recs to return (subject to server-defined limit).<br />
RequestID - Client application-defined integer value, will be echoed back to client in result<br />
ResponseType - XML (default), or CSV<br />
Period - # days / seconds to combine into each bar (see DayBars / TickBars below)<br />
Compress - a value of 1 for this field is sent to request GZIP compression of response. This may also<br />
be requested by including the "Accept-Encoding: gzip" HTTP header in the request. NOTE: small<br />
responses, as well as responses returned during periods of heavy server activity, may result in an<br />
uncompressed response; it is therefore imperative that a client handle both compressed and<br />
uncompressed responses. When a response is compressed, the Content-Encoding=GZIP header will<br />
be contained in the response header.<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Response Format<br />
Requests will result in success, returning valid data, or an error response, indicating a reason.<br />
Success Responses<br />
Successful requests will result in a reply containing either valid XML or CSV-formatted data. Both<br />
contain fields specific to the particular bar-type requested. The general format is:<br />
<br />
[ID of server]<br />
[client-supplied-value] <br />
… <br />
<br />
ServerID=[ID of server]<br />
RequestID=[client-supplied-value<br />
Count=[number of records returned]<br />
[column header definition]<br />
[one or more records…]<br />
Error responses<br />
Error responses are common among all request types and result in a reply containing an error code<br />
(see Appendix A “HistErrorType”), serverID, and optional client-supplied requestID. XML<br />
responses may also include a “message” to provide more detail.<br />
XML-format:<br />
<br />
[ID of server]<br />
[client-supplied-value] <br />
Example:<br />
<br />
<br />
MbtHist01<br />
1234<br />
<br />
Tick Bars<br />
Request handler:<br />
GetTickBars.ashx<br />
Fields returned:<br />
Date: timestamp of record<br />
Price: price or record<br />
Size: volume of record<br />
Type: type of record. (Currently only available value is 0=Trade). Bid/ask may be returned in future<br />
versions of the <strong>API</strong>; therefore it is suggested that current applications ignore records containing<br />
values other than 0.<br />
Indicator: see Appendix B “Indicator values”.<br />
Sample XML format request/response:<br />
http://histdata.mbtrading.com/MbtHist/GetTickBars.ashx?<br />
Symbol=EUR/USD&RequestID=1234&SessionToken=8316093812120891212718263897569239136124537672n11<br />
904212012386875&MaxRecs=5<br />
<br />
MbtHist01 1234 <br />
<br />
<br />
Sample CSV format request/response:<br />
http://histdata.mbtrading.com/MbtHist/GetTickBars.ashx?<br />
Symbol=EUR/USD&SessionToken=8316093812120891212718263897569239136124537672n11904212012386875<br />
&RequestID=1234&MaxRecs=5&ResponseType=CSV<br />
ServerID=MbtHist01<br />
RequestID=1234<br />
Count=5<br />
Date,Price,Size,Type,Indicator<br />
2009-10-05 12:20:18,1.46434,600,0,0<br />
2009-10-05 12:20:15,1.46432,600,0,0<br />
2009-10-05 12:20:14,1.46434,600,0,0<br />
2009-10-05 12:20:14,1.46434,600,0,0<br />
2009-10-05 12:20:14,1.46434,500,0,0<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Minute Bars<br />
Request handler:<br />
GetMinBars.ashx<br />
Bar-type specific optional request parameter:<br />
Period - #seconds per bar. 0 or 60: (default) minute bars.<br />
300: 5 minute bars<br />
900: 15 minute bars<br />
3600: hourly bars<br />
(This value must currently be a multiple of 60 (even-minutes) or an error will be returned).<br />
Fields returned:<br />
Date: timestamp of record<br />
Open: opening price of period<br />
High: high price of period<br />
Low: low price of period<br />
Close: closing price of period<br />
Volume: total volume of period<br />
Sample XML format request/response:<br />
http://216.52.236.37/MbtHist/GetMinBars.ashx?<br />
Symbol=EUR/USD&SessionToken=8316093812120891212718263897569239136124537672n11904212012386875<br />
&StartTime=2009-10-05T09:30&EndTime=2009-10-05T09:35&RequestID=1234<br />
<br />
<br />
MbtHist01<br />
1234<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Sample CSV format request/response:<br />
http://216.52.236.37/MbtHist/GetMinBars.ashx?<br />
Symbol=EUR/USD&SessionToken=8316093812120891212718263897569239136124537672n11904212012386875<br />
&StartTime=2009-10-05T2009:30&EndTime=2009-10-05T2009:35&RequestID=1234&ResponseType=CSV<br />
ServerID=MbtHist01<br />
RequestID=1234<br />
Count=6<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Date,Open,High,Low,Close,Volume<br />
2009-10-05 09:35:00,1.46039,1.46049,1.45939,1.4599,73303<br />
2009-10-05 09:34:00,1.46025,1.46037,1.46005,1.46036,25300<br />
2009-10-05 09:33:00,1.46021,1.46032,1.4601,1.4603,44400<br />
2009-10-05 09:32:00,1.45984,1.46019,1.45969,1.46019,62700<br />
2009-10-05 09:31:00,1.4604,1.46052,1.45984,1.45984,55400<br />
2009-10-05 09:30:00,1.4605,1.4605,1.46004,1.4604,57000<br />
Day Bars<br />
Request handler:<br />
GetDayBars.ashx<br />
Bar-type specific optional request parameter:<br />
Period - 0 or 1: (default) daily bars<br />
>= 2: # days compressed into each bar.<br />
-1: calendar weekly (Sun-Sat)<br />
-2: calendar monthly<br />
-3: annual<br />
-4: quarterly<br />
Fields returned:<br />
Date: timestamp of record<br />
Open: opening price of period<br />
High: high price of period<br />
Low: low price of period<br />
Close: closing price of period<br />
Volume: daily=total volume during period; multiple days (including<br />
weekly/monthly/annual)=average daily volume<br />
Sample XML format request/response:<br />
http://216.52.236.37/MbtHist/GetDayBars.ashx?<br />
Symbol=EUR/USD&SessionToken=8316093812120891212718263897569239136124537672n11904212012386875<br />
&RequestID=1234&EndTime=2009-09-30&Period=-1&MaxRecs=6<br />
<br />
<br />
MbtHist01<br />
1234<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Sample CSV format request/response:<br />
http://216.52.236.37/MbtHist/GetDayBars.ashx?<br />
Symbol=EUR/USD&SessionToken=8316093812120891212718263897569239136124537672n11904212012386875<br />
&RequestID=1234&EndTime=2009-09-30&Period=-1&MaxRecs=6&ResponseType=CSV<br />
ServerID=MbtHist01 RequestID=1234 Count=6 Date,Open,High,Low,Close,Volume 2009-09-<br />
27,1.4701,1.47193,1.45269,1.46362,86571415 2009-09-20,1.46998,1.48439,1.46115,1.46874,77433808 2009-09-<br />
13,1.46022,1.4767,1.45151,1.47074,59759947 2009-09-06,1.43003,1.46347,1.4298,1.45703,68759811 2009-08-<br />
30,1.43076,1.43773,1.41771,1.42951,87021711 2009-08-23,1.43309,1.44063,1.42063,1.43028,106979356<br />
Appendices<br />
Appendix A: HistErrorType<br />
Error codes returned will contain one of the following values:<br />
public enum class HistErrorType<br />
{<br />
[Description("Success")] NoError = 0,<br />
[Description("Maintenance in progress")] MaintInProgress = 11,<br />
[Description("Invalid request")] InvalidRequest = 12,<br />
[Description("MbtHistService unavailable")] MbtHistServiceUnavailable = 13,<br />
[Description("Memory allocation error")] MemoryAlloc = 14,<br />
[Description("No request for data")] NoRequestData = 15,<br />
[Description("General remote error")] GeneralRemote = 16,<br />
[Description("Invalid parameter")] InvalidParameter = 17,<br />
[Description("Invalid session token")] InvalidSessionToken = 18,<br />
[Description("User locked out")] LockedOut = 19,<br />
[Description("Internal database error ")] InternalDatabaseError = 20,<br />
[Description("Not entitled")] NotEntitled = 21,<br />
[Description("General exception")] GeneralException = 22,<br />
[Description("Disconnected")] Disconnected = 23,<br />
[Description("Server unavailable")] Unavailable = 24,<br />
[Description("Invalid symbol")] InvalidSymbol = 25,<br />
[Description("Invalid time")] InvalidTime = 26,<br />
[Description("Remote timeout")] RemoteTimeout = 27<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
Appendix B: Indicator values<br />
Most trades will return 0 for an indicator. While in reality only a handful of the following indicators<br />
(such as Form T) are typically encountered, the entire list of possible values follows for<br />
completeness.<br />
// Trade Indicators<br />
#define TI_REGULAR_SALE 0<br />
#define TI_ACQUISITION 1<br />
#define TI_DISTRIBUTION 2<br />
#define TI_SPLIT 3<br />
#define TI_RESERVED_SALE 4<br />
#define TI_CASH_SALE 5<br />
#define TI_NEXT_DAY_SALE 6<br />
#define TI_SELLER_SALE 7<br />
#define TI_RULE_155 8<br />
#define TI_SOLD_LAST_SALE 9<br />
#define TI_OPENED_SALE 10 // Late and out of sequence report of the open.<br />
#define TI_OUT_OF_SEQ 11<br />
#define TI_CANCEL_VOL 12<br />
#define TI_CANCEL_LAST 13<br />
#define TI_CANCEL_OPEN 14<br />
#define TI_CANCEL_ONLY 15<br />
#define TI_CANCEL_STOPPED 16<br />
#define TI_REOPEN 17<br />
#define TI_ADJUSTED 18<br />
#define TI_SPREAD 19<br />
#define TI_STRADDLE 20<br />
#define TI_STOPPED 21<br />
#define TI_BUNCHED 22<br />
#define TI_BUNCHED_SOLD 23<br />
#define TI_VOLUME_ONLY 24<br />
#define TI_FUTURE_TRADE 25<br />
#define TI_PREMIUM 26<br />
#define TI_MID_PRICE 27<br />
#define TI_SETTLEMENT 28<br />
#define TI_FORM_T 29<br />
#define TI_LATE_OPEN 30<br />
#define TI_AUTO_EXECUTE 31<br />
#define TI_INTRADAY_DETAIL 32<br />
#define TI_OPENING_DETAIL 33<br />
#define TI_RULE_127 34<br />
#define TI_OVERNIGHT_TRADE 35<br />
#define TI_DELAYED_TRADE 36<br />
#define TI_AGENCY_CROSS 37<br />
#define TI_AGENCY_CROSS_FORWARD 38<br />
#define TI_FAST_MARKET 39<br />
#define TI_OPEN_INTEREST 40<br />
#define TI_OPEN_PRICE 41<br />
#define TI_HIGH_PRICE 42<br />
#define TI_LOW_PRICE 43<br />
#define TI_SPOT_PRICE 44<br />
#define TI_VALUATION_PRICE 45<br />
#define TI_LAST_SALE_TELEKURS 46<br />
#define TI_X_DIVIDEND 47<br />
#define TI_OPTION_INIT 48<br />
#define TI_CLOSE_PRICE 49<br />
#define TI_SUMMARY_PRICE 50<br />
#define TI_EARLIER_THAN_YESTERDAY_PRICE 51<br />
#define TI_CO<strong>MB</strong>O 52 // C<strong>MB</strong>O spread trade, OPRA, BJB, 11/28/2001<br />
#define TI_AVERAGE_PRICE 53<br />
#define TI_BURST_BASKET 54<br />
#define TI_INTERMARKET_SWEEP 54 // Replaces burst basket in ects<br />
#define TI_AUTOMATIC_SWEEP 55<br />
#define TI_ODDLOT 56 // non-board lot trade in Canada<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
#define TI_INACTIVE_ISSUER 57 // Canada - inactive issuer (also known as "shell company")<br />
#define TI_C<strong>API</strong>TAL_POOL_COMPANY 58 // Canada - capital pool company (also known as "CPC)<br />
#define TI_OFFICIAL_CLOSING_PRICE 59<br />
#define TI_PAID_BID_TK 60<br />
#define TI_PAID_ASK_TK 61<br />
#define TI_DRAWING_PRICE_TK 62<br />
#define TI_TRADING_HALT_TK 63<br />
#define TI_DRAWING_PRICE_FORWARD_TK 64<br />
#define TI_DELETE_PREV_INDEX 65<br />
#define TI_FORCED_PRICE 66<br />
#define TI_BARGAIN_CONDITION 67<br />
#define TI_OVERSEAS_CROSS 68<br />
#define TI_CROSSED 69<br />
#define TI_FRENCH_COMM_REFERENCE 70<br />
#define TI_BLOCKED 71<br />
#define TI_JAKARTA_CROSSED 72<br />
#define TI_BR_ODD_LOT 73<br />
#define TI_COMPENSATION 74<br />
#define TI_REPORTED_OUTSIDE 75<br />
#define TI_EUROPE_ODD_LOT 76<br />
#define TI_PRIOR_REFERENCE_PRICE 77 // NTDS "P"(Prior Reference Price) sale<br />
#define TI_AUTOMATIC_EXECUTION 78 // NYSE Direct+ Automatic Execution System sale<br />
#define TI_NO_HIGH_LOW 79<br />
#define TI_PREVIOUS_DAY 87<br />
#define TI_CANCEL_VOLUME 88<br />
#define TI_INDICATIVE_TRADE 89<br />
#define TI_SPECIAL_TRADE_ASX 90<br />
#define TI_CUM_DIV_TRADE_ASX 91<br />
#define TI_EX_DIV_TRADE_ASX 92<br />
#define TI_LATE_TRADE_ASX 93<br />
#define TI_LSE_BLK_TRD_PREV_DAY 94 // Bridge code "BD"<br />
#define TI_LSE_BLK_TRD_SAME_DAY 95 // Bridge code "BL"<br />
#define TI_CUM_VOLUME 97<br />
#define TI_INACTIVE_BOARD 99 // Canada - refers to Canada's inactive board<br />
#define TI_BASIS_TRADE 101<br />
#define TI_CONTINGENT_TRADE 102<br />
#define TI_SPECIAL_TRADING_SESSION 103<br />
#define TI_CANADA_VWAP 104<br />
#define TI_BROKER_TO_BROKER 105<br />
#define TI_DE_PART_PD_BID_QUOTE 106<br />
#define TI_DE_PART_PD_ASK_QUOTE 107<br />
#define TI_NON_PROTECTED_PORTFOLIO 108<br />
#define TI_DE_OFFICIAL_PRICE 109<br />
#define TI_NE_PAID_BID 110<br />
#define TI_NE_PAID_ASK 111<br />
#define TI_PROTECTED_PORTFOLIO 112<br />
#define TI_DE_REPESENT_PRICE 113<br />
#define TI_DE_RATIONED_BID 114<br />
#define TI_DE_RATIONED_ASK 115<br />
#define TI_DE_CANCELED_BID 116<br />
#define TI_DE_CANCELED_ASK 117<br />
#define TI_REGULAR_SALE_ETH 143<br />
#define TI_SOLD_LAST_SALE_ETH 144<br />
#define TI_OPENED_SALE_ETH 145<br />
#define TI_OUT_OF_SEQUENCE_ETH 146<br />
#define TI_CANCEL_VOL_ETH 147<br />
#define TI_CANCEL_LAST_ETH 148<br />
#define TI_CANCEL_OPEN_ETH 149<br />
#define TI_CANCEL_ONLY_ETH 150<br />
#define TI_CANCEL_STOPPED_ETH 151<br />
#define TI_REOPEN_ETH 152<br />
#define TI_ADJUSTED_ETH 153<br />
#define TI_SPREAD_ETH 154<br />
#define TI_STRADDLE_ETH 155<br />
#define TI_STOPPED_ETH 156<br />
#define TI_LATE_OPEN_ETH 157<br />
#define TI_AUTO_EXECUTE_ETH 158<br />
#define TI_CO<strong>MB</strong>O_ETH 159<br />
#define TI_STOPPED_SOLD_LAST_SALE 160<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.
#define TI_STOPPED_OUT_OF_SEQUENCE 161<br />
#define TI_OFFICIAL_OPENING_PRICE 166<br />
#define TI_CANCEL_OFFICIAL_OPENING_PRICE 167<br />
#define TI_YELLOWFLAG 170<br />
#define TI_EXCEPTIONAL_ASSET_ALLOCATION 171 // type A<br />
#define TI_EXCEPTIONAL_WHOLESALE_TRADE 172 // type B<br />
#define TI_EXCEPTIONAL_AGAINST_ACTUAL 173 // type G<br />
#define TI_EXCEPTIONAL_ASSET_BASIS 174 // type S<br />
#define TI_EXCEPTIONAL_EXCHANGE_FOR_PHYSICAL 175 // Type E<br />
#define TI_EXCEPTIONAL_AVE_PRICE_5_MIN 176 // type F<br />
#define TI_EXCEPTIONAL_MATCH_CROSS_TRADE 177 // type H<br />
#define TI_EXCEPTIONAL_AVE_PRICE_1_MIN 179 // type O<br />
#define TI_EXCEPTIONAL_EXCHANGE_FOR_PHYSICAL_2 180 // type P<br />
#define TI_EXCEPTIONAL_EXCHANGE_FOR_RISK 181 // type R<br />
#define TI_EXCEPTIONAL_EXCHANGE_FOR_OPTION 182 // type U<br />
#define TI_EXCEPTIONAL_EXCHANGE_FOR_SWAPS 183 // type W<br />
#define TI_CANADA_MOC_TRADE 187<br />
#define TI_DUAL_SIDE_TRADE_CONTRA 190<br />
#define TI_BLOCK_TRADE 191<br />
#define TI_MM_TO_MM 192<br />
#define TI_NOT_TO_MARK 193<br />
#define TI_NON_RISK 194<br />
#define TI_RISKLESS_AT_DIFF_PRICE 195<br />
#define TI_OPTION 196<br />
#define TI_RISK_TRADE 197<br />
#define TI_SEAQ_TRADE 198<br />
#define TI_STOCK_SWAP 199<br />
#define TI_UNCROSSING_TRADE 200<br />
#define TI_PROTECTION_APPLIED 201<br />
#define TI_PREVIOUS_DAY_CONTRA 202<br />
#define TI_SINGLE_PROTECTED_TRADE 203<br />
#define TI_WORKED_PRINCIPAL_NOTIFICATION 204<br />
#define TI_WORKED_PRINCIPAL 205<br />
#define TI_CONTRA_TRADE 206<br />
#define TI_AUTO_INPUT_DISABLE 207<br />
#define TI_PRINCIPLE_PORTFOLIO 208<br />
#define TI_VWAP 209<br />
#define TI_AUTO_VWAP 210<br />
#define TI_VWAP_NO_UPDATE 211<br />
#define TI_BENCHMARK 212<br />
#define TI_TRADE_THRU_STOPPED 213<br />
Proprietary Information. Copyright © 2009 <strong>MB</strong> <strong>Trading</strong>. ALL RIGHTS RESERVED.