問題與回覆


Current Reference from GET Systems

張貼者:2011年2月21日 下午7:40Wei-Xiuang Wang   [ 已更新 2011年2月21日 下午7:43 ]


SenderOrdID|TargetOrdID|OrdStatus|Symbol|Side|OrdType|Px|StopPx|OrdQty|LastPx|LastQty|LeaveQty|DateTime

SenderOrdID: 下單編號
TargetOrdI:上手下單編號

OrdStatus:委託單狀態
0: New
1. Partial Filled
2. Filled
3: Pending New
4: Pending Cancel
5: Pending Replace
6. Canceled
7: Replaced
8: Cancel Reject
9: Replace Reject

OrdType:
1: Market Order
2: Limit Order
3. Stop Order
4. Oco Order

LastPx:成交價格
LastQty:成交數量
LeaveQty:剩餘數量

IB/Tws Generic Tick Types, Tick Values

張貼者:2011年2月8日 下午6:38Wei-Xiuang Wang   [ 已更新 2011年2月8日 下午7:05 ]


Generic Tick Types

For all socket-based API technologies, including the socket client library, ActiveX and Java, we provide several types of market data ticks that can be requested as a part of the market data request.

Starting with API version 9.0 (client version 30), version 6 of the REQ_MKT_DATA message is sent containing a new field that specifies the requested ticks as a list of comma-delimited integer Ids (generic tick types). Requests for these ticks will be answered if the tick type requested pertains to the contract at issue.

Note that Generic Tick Tags cannot be specified if you elect to use the Snapshot market data subscription.

The generic market data tick types are:

Integer ID Value

Tick Type

Resulting Tick Value (see list below)

100

Option Volume (currently for stocks)

29, 30

101

Option Open Interest (currently for stocks)

27, 28

104

Historical Volatility (currently for stocks)

23

106

Option Implied Volatility (currently for stocks)

24

162

Index Future Premium

31

165

Miscellaneous Stats

15, 16, 17, 18, 19, 20, 21

221

Mark Price (used in TWS P&L computations)

37

225

Auction values (volume, price and imbalance)

34, 35, 36

236

Shortable (see “Tick Values” for more information)

46

Tick Values

The Resulting Tick Values are:

Tick Values

Description

0

BID_SIZE

1

BID

2

ASK

3

ASK_SIZE

4

LAST

5

LAST_SIZE

6

HIGH

7

LOW

8

VOLUME

9

CLOSE

10

BID_OPTION_COMPUTATION

11

ASK_OPTION_COMPUTATION

12

LAST_OPTION_COMPUTATION

13

MODEL_OPTION

14

OPEN


Tick Values

Description

15

LOW_13_WEEK

16

HIGH_13_WEEK

17

LOW_26_WEEK

18

HIGH_26_WEEK

19

LOW_52_WEEK

20

HIGH_52_WEEK

21

AVG_VOLUME

23

OPTION_HISTORICAL_VOL

24

OPTION_IMPLIED_VOL

27

OPTION_CALL_OPEN_INTEREST

28

OPTION_PUT_OPEN_INTEREST

29

OPTION_CALL_VOLUME

30

OPTION_PUT_VOLUME

31

INDEX_FUTURE_PREMIUM

34

AUCTION_VOLUME

35

AUCTION_PRICE

36

AUCTION_IMBALANCE

37

MARK_PRICE

46

SHORTABLE

47

FUNDAMENTAL_RATIOS

The Shortable tick tells whether SHORT SELL orders for a contract will be accepted.  The value returned from the tickGeneric(int tickerId, int tickType, double value) method can be analyzed as follows:

if (value > 2.5) { // 3.0

   // There are at least 1000 shares available for a short sale

   }

else if (value > 1.5) { // 2.0

   // This contract will be available for short sale if shares can be       located

   }

   else if (value > 0.5) { // 1.0

   // Not available for short sale

   }

   else {

   // unknown value

   }

Note:   This feature is supported as of server version 33 (872 release of TWS).

TAG Values for FUNDAMENTAL_RATIOS tickType

The FUNDAMENTAL_RATIOS tickType (Tick Value 47) lets you request fundamental ratios in the form TAG=VALUE, TAG2=VALUE2, and so on. This ratios are sent using the tickGeneric() callback. The following table lists all the TAG values for FUNDAMENTAL_RATIOS.

TAG

Description

NPRICE

Closing Price
This is the closing price for the issue from the day it last traded. It is also referred to as the Current Price. Note that some issues may not trade every day, and therefore it is possible for this price to come from a date prior to the last business day.

Three_Year_TTM_
Growth

3 year trailing twelve months growth.

TTM_over_TTM

Trailing twelve months over trailing twelve months.

NHIG

High Price
This price is the highest price the stock traded at in the last 12 months. This could be an intra-day high.

NLOW

Low Price
This price is the lowest price the stock traded at in the last 12 months. This could be an intra-day low.

PDATE

Pricing date
The pricing date is the date at which the issue was last priced.

VOL10DAVG

Volume
This is the daily average of the cumulative trading volume for the last ten days.

MKTCAP

Market capitalization
This value is calculated by multiplying the current Price by the current number of shares outstanding.

TTMEPSXCLX

EPS excluding extraordinary items
This is the Adjusted Income Available to Common Stockholders for the trailing twelve months divided by the trailing twelve month Diluted Weighted Average Shares Outstanding.

AEPSNORM

EPS Normalized
This is the Normalized Income Available to Common Stockholders for the most recent annual period divided by the same period's Diluted Weighted Average Shares Outstanding.

TTMREVPS

Revenue/share
This value is the trailing twelve month Total Revenue divided by the Average Diluted Shares Outstanding for the trailing twelve months.

Note:   Most banks and insurance companies do not report revenues when they announce their preliminary quarterly financial results in the press. When this happens, the trailing twelve month values will not be available (NA).

QBVPS

Book value (Common Equity) per share
This is defined as the Common Shareholder's Equity divided by the Shares Outstanding at the end of the most recent interim period. Book Value is the Total Shareholder's Equity minus Preferred Stock and Redeemable Preferred Stock.

QTANBVPS

Book value (tangible) per share
This is the interim Tangible Book Value divided by the Shares Outstanding at the end of the most recent interim period. Tangible Book Value is the Book Value minus Goodwill and Intangible Assets for the same period.

QCSHPS

Cash per share
This is the Total Cash plus Short Term Investments divided by the Shares Outstanding at the end of the most recent interim period.

Note:   This does NOT include cash equivalents that may be reported under long term assets.

TTMCFSHR

Cash Flow per share
This value is the trailing twelve month Cash Flow divided by the trailing twelve month Average Shares Outstanding. Cash Flow is defined as the sum of Income After Taxes minus Preferred Dividends and General Partner Distributions plus Depreciation, Depletion and Amortization.

TTMDIVSHR

Dividends per share
This is the sum of the Cash Dividends per share paid to common stockholders during the last trailing twelve month period.

IAD

Dividend rate
This value is the total of the expected dividend payments over the next twelve months. It is generally the most recent cash dividend paid or declared multiplied by the dividend payment frequency, plus any recurring extra dividends.

PEEXCLXOR

P/E excluding extraordinary items
This ratio is calculated by dividing the current Price by the sum of the Diluted Earnings Per Share from continuing operations BEFORE Extraordinary Items and Accounting Changes over the last four interim periods.

APENORM

P/E Normalized
This is the Current Price divided by the latest annual Normalized Earnings Per Share value.

TMPR2REV

Price to sales
This is the current Price divided by the Sales Per Share for the trailing twelve months. If there is a preliminary earnings announcement for an interim period that has recently ended, the revenue (sales) values from this announcement will be used in calculating the trailing twelve month revenue per share. NOTE: Most Banks and Finance companies do not report revenues when they announce their preliminary interim financial results in the press. When this happens, the trailing twelve month values will not be available (NA) until the complete interim filing is released.

PR2TANBK

Price to Tangible Book
This is the Current Price divided by the latest annual Tangible Book Value Per Share. Tangible Book Value Per Share is defined as Book Value minus Goodwill and Intangible Assets divided by the Shares Outstanding at the end of the fiscal period.

TTMPRCFPS

Price to Cash Flow per share
This is the current Price divided by Cash Flow Per Share for the trailing twelve months. Cash Flow is defined as Income After Taxes minus Preferred Dividends and General Partner Distributions plus Depreciation, Depletion and Amortization.

PRICE2BK

Price to Book
This is the Current Price divided by the latest interim period Book Value Per Share.

QCURRATIO

Current ratio
This is the ratio of Total Current Assets for the most recent interim period divided by Total Current Liabilities for the same period. NOTE: This item is Not Available (NA) for Banks, Insurance companies and other companies that do not distinguish between current and long term assets and liabilities.

QQUICKRATI

Quick ratio
Also known as the Acid Test Ratio, this ratio is defined as Cash plus Short Term Investments plus Accounts Receivable for the most recent interim period divided by the Total Current Liabilities for the same period. NOTE: This item is Not Available (NA) for Banks, Insurance companies and other companies that do not distinguish between current and long term assets and liabilities.

QLTD2EQ

LT debt/equity
This ratio is the Total Long Term Debt for the most recent interim period divided by Total Shareholder Equity for the same period.

QTOTD2EQ

Total debt/total equity
This ratio is Total Debt for the most recent interim period divided by Total Shareholder Equity for the same period. NOTE: This is Not Meaningful (NM) for banks.

TTMPAYRAT

Payout ratio
This ratio is the percentage of the Primary/Basic Earnings Per Share Excluding Extraordinary Items paid to common stockholders in the form of cash dividends during the trailing twelve months.

TTMREV

Revenue
This is the sum of all revenue (sales) reported for all operating divisions for the most recent TTM period. NOTE: Most banks and Insurance companies do not report revenues when they announce their preliminary quarterly financial results in the press. When this happens, the quarterly value will not be available (NA).

TTMEBITD

EBITD
Earnings Before Interest, Taxes, Depreciation and Amortization (EBITDA) is EBIT for the trailing twelve months plus the same period's Depreciation and Amortization expenses (from the Statement of Cash Flows). NOTE: This item is only available for Industrial and Utility companies.

TTMEBT

Earnings before taxes
Also known as Pretax Income and Earnings Before Taxes, this is Total Revenue for the most recent TTM period minus Total Expenses plus Non-operating Income (Expenses) for the same period.

TTMNIAC

Net Income available to common
This is the trailing twelve month dollar amount accruing to common shareholders for dividends and retained earnings. Income Available to Common Shareholders is calculated as trailing twelve month Income After Taxes plus Minority Interest and Equity in Affiliates plus Preferred Dividends, General Partner Distributions and US GAAP Adjustments. NOTE: Any adjustment that is negative (ie. Preferred Stock Dividends) would be subtracted from Income After Taxes.

AEBTNORM

Earnings before taxes Normalized
This is the Income Before Tax number excluding the impact of all unusual/one-time/special charges items for the most recent annual period.

ANIACNORM

Net Income Available to Common, Normalized
This is the annual dollar amount accruing to common shareholders for dividends and retained earnings excluding the impact of all unusual/one-time/special charges items.

TTMGROSMGN

Gross Margin
This value measures the percent of revenue left after paying all direct production expenses. It is calculated as the trailing 12 months Total Revenue minus the trailing 12 months Cost of Goods Sold divided by the trailing 12 months Total Revenue and multiplied by 100. NOTE: This item is only available for Industrial and Utility companies.

TTMNPMGN

Net Profit Margin %
Also known as Return on Sales, this value is the Income After Taxes for the trailing twelve months divided by Total Revenue for the same period and is expressed as a percentage. NOTE: Most Banks and Finance companies do not report revenues when they announce their preliminary quarterly financial results in the press. When this happens, the trailing twelve month value will not be available (NA).

TTMOPMGN

Operating margin
This value measures the percent of revenues remaining after paying all operating expenses. It is calculated as the trailing 12 months Operating Income divided by the trailing 12 months Total Revenue, multiplied by 100. Operating Income is defined as Total Revenue minus Total Operating Expenses.

APTMGNPCT

Pretax margin
This value represents Income Before Taxes for the most recent fiscal year expressed as a percent of Total Revenue for the most recent fiscal year.

TTMROAPCT

Return on average assets
This value is the Income After Taxes for the trailing twelve months divided by the Average Total Assets,expressed as a percentage. Average Total Assets is calculated by adding the Total Assets for the 5 most recent quarters and dividing by 5.

TTMROEPCT

Return on average equity
This value is the Income Available to Common Stockholders for the trailing twelve months divided by the Average Common Equity and is expressed as a percentage. Average Common Equity is calculated by adding the Common Equity for the 5 most recent quarters and dividing by 5.

TTMROIPCT

Return on investment
This value is the trailing twelve month Income After Taxes divided by the average Total Long Term Debt, Other Long Term Liabilities and Shareholders Equity, expressed as a percentage.

REVCHNGYR

Revenue Change %
This value is calculated as the most recent interim period Sales minus the Sales for the same interim period 1 year ago divided by the Sales for the same interim period one year ago, multiplied by 100.

TTMREVCHG

Revenue Change %
This is the percent change in the trailing twelve month Sales as compared to the same trailing twelve month period one year ago. It is calculated as the trailing twelve month Sales minus the trailing twelve month Sales one year ago divided by the trailing twelve month Sales one year ago, multiplied by 100.

REVTRENDGR

Revenue growth rate
The Five Year Revenue Growth Rate is the annual compounded growth rate of Revenues over the last 5 years.

EPSCHNGYR

EPS Change %
This value is calculated as the most recent interim period EPS minus the EPS for the same interim period 1 year ago divided by the EPS for the same interim period one year ago, multiplied by 100. NOTE: EPS must be positive for both periods. If either EPS value is negative, the result in Not Meaningful (NM).

TTMEPSCHG

EPS Change %
This is the percent change in the trailing twelve month EPS as compared to the same trailing twelve month period one year ago. It is calculated as the trailing twelve month EPS minus the trailing twelve month EPS one year ago divided by the trailing twelve month EPS one year ago, multiplied by 100. NOTE: If either value has a negative value, the resulting value will be Not Meaningful (NM).

EPSTRENDGR

EPS growth rate
This growth rate is the compound annual growth rate of Earnings Per Share Excluding Extraordinary Items and Discontinued Operations over the last 5 years. NOTE: If the value for either the most recent year or the oldest year is zero or negative, the growth rate cannot be calculated and a 'NA' (Not Available) code will be used.

DIVGRPCT

Growth rate % - dividend
The Dividend Growth Rate is the compound annual growth rate in dividends per share. DIVGR% is calculated for 3 years whenever 4 years of dividends are available.


Ref1: http://www.ibyingtou.com/php/apiUsersGuide/apiguide/api/generic_tick_types.htm
Ref2: http://www.ibyingtou.com/php/apiUsersGuide/apiguide/api/tick_values.htm#XREF_tick_values_generic_tick

Channel Status的通知與運作方式

張貼者:2010年12月19日 上午5:51Wei-Xiuang Wang   [ 已更新 2010年12月19日 上午6:17 ]


例舉

依通訊規格說明
Status/Cmd
67 ('C') : App <== Channel
Channel Status Notify ( 79('O'): online, 88('X'): offline, 45('-'): disconnect)
狀態說明
'O': online - 該Channel於頂端ATS中處於可交易之狀態
'X': offline - 該Channel於頂端ATS中處於不可交易之狀態
'-': disconnect - 該Channel於連線通路中,某個ATG結點對應連線為斷線狀態
假設有架構為 [ATS] <===> [ATG2] <===> [ATG1]
於 [ATS] 上有提供有 Channel 8801 與 8803 兩個下單通路,
而 [ATG2] 則是將 8801 與 8803 對應到 [ATS] 主機上,
另外 [ATG1] 則是將 8801 與 8803 對應到 [ATG2] 主機上

當所有通路連線正常狀態下,
任何AP連上 [ATS] 或 [ATG1] 或 [ATG2] 皆會收到以下通知
Channel=8801.Status=67.Result=79.Msg=online.
Channel=8803.Status=67.Result=79.Msg=online.

代表兩個通路 8801,8803 皆為可交易之狀態

倘若此時 [ATG1] 對 [ATG2] 之連線中斷,連接於 [ATG1] 的AP會收到以下通知
Channel=8801.Status=67.Result=45.Msg=disconnect.
Channel=8803.Status=67.Result=45.Msg=disconnect.

代表兩通路於某個ATG結點對應連線為斷線狀態,
此時如果 [ATG1] 對 [ATG2] 之連線恢復正常,立即會再收到
Channel=8801.Status=67.Result=79.Msg=online.
Channel=8803.Status=67.Result=79.Msg=online.

同樣的狀況若發生於 [ATS] 與 [ATG2] 之間,則連接於 [ATG1] 與 [ATG2] 的AP皆會有如上相同的訊息反應

而如果是 [ATS] 上, Channel 8803 對實際券商下單處理連線狀態為斷線或異常,
所有AP不論連結於 [ATS] 或 [ATG2] 或 [ATG1] 皆將收到以下通知
Channel=8803.Status=67.Result=88.Msg=offline.
代表 Channel 8803 目前為無法下單之狀態

也就是 online / offline 兩種狀態為由頂端 [ATS] 針對實際下單連線的直接狀態回應,
而 disconnect 則是整個通路系統中,某個 [ATG] 節點有網路連線中斷的情形


Gateway幾個問題

張貼者:2010年12月19日 上午5:40Wei-Xiuang Wang   [ 已更新 2020年5月30日 下午8:18 ]


問題

目前Gateway大致上運作順暢...

有幾個問題想請教...

Gateway上為啥要用 MAP 8801=6600來對應呢???這是比較想不懂的

另外...Server上 O X F 這三個按鈕是做什麼的???我好像按了之後單子就送不出去了...

最後一個...單子送到Gateway之後...訊息也送回來告訴我說單子在Gateway已收到了...
但這時的Server是掛掉的...也就是說單子在Gateway上...但沒有Server可以幫他把單子轉送出去...
要是我把Server重開...那這張單會在連接上的時候立刻轉送出去嗎???
1.
Gateway上用 MAP 8801=6600 只是示範,可以依自己的概念作設計
6600是代表一個主機HOST可以是Trader Server或GateWay,
於你所看到的設定中,是於MAP之前透過 ADD 6600=127.0.0.1:22820 作編號給予代碼6600表示主機 127.0.0.1:22820
而8801是指一個Channel的交易通路, MAP 8801=6600 代表所有下單到通路 8801 Channel 的單會被送往 127.0.0.1:22820

GateWay上可以設定多台下單Server主機HOST(或GateWay),可以一一透過 ADD 給一個編號作代碼
而各通路Channel實際路由主機或GateWay則透過MAP給予指示
例如
ADD 6600=127.0.0.1:22820
ADD 6601=test1.trader.com.tw:33388
ADD 4567=test2.trader.com.tw:33388
ADD 8801=test3.trader.com.tw:33388
MAP 8801=6600
MAP 8802=6600
MAP 8803=6600
MAP 6601=6601
MAP 6602=4567
MAP 6603=8801
以上代表
通路Channel 8801,8802,8803的單皆會被下至 127.0.0.1:22820
通路Channel 6601 的單會被下至 test1.trader.com.tw:33388
通路Channel 6602 的單會被下至 test2.trader.com.tw:33388
通路Channel 6603 的單會被下至 test3.trader.com.tw:33388
MAP時的Channel編號與ADD時的主機編號是兩回事,
上面故意作有重複的示範供參考思考
而如果某個HOST例如 test2.trader.com.tw:33388 其實又是個GateWay
則再依該GateWay上設定之原則作通路轉送

2.
Server上的 O X F 基本上是不需要用的,也不會造成單子送不出去(請再確認)
O 可以讓視窗立即更新(原本每秒自動會刷新)
F 是字體環境切換,原本會顯示簡體字,按了變成繁體環境則會看到亂碼,再按就又恢復簡體
X 完全沒用

3.
所有單下出去只要沒收到Inser成功就是失敗
Status=0只是在告知通路的運作情形
Status=1才是告知下單是否成功
所有通路正常下一定會收到Status=1的結果
而如果通路中間有某個GateWay或最末端的Trader Server是掛掉的
會於Status=0的狀態下即會告知失敗
不會有任何單是卡在GateWay或TraderServer上的而是直接回覆失敗!!
(訊息也如之前所提, Result=0: faild! , 1: success , 2: Disabled{目前無法交易} , 3: UnMapping{系統未配置的頻道} )
你說Server掛掉,應該會收到Status=0,Result=2
請麻煩再確認一下,可以的話把逐筆接收到之訊息Log附上
(以上,代表不會有卡單問題,也沒有系統重開重送單的問題,只有AP收到失敗的處理方式而已)

問題

非常清楚...感謝...

那問題來了...

當我下命令 Console 8801 330001 "IF1012|B3700" 時

Console.exe 這個檔怎麼知道要去哪邊找Gateway的service呢...

也就是說...Console怎麼知道要把單子送到哪台電腦的Gateway去???

因為我看Console那邊只有一個dll檔...所以是不是被你包在裡面了呢...

如果是的話那就這樣...也無所謂...我只是確定以後這隻程式需不需要自己maintain而已...
Console只是一個使用dll的範例程式
http://site.edu.wwx.tw/ftw/Home/pei-zi-jiao-yi-tong-lu-xi-tong/atsc-api
透過API可以指定直接連結ATS或連ATG
此Console範例是
if (fnATSCdll_Start("localhost:22821"))
所以是連 127.0.0.1 的GateWay
因此同一機器上所跑的GateWay怎麼設就怎麼送
實際上AP設計就是透過API來操作
(Console只是示範API的用法而已)

當然也可以把GateWay的設定改成放在ini檔中便於改設定, 程式則改由ini檔讀入,
如果有需要也可增加命令列參數是可以指定GateWay的格式方式...
也就是參考這隻Console程式可以自行開發任意需求的應用程式,不限開發工具,
未必要以命令列方式來應用, 也是能設計成有GUI介面操作的視窗軟體(例如像是IB提供的測試工具)

PS: 參考於Python上使用DLL裡的API呼叫範例, 只要有好用的dll, 外行人也都能輕鬆開發自己合用的專屬應用程式

第 1 個 - 第 4 個,共 4 個