Open cheukhin1024 opened 1 year ago
OK, with a little digging here I think there's two issues. First, the default currency in download_bars.py is USD, so you are trying to download a contract that doesn't exist because the HSI is in HKD.
One way to find this is to run the query_contracts.py script in this project. I updated it just now to spit out a bit more info. So for example:
./src/query_contracts.py --symbol HSI --security-type IND
This spits out the following (along with a lot of other logging)
Security Type: IND Symbol:HSI Currency: HKD
CUSIP:
Primary Exchange:
Details for - Hang Seng Stock Index
Industry: Category: Subcategory:
OrderTypes: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,BASKET,BENCHPX,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,LMT,NONALGO,OCA,SCALE,SCALERST,WHATIF
ValidExchanges: HKFE
Now if I run the script with HKD as the currency...
./src/download_bars.py --size "1 day" --security-type IND --max-days --exchange HKFE --currency HKD HSI
I get the message that I don't have market data permissions for this contract.
21:16:50,398 root ERROR Error. Id: 3 Code 162 Msg: Historical Market Data Service error message:No market data permissions for HKFE IND
If you pay for market data, you should be able to download historical data then.
Let me know if that works for you. I don't think I'd downloaded non-USD data before.
I'm getting the same issue for VIX using download_bars.py --size "1 hour" --security-type IND --start-date 19901010 --end-date 20240401 VIX
The following is the output of query_contracts.py --symbol VIX --security-type IND
Security Type: IND Symbol:VIX Currency: USD
CUSIP:
Primary Exchange:
Details for - CBOE Volatility Index
Industry: Indices Category: Volatility Index Subcategory: *
OrderTypes: ACTIVETIM,AD,ADJUST,ALERT,ALLOC,BASKET,BENCHPX,COND,CONDORDER,DAY,DEACT,DEACTDIS,DEACTEOD,GAT,GTC,GTD,GTT,HID,LMT,NONALGO,OCA,SCALE,SCALERST,WHATIF
ValidExchanges: CBOE
@alphaDev23 This topic has been a long time.
After I posted this 1 year ago, I switched to using 'ib_insync' to get the HSI historical data.
@wrighter thoughts on my comment?
I haven’t used ib_insync but it does appear to have a number of contributors and some great features. If it’s working for you, that’s great. Hopefully some of the contributors will be able to carry on with the project since it appears the founder has recently passed, which is terrible news.
I unfortunately don’t have much free time to work on this project.
I had left off the --exchange
parameter.
I want to download HSI data. (HSI is Hang Seng Index)
I followed the guide https://www.wrighters.io/how-to-get-historical-market-data-from-interactive-brokers-using-python/ to download the HSI Hang Seng index data using the following bash command script:
./download_bars.py --size "1 day" --security-type IND --max-days --exchange HKFE HSI
Yet, there is an error: No security definition has been found for the request . I want to know whether this ib-scripts project support downloading non-US data because all examples are US-related. Thank you!
The following is the full terminal result: