Select single column from array returned by GetQuote extension
-
26-04-2021 - |
Domanda
Ted Schlossmacher's free GetQuote extension for OpenOffice.org Calc allows users to access quotes for several types of symbols tracked by Yahoo! Finance. Specifically, the GETHISTORY()
function returns a range of past and present quotes.
After installing the extension, try highlighting a 5-column range and then typing =GETHISTORY("PETR4.SA",1,TODAY()-1)
(you might need to use semicolons instead of commas) and then pressing Ctrl+Shift+Return
. That should provide you with date, open, high, low and close quotes for PETR4, the preferred stock of Brazilian oil giant Petrobras S.A.
My question is: how can I, in one cell, insert a formula that would return me the value of the 5th column of the above array?
Soluzione
This can be done with the INDEX
function. You don't need to use ctrl+shift+enter for it to work as it does't return an array.
=INDEX(GETHISTORY("PETR4.SA",1,TODAY()-1),1,5)
The 2 end parameters are row
,column
, and are a 1-based index into the array.
More information about INDEX
can be found on any Excel website, or in the LibreOffice Calc help at https://help.libreoffice.org/Calc/Spreadsheet_Functions#INDEX
Altri suggerimenti
Yesterday's closing price can be retrieved using a second argument, for example: =GETQUOTE("TD.TO",21)
From the manual: GETQUOTE can fetch 31 types of quotes. The types are numbered from 0 to 30. The function accepts these numbers as the second argument.
0 = Last traded price
1 = Change in price for the day
2 = Opening price of the day
3 = High price of the day
4 = Low price of the day
5 = Volume
6 = Average Daily Volume
7 = Ask Price
8 = Bid Price
9 = Book Value
10 = Dividend/Share
11 = Earnings/Share
12 = Earnings/Share Estimate Current Year
13 = Earnings/Share Estimate Next Year
14 = Earnings/Share Estimate Next Quarter
15 = 52-week low
16 = Change from 52-week low
17 = 52-week high
18 = Change from 52-week high
19 = 50-day Moving Average
20 = 200-day Moving Average
21 = Previous Close
22 = Price/Earning Ratio
23 = Dividend Yield
24 = Price/Sales
25 = Price/Book
26 = PEG Ratio
27 = Price/EPS Estimate Current Year
28 = Price/EPS Estimate Next Year
29 = Short Ratio
30 = 1-year Target Price
If you need only the latest price (which is the fifth field) I believe you can simply use:
=GETQUOTE("PETR4.SA")
I'm not certain this works to return the current price when markets are open, but it does return the last trade price when markets are closed.