MorningStar(Tenfore) DataFeed API调查笔记

公司的国际股票以及港股行情来自MorningStar公司,最近由于开发新的FeedHandler,因此对其API文档进行了研究,以下是研究笔记:


Tenfore DataFeed调查

 

1.       消息类型(message types)

#define TF_MSG_TYPE_UNDEF        0       // undefined

#defineTF_MSG_TYPE_TRADE        1        // trades

#defineTF_MSG_TYPE_QUOTE        2        // bid/ask

#defineTF_MSG_TYPE_RECAP        3        // refresh

#define TF_MSG_TYPE_ADMIN        4       // administration (in text format)

#define TF_MSG_TYPE_CONTROL      5       // control messages (reserved)

#define TF_MSG_TYPE_STATIC       6       // fundamental data

#defineTF_MSG_TYPE_DYNAMIC      7        // dynamic size messages(文档未提及,丢弃?)

#define TF_MSG_TYPE_OTHERS       8       // other messages

#defineTF_MSG_TYPE_CLOSE        9        // closing message

#define TF_MSG_TYPE_NEWS        10       // news message

#define TF_MSG_TYPE_CHART                  13                // chart update (msg 11 and 12 are usedinternal)

 

2.       证券类型(TF_SEC_TYPE_)

Value

Description

Translation

0

Invalid security type (should be ignored)

无效证券类型

1

Stocks, Warrants

股票/权证

2

Options

期权

3

Futures

期货

4

Future Options

期货期权

5

Spots

现货

6

Contract Specs

合约规格

7

Corporate Bonds

公司债券

8

Mutual Funds

共同基金

9

Government Bonds

政府债券

10

Indices

指数

11

Municipal Bonds

市政债券

12

News (currently not used)

新闻

13

Strategies & Spreads

策略及利差

14

Statistic Symbols

统计符号

15

Monetary Funds

货币资金

16

Unspecified Bonds

未指定的债券

17

Unspecified Funds & Certificates

未指定基金

18

Miscellaneous Securities

杂项证券

19

Money Market Symbols

货币市场符号

20

Forex Symbols

外汇符号

 

 

3.       API

TApiInitialize            // 初始化

TApiShutDown         // 关闭

TApiReadRecord      // 读数据包

TApiSaveDataToFile // 保存tenfore原始数据,供回放

TApiEmulateFeedServer  // 模拟Tenfore feedserver

TApiRealtimeFeedServer // 从模拟feedserver转换为实时feedserver

TApiSetReadDelay   // 当使用模拟feedserver时,设置回放速度

TApiFracToDouble    // 分数至double

TApiSetMarketFlag  //启动/关闭某市场

TApiSetNewsFlag              // 启动/关闭某新闻

TApiSetMessageFlag                 // 启动/关闭某消息

TApiSetSecurityFlag          // 启动/关闭某证券类型

TApiSetFieldFlag                // 启动/关闭某字段

TApiFieldToLong                 // 转换为long

TApiFieldToFloat                // 转换为float

TApiFieldToDouble            // 转换为double

。。。。。。

TApiGetNextField              // 获取下一个字段

TApiGetSymbol                            // 获取TF代码

 

4.      对Tenfore DataFeed的几点理解:

 

(1)    它的Ticker Plant对应wind feedserver,部署在MorningStar;它的Feedserver对应wind feedreceiver,部署在第三方服务器上. (SetFeed是可视化的tenfore feedserver)

Tenfore强烈推荐Feedserver与API部署在同一台电脑上。

 

QuoteSpeed Server是TenforeFeedServer的另一类下游程序,它与FeedServer通过IAPI进行通信

Basically the differencebetween the Broadcast API and the Interactive API is that the Interactive APIdelivers real time data only for requested symbol and not the complete feed

 

         受制于设计机制,FeedServer仅仅允许有一个客户端。

 

(2)    重要:不能使用Windows远程桌面连接Feedserver机器,而应该使用第三方工具,例如PC Anywhere等。

Important:        Themachine which is used to run Feedserver MUST NOT be accessed by Windows RDP. If a remote access is wanted,please use a tool like e.g.  Dameware, PCAnywhere, VNC.

 

(3)     Tenfore协议时间:The time is always Eastern Standard Time (EST in New York).

 

(4)     TApiInitialize不能连续调用两次。也即TApiInitialize与TApiShutDown需匹配调用

 

(5)    After a successful call to TApiInitialize () the Broadcast API based application should start readingthe feed and not perform other time consuming initialization tasks because theFeedServer will start immediately sending data and might overflow the verysmall RPC communication buffers.   (备注:TApiInitialize初始化后,应该马上开始接收数据)

 

(6)Tenfore强烈建议调用APITApiSet...Flag(nFlag, nId)进行数据过滤。

it ishighly recommended to explicitly enable or disable the markets, news, messagetypes, security types and fields an application wants to receive from theFeedServer. The reasons for this are quite obvious. First of all enabling onlythe desired data reduces the communication traffic between FeedServer andapplication (a program that wants to process only stocks from NYSE does notneed to receive data from any other market). The second and even more important reason is that anapplication does not know at startup what markets, news and so on are currentlyenabled in the FeedServer. Only after a restart of the FeedServer anapplication can be sure that all the data it expects to receive (matching theFeedServers subscription) is enabled.

 

最佳实践:A goodprogramming practice is to disable first e.g. all markets and then activateonly the desired markets.

即:

// 先禁用所有市场

TApiSetMarketFlag (-1, 0)

 

//然后启用某(几)个市场

TApiSetMarketFlag(TF_EXCHG_ID_NYSE,1);  // enable NYSE

TApiSetMarketFlag(TF_EXCHG_ID_NASD,1);  // enable NASDAQ

 

(7)    Tenfore全市场峰值包流量会突破100,000/s.因此Tenfore建议使用死循环进行异步数据接收,而不应该使用定时器。

In a Broadcast API application the processing of the messageshould not be too time consuming. Of course also a timer or any other periodicpolling mechanism could be used to read the messages but a Broadcast API basedapplication should be aware that the complete Morningstar Quotes feed easilycrosses 100,000 messages per second during the US opening (after 15:30 CET).

 

(8)     可以采用API: TAPIDataToString将RawData存储为明码文本

Record格式"<02.04.077.000.5>{0.11}XSF2HP10100{4.12}0.0089{5.8}50{114.11}R{1.4}354"

<msg.sec.mkt.submkt.flds>{fid.type}value1{fid.type}value2…

msg

Message type, for values see TF_MSG_TYPE_… definitions inTAPIdef.h

sec

Security type, for values see TF_SEC_TYPE_… definitions inTAPIdef.h

mkt

Exchange id, for values see TF_EXCHG_ID_… definitions inTAPIdef.h

submkt

Submarket (if different from mkt), for values see TF_EXCHG_ID_… definitions inTAPIdef.h. Default value id 0.

flds

# of following fields

fid

Field id, for values see TF_FIELD_… definitions inTAPIdef.h

type

Value type, for values see TF_VAL_TYPE_… definitions inTAPIdef.h

value..

The actual value in printable format. Binary data is displayed as a sequence of hex bytes.

 

(9)     API不是线程安全的

 

(10) BroadcastAPI: 提供单向数据流(DataFeed业务)

Interactive API:交互式API,交易使用(支持单只股票订阅与请求)

Desktop API:IAPI的受限版本(终端客户使用)

 

(11) 万得代码映射,需要产品部提供大力支持。

 

(12) field的id与类型不是一直匹配的

Anapplication should be aware that the combinations between field ids and valuetype are not fixed. I.e. a last price does not necessarily always have thefractional format it could use the double format instead.

 

(13) TApiPtr2Off (szBuffer)

TApiOff2Ptr(szBuffer)

提供了一种保存指针value的方法。(将指针内存转化为连续内存 list -> vector)

if ((size = TApiReadRecord (szBuffer)) > 0)

{

    // first convert pointers tooffsets

   TApiPtr2Off (szBuffer);

    // now save the message inanother location

    memcpy (szDest, szBuffer, size);

 

    // do something else

 

    // convert the offsets back topointers

   TApiOff2Ptr (szDest);

    // now process the messagesnormally

   ProcessTheBuffer (szDest);

}

 

(14) 实时数据(Realtime data)有四类:成交数据、报价数据、更新数据、新闻数据

 

(15)多数情况下可以用最新价来计算开高低收,但有例外。

If not specified differently in the messagewith a trade condition the last price of a trade message should be used tocalculate open/high/low/close values of a trading session.

 

例外情况:应该根据TF_FIELD_TRADE_COND来决定是否更新开高低收。

If supplied by the data source the trademessage might contain trade condition information. There are two levels oftrade conditions supported by the feed. The 1st level is an exchangeindependent condition transmitted with the field

 

TF_FIELD_TRADE_COND

 

that specifies whether a last price shouldupdate also open high low and/or composite symbol.

 

#defineTF_FIELD_TRADE_COND_LAST     0x01 /*update last price */

#defineTF_FIELD_TRADE_COND_HIGHLOW  0x02 /*update high/low values from last price */

#defineTF_FIELD_TRADE_COND_CMP      0x04 /*update composite symbol also */

#defineTF_FIELD_TRADE_COND_OPEN     0x08 /*update open value from last price */

#defineTF_FIELD_TRADE_COND_VOL      0x10 /*update only volume */

#defineTF_FIELD_TRADE_COND_DEFAULT (TF_FIELD_TRADE_COND_LAST | TF_FIELD_TRADE_COND_HIGHLOW |TF_FIELD_TRADE_COND_VOL)

 

注:TF_FIELD_TRADE_COND_CMP主要针对外汇。

For Forex symbolswithin markets 240, 241 and 242 the default value is to update composite symbolAAABBBCOMP as well.

In messages were fromthese markets a composite symbol should not be updated, the flag will be set to

 

TF_FIELD_TRADE_COND_LAST.

 

For all other Forexmarkets (243-250) the default is not to update the composite symbol. In cases,where the message should update the composite symbol, it will contain the flag

 

         TF_FIELD_TRADE_COND_CMP

 

The 2ndtrade condition level is an optional exchange specific value sent in the field

 

TF_FIELD_TRADE_IND

 

and contains the trade condition specifiedby the exchange (as close as possible). E.g. the Amsterdam Stock Exchange issending an “A” in this field to indicate that the last price is an adviceprice.

 

 

如果交易所发了总成交量过来,则以交易所为准。否则应该自己累积。

 

(16) Zero values (for bid/askprices or sizes) are intended by the exchange and normally used to clearoutstanding bids or asks.

0值的买卖价量用于清除买卖数据。

 

(17) 关于Close Messages。此消息用于标记交易所收盘。Closemessage之后的交易消息要么是延迟的交易序列或是预示着新的交易日开始

Any trade message following a close message would either bepart of a late trading session and not included in the close price calculationor open a new trading day.

 

没有消息体的close message意味着当前价就是收盘价

A close message does not necessarily need aclose field inside. Such a message without a close implies that the currentvalue is considered the official close price.

 

对期货或权证,结算价就是收盘价

For futures and future options thesettlement price is used to officially close an instrument.

 

(18) 静态数据与实时数据是严格分开的,否则预示着错误。

Due to the overlapping field ids a static message cannotcontain real time fields and real time messages (trade, quote, recap, andclose) can not contain static fields.

 

(19) 由于Admin消息与其他消息存在id重合问题,因此如果不需要Admin消息,不能简单调用API接口禁用,而应该在Application中手动禁用。

 

(20) 用三维度确定一个证券:<market code><security type><Ticker Symbol>

 

(21) 对美国股票,股票代码中的”.”被晨星用”/”替换了。(字符型)

对欧洲市场,他们使用了ISIN (International Securities Identification Number)来标记股票代码,但同时也提供了字符股票代码。Tenfore顺序:字符代码 –>本地证券标志 -> ISIN代码。

股票的第一个字符必须以大写字母或数字或以下之一的字符开头,!, $, @, #。首字符外的其他字符,则是大/小写字母,数字或是/,  _,  -

Examples:

 

IBM         Intl. Business Machines

MSFT        Microsoft (listed on NASDAQ)

MSF         Microsoft (listed in Germany)

RR/         Rolls Royce PLC(listed on LSE)

DTE         Deutsche Telekom (listed in Germany)

DT          Deutsche Telekom (listedon NYSE)

FTE         France Telecom (Paris)

NDX         NASDAQ 100 index

@CCO        NASDAQ composite index

!DJI        Dow Jones IndustrialAverage index

DAX         Deutscher Aktienindex

MIB30       MIB 30 index (Italy)

PX1         CAC40 index (France)

SX5E        Dow Jones Euro STOXX 50 index

GD-P        Previous Days ASEGeneral Index (Greece)

T1X         FTSE TechMark 100 index

394748      Dow Jones Euro STOXX Utilities Price index

 

(22) 对NASDAQ股票:它包含了1到4个字符,以及额外的后缀(不一定都有)。后缀值:

Code

Description

 

 

A

Class A

B

Class B

D

New

F

Foreign

G

First convertible Bond

H

Second Convertible Bond

I

Third Convertible Bond

J

Voting

K

Non-Voting

L

Miscellaneous situations such as certificates of participation, preferred participation, stubs, foreign when issued

M

Fourth preferred, same company

N

Third preferred, same company

O

Second preferred, same company

P

First preferred, same company

R

Rights

S

Shares of beneficial Interest (SBI)

T

With warrants or with rights

U

Units, same company

V

When Issued and when distributed

W

Warrants same company

X

Mutual Funds

Y

American Depository Receipts (ADRs)

Z

Miscellaneous situations such as certificates of preferred when issued.

 

(23) US Equity options (CBOE)

<spinoff><exp><strike>

<spinoff>  is a code for the underlying root symbol,several

          spinoffs for an underlying symbol can exist.

<exp>      one character code for the expirationmonth

          A = January Call

          B = February Call

          . . .

          L = December Call

          M = January Put

          N = February Put

          . . .

          X = December Put

<strike>   one character code for the strike price(there is no

          fixed lookup table for code – strike price, it is

          depending on the price of the underlying instrument)

 

Examples:

 

IBMJT   IBM 100 $ October 2001 Call Option

IBMVT   IBM 100 $ October 2001 Put Option

VIBAT   IBM 100 $ January 2002 Call Option

 

(24) Almost all non-US equity and future option have the following symbolformat:

 

<root><year><month><strike>

 

where

 

<root>    underlying root symbol (normally the symbolof the

         share or index (like DTE),it is for all options the

         same root symbol

<year>    1 digit year code (0 – 9)

<month>   1 character expiration month code

         A = January Call

          B = February Call

         . . .

         L = December Call

         M = January Put

         N = February Put

         . . .

         X = December Put

<strike>  explicit strike price without decimal point(for some

         exchanges a version number is added to the strike price

         e.g. after splits to make the symbol unique)

 

Examples:

 

DAX1J4500        DAX 4500 October 2001 Call option

DAX1V4500        DAX 4500 October 2001 Put option

DTE9S83          Deutsche Telekom  8 July 2009 PutOption version 3

VOD1J150         Vodaphone 150 GBPOctober 2001 Call option

 

(25) Forex Cross Rates

Forex cross rate symbols consist of the following parts:

 

<cur1><cur2><contr>

 

where

 

<cur1>   1st currency code of the crosrate (3 characters)

<cur2>   2nd currency code of the crosrate (3 characters)

<contr>  contributor code (4 characters)

 

Examples:

 

EURUSDBARC Euro – US $ cross rate from Barclays, London

CHFJPYOHA_ Swiss Franc – Japanese Yen, OHV Amsterdam

EURUSDCOMP Euro – US $ cross rate composite symbol

 

(26) TF_Field_TRADE_IND       - 138

交易指示标记,不同的市场,含义不同。

 

(27) 关于L2

L2提供两种发送方式,一是常规发送,即买卖5/10/20;二是用订单(orderbook)的方式发送。详细说明见文档FeedSpecs.doc的7.1章。总之,订单方式需要Application端重新排列。

 

(28) 市场(TF_EXCHG_ID_)

 

#defineTF_EXCHG_ID_BTDS             4  /* Bonds Trade Dessimination Service (TRACE)*/

 

#defineTF_EXCHG_ID_EAG            7 /* symbols generated by EAG (like INDU,UTIL,...) */

 

// 自由指标

#defineTF_EXCHG_ID_FREE_IND    9  /* Free Indices */

 

// 纳斯达克小盘股市场

#define TF_EXCHG_ID_SCAP             17  /* NTDS NASDAQ small cap stock market */

#defineTF_EXCHG_ID_BATS             17  /* BATS */

 

#defineTF_EXCHG_ID_ADF              18  /* NASDAQ ADF (Alternative Display Facility)*/

 

CTS场外交易股票(纽约证券交易所股票场外交易)

#define TF_EXCHG_ID_NASD                    20  /* for compatibility */

#defineTF_EXCHG_ID_CTS_OTC        20 /* CTS OTC equities */

 

#defineTF_EXCHG_ID_THIRD          23 /* NTDS NASDAQ listed third market */

 

NW18基准符号

#defineTF_EXCHG_ID_NW18_BENCH     78 /* NW18 benchmark market */

 

???

#defineTF_EXCHG_ID_BIFFEX_ROUTES 153  /* BIFFEX specific routes */

#define TF_EXCHG_ID_BIFFEX        154  /* BIFFEX headline service */

 

#define TF_EXCHG_ID_STOCKH        170  /* Stockholm */

#define TF_EXCHG_ID_STOCKH2       171  /* Stockholm II (indices) */

170 Stockholm(Equities) Also Iceland – differentiated by field S676

171 Stockholm(Indices) Also Iceland – differentiated by field S676

 

#define TF_EXCHG_ID_CEDMD         224  /* CED Borsa market depth */

#define TF_EXCHG_ID_CHIX          225  /* Chi-X */

 

#define TF_EXCHG_ID_TURQUOISE     226  /* Turquoise (03.03.09, mg) */

 

#define TF_EXCHG_ID_ICAP          244 /* ICAP */

 

(29) 晨星字段ID代码

//

// field definitions for error messages from the TICcard

// must not be transmitted to the end user

//

#define TF_FIELD_ERROR_CODE        28    // 4 TIC error code

#define TF_FIELD_ERROR_TEXT        29    // n TIC error text

 

AEX feed specific definitions

FIM feed specific definitions

SIA feed specific definitions

 

两类指标ID:

D: Dynamic

S: Statics (当前交易日内不变化的指标)

 


你可能感兴趣的:(api,Microsoft,application,character,Exchange,combinations)