I'm trying to get stock prices on Tokyo exchange using VBA. I have searched for quite a number of API but none of them has Tokyo exchange's data, except finance.google.com. But google finance has stopped working and no longer return data in json format so i have to make use of what's left, to extract data from the string returned.
Below is the example of the string returned.
EXCHANGE%3DTYO
MARKET_OPEN_MINUTE=540
MARKET_CLOSE_MINUTE=900
INTERVAL=86400
COLUMNS=DATE,CLOSE,HIGH,LOW
DATA_SESSIONS=[MORNING,540,690],[AFTERNOON,750,900]
DATA=
TIMEZONE_OFFSET=540
a1522216800,2313,2324,2240
1,2298,2350,2242
2,2325,2336,2300
5,2252,2333,2246
6,2229,2257,2216 <--
7,2222,2238,2214
8,2262,2267,2220
9,2293,2313,2249
12,2338,2351,2300
13,2373,2392,2351
14,2386,2396,2323
15,2368,2395,2335
16,2391,2398,2375
19,2420,2439,2389
20,2378,2419,2363
21,2411,2428,2389
22,2384,2422,2381
23,2407,2426,2386
26,2437,2438,2389
27,2454,2468,2443
28,2453,2456,2418
29,2437,2422,2443 <<--
The URL for your reference http://finance.google.com/finance/getprices?x=TYO&q=9143&i=86400&f=d,c,h,l
a1522216800 is the timestamp and the first number of the following lines are intervals in days. 1 being 1 day after a1522216800. The timestamp after the alphabet "a" seems to change with days whenever I call that URL.
I use InStr()
looking for "a" and Mid()
to extract the timestamp and convert it into date format and add the day interval to the extracted date to get my specific date.
Here's the problem, for example, I want to get 29 days from the timestamp, indicated by <<--, when I use the same InStr()
to look for "29," VBA returned string position at <--, as they have the same "29," in that line. How can I get my intended date?
My life would be easier if the response from finance.google.com is in json format. I don't suppose there is a way to convert these string into json are they?