- ago
I've tried almost every data source including extensions. Most only provides US stocks data. That "Stooq" has Hongkong stocks data, but comapred to HK Exchanges the data is not correct.
The only one left is Interactive broker. I don't know what's the stock code pattern for hongkong stocks. For example, Tencent Holdings is 700. I tried 700, 0700, 00700, or 700.HK, neither could get any data.
0
550
Solved
12 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.98% )
- ago
#1
For IB non-U.S. stocks, you'll need to use the explicit specification to define that contract (see Help > Interactive Brokers).

However, if you have a large number of these, which you probably do, you can shortcut the explicit specification as follows:

1. Close Wealth-Lab 7
2. File > Open Wealth-Lab User Data Folder
3. Find and open the IBContracts.txt file

You'll see records like this:
A=A|USD|STK|SMART|NYSE
AAL=AAL|USD|STK|SMART|NASDAQ
AAP=AAP|USD|STK|SMART|NYSE

You need to enter a record for each of your contracts as follows
700=700|HKD|STK|SEHK|SEHK

The first symbol could be any unique one you want to use in Wealth-Lab., e.g.,
TNCT700=700|HKD|STK|SEHK|SEHK

4. Save the file and launch Wealth-Lab.
5. Open a chart and enter your symbol 700 (or TNCT700 if you used that name) and it should work.

Always remember that you must have data permissions for the symbols you request.


1
Best Answer
- ago
#2
I wouldn't consider Stooq for this. Yahoo! Finance has always had free HK data. Please give Yahoo a try.

Also, what data feeds are most used in Hong Kong - free and subscription-based? Maybe we could look into them with a view to create a data provider.
0
Cone8
 ( 4.98% )
- ago
#3
Follow up for using Interactive Brokers -

You also need to create a Market in Tools > Markets & Symbols for the SEHK exchange, otherwise the data will be assigned to the US Market, which won't work for intraday data.

I was just looking at the Trading Session hours, and it looks like SEHK only opens twice a week from about 09:30 - 16:10 max. Enter those hours and the time zone -(UTC+08:00) Hongkong - so that your data is timestamped correctly. If you have any trouble, let me know.

Unfortunately for now, you'll need to manually select the market (SEHK) at the bottom of charts (or enter all the symbols in Market and Symbols). There's a bug in the IB Provider when assigning the market to stocks if it's not U.S.
0
- ago
#4
Thanks for the reply. This explict specification really works for HongKong stocks, so I will continue work with IB data.
Besides, do you know how to write the explict specification for "Shanghai-Hong Kong Stock Connect program" stocks through IB, e.g.,
CH.600048=600048|CNH|STK|SEHKNTL|SEHKNTL
and it "returned null".
And there is a US ETF called "KWEB" also "returned null", which I want to add to my portfolio too. i saw this code was in IBContracts.txt by default. It looks like this:
KWEB=KWEB|USD|STK|SMART|ARCA|KWEB|||0|

No matter I modified it to
KWEB=KWEB|USD|STK|SMART|ARCA
nor I just deleted this line for it is just a US stocks,
I got "returned null" every time.
0
- ago
#5
Yahoo did have HK stock data in the past days. But not any more today.
0
- ago
#6
There is a new problem i encountered when I run a backtest strategy : "Historical data pre-emptively ended" triggers a exit signal, but I did not intend to close a position only when data ended. And Actually, data does not end, maybe it is just a holiday event. How to stop this exit signal?
0
- ago
#7
QUOTE:
Yahoo did have HK stock data in the past days. But not any more today.

Since it's a free feed, Yahoo may be a bit slower to update its data. In general, you should look for it the next day.
0
Cone8
 ( 4.98% )
- ago
#8
QUOTE:
And Actually, data does not end, maybe it is just a holiday event. How to stop this exit signal?
Did you create a Market for SEHK in Tools > Markets & Symbols?

I don't know anything about SEHK, but based on the symbol "700" it appeared to me that SEHK is open only two days a week.



For this, you should create a corresponding SEHK market. Hopefully it's the same for all symbols on SEHK, otherwise you'll need to create a New Market for each one. Let us know.

Also, if you can give us a list of the exchange holidays, we could include it for easy selection.
1
Cone8
 ( 4.98% )
- ago
#9
I just noticed we have a market for "Hong Kong Stock Exchange". However, we don't have a holiday list yet, and I see that it was closed 1-3 Feb due to the New Year.

We'll add a holiday list for Hong Kong Stock Exchange Build 48. If you specify symbols with SEHK, the IB adapter will properly assign the "Hong Kong Stock Exchange".

Note, for the HSI benchmark, you can enter this record in IBContracts.txt. (Only make edits to that file when Wealth-Lab is shut down.)

HSI=HSI|HKD|IND|HKFE||HSI
0
- ago
#10
Some Chinese holiday like this "Spring festival” this week use a different Calendar(Lunar Calendar) so the Date and Month varies every year. Maybe the best way is to figure out how to read holiday list from HK Exchanges.

By the way, do you know how to write the explicit specification for Shanghai stocks and the KWEB etf?
0
- ago
#11
QUOTE:
Some Chinese holiday like this "Spring festival” this week use a different Calendar(Lunar Calendar) so the Date and Month varies every year. Maybe the best way is to figure out how to read holiday list from HK Exchanges.

That's what we're going to do for B48: act simple and take the holiday list from hkex.com.hk (2022) and other resources (for some years back).

Ideally, we could determine the ever changing dates based on the Lunar calendar programmatically but it's not on the table right now.
0
Cone8
 ( 4.98% )
- ago
#12
I missed your Post #4..
Always keep in mind that you must have permissions for the data you request. Even if you can see a chart in TWS, it doesn't automatically mean that it will be available through the API to clients like Wealth-Lab. Your account must have the permissions for the data.

Re: KWEB
When you see a long record like this in IBContracts.txt..
KWEB=KWEB|USD|STK|SMART|ARCA|KWEB|||0|
.. it means that the contract was found and recorded. I have the same record and it returns data for me. In TWS there's a note that KEWB cannot be traded by retail clients. Even so, I don't know why it wouldn't return data for you.

QUOTE:
explict specification for "Shanghai-Hong Kong Stock Connect program" stocks

If you use the explicit specification, you need to start with the symbol TWS uses. You may need to specify the multiplier (use 1 for stocks) and the Local Name or Local Class, which you can in the symbol details (right click in TWS).

Anyway, IB found the contract with this specification. .
600048;STK;CNH;SEHKNTL;1;600048

.. which created this record
600048=600048|CNH|STK|SEHKNTL|SEHKNTL|600048|||0|1

With WL7 Closed, you can change the first symbol to the one you want to use in Wealth-Lab:
CH.600048=600048|CNH|STK|SEHKNTL|SEHKNTL|600048|||0|1

Finally, we don't have a market created for SEHKNTL. You should create one named SEHKNTL. The next IB Build (probably next week) will match the market name in the contract specification with a Market in Wealth-Lab. SEHK and HKFE will automatically be assigned to the Market "Hong Kong Stock Exchange", so you won't need to recreate that one.
0

Reply

Bookmark

Sort