0

I would like to fetch the stock code of warrant, say 57107, listed in Hong Kong Market.

Because googleFinance and yahooFinance does not have warrant details.

An article "https://stackoverflow.com/questions/68411743/importxml-cant-fetch-from-yahoo-finance-if-there-is-a-point-in-in-the-ticker" suggested ImportXML is not working. Therefore I am writing an app script to get it done.

function getXML(){
  var aastockLink = 'http://www.aastocks.com/en/stocks/quote/quick-quote.aspx?symbol=57107'
  var content = UrlFetchApp.fetch(aastockLink).getContentText();
  var regex = /<span class="neg"><span class="arrowUpDn"[\s\S]*?\/span>([\s\S]*?)<\/span>/g;
  Logger.log(regex.exec(content)[0]);
}

I am looking for fetching the closed price etc.

Thank you for your help

8平民
  • 49
  • 5
  • See if these references are of any help? How to Track HK Stocks With GOOGLE FINANCE Function?: https://support.google.com/docs/thread/3429276/how-to-track-hk-stocks-with-google-finance-function?hl=en How to get Live Stock Price in Google Sheets: https://www.youtube.com/watch?v=oTwdQ78cEK8 Getting warrant prices: https://www.reddit.com/r/SPACs/comments/ix7uot/anyone_know_how_to_get_units_and_warrant_prices/ – Nami888 Apr 10 '22 at 15:28
  • Might need to use a combination of the reference link – Nami888 Apr 10 '22 at 15:28
  • Fix your code by replacing the double quotes with single quotes (the source you are scrapping uses single quotes for class='neg' and so on). Also, get [1] from the result, not [0] – Ricardo Aranguren Apr 10 '22 at 15:36
  • Re Ricardo Aranguren: The expression is for regex only. I tested the regex using regexr.com and confirmed the double quotes works. I believe my problem is the content fetched seems not including the stock price. I understand get [1] would get the result. I will change back to [1] after I fetch anything using [0]. Thank you – 8平民 Apr 10 '22 at 16:07
  • Re Nami888: GOOGLE FINANCE does not have information for HK warrant. You may see "=GOOGLEFINANCE("HKG:57107","Price")" returning #N/A. And the reddit site showed how to fetch data from BigChart. But BigChart does not have information for HK Warrant too. See https://bigcharts.marketwatch.com/symbollookup/symbollookupresults.asp?symb=57107&country=hk&insttype=All&x=0&y=0 – 8平民 Apr 10 '22 at 16:21
  • I have to apologize for my poor English skill. Unfortunately, I couldn't understand your expected value from `I am looking for fetching the closed price etc.`. Can you provide your expected value? – Tanaike Apr 11 '22 at 01:54
  • Hello Tanaike. Because the stock price varies over time. My expected value as of now from "http://www.aastocks.com/en/stocks/quote/quick-quote.aspx?symbol=57107" would be 0.290, that is the current market price of that stock number 57107. – 8平民 Apr 11 '22 at 05:57
  • Thank you for replying. I have to apologize for my poor English skill, again. Unfortunately, from your reply, I couldn't still understand your expected value. – Tanaike Apr 11 '22 at 09:17
  • There is nothing to apologize. My english is poor too. You may visit "http://www.aastocks.com/en/stocks/quote/quick-quote.aspx?symbol=57107" today. My expected value is 0.285. I hope I can explain better. But I do not know how to post a photo here. – 8平民 Apr 11 '22 at 10:13
  • Thank you for replying. Where can I see the value of `0.285`? I'm worried that the value might be changed over time. – Tanaike Apr 12 '22 at 00:52
  • Thank you for your kindness. There is a table in the website, showing Last(HKD)Bull(CBBCs), Range, Volume, Turnover, Lot Size and so on. I like to have the value (i.e. 0.290) shown in Last(HKD)Bull(CBBCs). The outerhtml code is [<0.290]. The full xpath is [/html/body/form/div[4]/div[3]/div[1]/div[2]/table[1]/tbody/tr[1]/td[1]/div[4]/div/span/text()] – 8平民 Apr 12 '22 at 02:39
  • Thank you for replying. From your reply, I confirmed that when I access your showing URL, those values are not shown in my browser. I thought that for this reason, I had not been able to understand your question. When I check the tag of ``. In my environment, I cannot see it. So, unfortunately, I cannot try to think of a solution because I cannot test it. I apologize for this. – Tanaike Apr 13 '22 at 01:40
  • Thank you for your trying. Tanaike. I very much appreciate it. – 8平民 Apr 13 '22 at 02:50

0 Answers0