LibreOffice Calc has no inbuilt stock market functions, and a popular plugin which offered those has stopped working along with changes to Yahoo Finance.
Luckily, we can get the latest quotes from Bloomberg.
[2018-12-15] Bloomberg Finance is, understandably, blocking multiple simultaneous requests. A more flexible solution is using a Python Stock Scraper.
The start position of the last quote can be returned into a cell with the function:
Luckily, we can get the latest quotes from Bloomberg.
[2018-12-15] Bloomberg Finance is, understandably, blocking multiple simultaneous requests. A more flexible solution is using a Python Stock Scraper.
Step 1. Enable regular expressions in Libreoffice Calc.
Go to:Tools - Options - LibreOffice Calc - CalculateSelect:
Enable regular expressions in formulae
Step 2. Use 'WEBSERVICE' function to download data into a cell.
Example: to download last month's data for Mizuho Group on the JPX:=WEBSERVICE"https://www.bloomberg.com/markets/chart/data/1M/8411:JP")We'll call the cell containing the downloaded JSON string <dataCell>
Step 3. Use 'SEARCH' function to isolate desired data.
The last quote usually takes the format, "99.99]]"The start position of the last quote can be returned into a cell with the function:
=SEARCH("[0-9]+.[0-9]+\]\]",<dataCell>)The end position can be returned into another cell with the function:
=SEARCH("]]",<dataCell>)The MID function can then be used to populate another cell with the substring containing the quote.
=MID(<dataCell>, <startPositionCell>, <endPositionCell>-<startPositionCell>
Notes
- (Unfortunately) Calc has no inbuilt JSON functions.
- Importing Bloomberg data into Calc is more reliable than into Google sheets. Bloomberg servers sometimes reject requests from Google as contravening terms of service.
Comments
Post a Comment