Get historical high with StockHistory function

%3CLINGO-SUB%20id%3D%22lingo-sub-2045750%22%20slang%3D%22en-US%22%3EGet%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2045750%22%20slang%3D%22en-US%22%3E%3CP%3EHI%20all%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20the%20stock%20data%20types%20can%20only%20get%2052%20weeks%20high%2C%20I%20turned%20to%20see%20if%20Stockhistory%20function%20can%20get%20the%20job%20done.%20However%2C%20with%20that%20function%2C%20I%20get%20a%20whole%20list%20of%20data%2C%20how%20can%20I%20turn%20this%20to%20be%20a%20simple%20%22one%20cell%2C%20one%20formula%2C%20returning%20one%20value%22%20format%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E(I%20prefer%20not%20to%20use%20VBA%20and%20I'm%20using%20Mac)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DSTOCKHISTORY(%22TSLA%22%2C%2201-01-1950%22%2CTODAY())%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2045750%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2045875%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2045875%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F923368%22%20target%3D%22_blank%22%3E%40CALVIN2021%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20this%3A%20%3DMAX(STOCKHISTORY(%22TSLA%22%2C%221%2F1%2F1950%22%2CTODAY()%2C0%2C0%2C3))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20that's%20what%20you%20were%20looking%20for.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2046198%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2046198%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help.%20The%20example%20works.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20I%20need%20to%20get%20the%20price%20for%20a%20list%20of%20stocks%2C%20so%20I%20made%20this%20formula%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DMAX(STOCKHISTORY(A1.%5BExchange%20abbreviation%5D%20%26amp%3B%20%22%3A%22%20%26amp%3B%20A1.%5BTicker%20symbol%5D%2C%221%2F1%2F1950%22%2CTODAY()%2C0%2C0%2C3))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20works%20for%20some%20stock%20but%20not%20all.%20Most%20return%20%23N%2FA%20error.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20suspect%20that%20was%20because%20there%20was%20no%20data%20on%201950.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20get%20from%20the%20earliest%20date%20that%20is%20available%3F%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2046633%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2046633%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F923368%22%20target%3D%22_blank%22%3E%40CALVIN2021%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20the%20formula%20is%20returning%20a%20single%20cell%20(thanks%20to%20the%20MAX%20function)%2C%20I%20would%20just%20place%20my%20multiple%20tickers%20in%20a%20single%20column%2C%20A1%20to%20A100%20(whatever)%20and%20%3CU%3Ecopy%20the%20formula%20down%20%3C%2FU%3Ein%20all%20adjacent%20rows.%3C%2FP%3E%3CP%3E%3DMAX(STOCKHISTORY(A1%2C%221%2F1%2F1950%22%2CTODAY()%2C0%2C0%2C3))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFurthermore%2C%20given%20the%20general%20movement%20of%20the%20stock%20market%20upward%2C%20I%20can't%20image%20why%20you%20even%20need%20to%20go%20back%20to%201950%20for%20any%20individual%20stock%20that%20is%20currently%20traded.%26nbsp%3B%20That%20couldn't%20be%20the%20cause%20of%20the%20%23NA%20error%3B%20after%20all%20TSLA%20worked%20and%20it%20didn't%20even%20exist%20until%20far%20more%20recently%20than%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESomething%20like%20that.%20I%20haven't%20tested%20it%2C%20but%20see%20no%20reason%20why%20that%20wouldn't%20work%20for%20symbols%20that%20are%20active.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2047029%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2047029%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F923368%22%20target%3D%22_blank%22%3E%40CALVIN2021%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20return%20entire%20row%20for%20the%20max%20value%20you%20may%20use%20something%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DINDEX(SORT(STOCKHISTORY(%22TSLA%22%2CDATE(1950%2C1%2C1)%2CTODAY()%2C%2C0)%2C2%2C-1)%2C1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EHere%20is%20at%20the%20left%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20732px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F245142i03F522487553C90D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ESTOCKHISTORY()%20by%20default%20takes%20the%20earliest%20date%20if%20the%20range%20is%20wider.%20To%20illustrated%2C%20I%20took%20UBER%20which%20was%20listed%20in%20mid%202019%2C%20range%20starts%20from%201950.%3C%2FP%3E%0A%3CP%3EMost%20probably%20errors%20are%20due%20to%20some%20other%20reasons.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2047034%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20historical%20high%20with%20StockHistory%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2047034%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20out%20the%20%23Value%20error%20occurred%20because%20there%20was%20an%20%23N%2FA%20error%20for%20one%20of%20the%20dates%2C%20which%20I%20don't%20know%20why%20it%20happens.%20So%20I%20am%20trying%20to%20exclude%20errors%20in%20a%20set%20of%20data%20when%20calculating%20the%20MAX.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20made%20the%20following%20formula%20but%20it%20does%20not%20work.%20Could%20you%20help%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DAGGREGATE(4%2C6%2CSTOCKHISTORY(D17%2C%221%2F1%2F1950%22%2CTODAY()%2C2%2C0%2C3))%3C%2FP%3E%3CP%3EExample%20stock%3A%20XNYS%3AFOUR%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

HI all,

 

Since the stock data types can only get 52 weeks high, I turned to see if Stockhistory function can get the job done. However, with that function, I get a whole list of data, how can I turn this to be a simple "one cell, one formula, returning one value" format?

 

(I prefer not to use VBA and I'm using Mac)

 

=STOCKHISTORY("TSLA","01-01-1950",TODAY())

9 Replies

@CALVIN2021 

 

Try this: =MAX(STOCKHISTORY("TSLA","1/1/1950",TODAY(),0,0,3))

 

Let me know if that's what you were looking for.

 

 

@mathetes 

 

Thanks for your help. The example works.

 

but I need to get the price for a list of stocks, so I made this formula

 

=MAX(STOCKHISTORY(A1.[Exchange abbreviation] & ":" & A1.[Ticker symbol],"1/1/1950",TODAY(),0,0,3))

 

It works for some stock but not all. Most return #N/A error.

 

I suspect that was because there was no data on 1950.

 

Is there a way to get from the earliest date that is available? 

@CALVIN2021 

 

Since the formula is returning a single cell (thanks to the MAX function), I would just place my multiple tickers in a single column, A1 to A100 (whatever) and copy the formula down in all adjacent rows.

=MAX(STOCKHISTORY(A1,"1/1/1950",TODAY(),0,0,3))

 

Furthermore, given the general movement of the stock market upward, I can't image why you even need to go back to 1950 for any individual stock that is currently traded.  That couldn't be the cause of the #NA error; after all TSLA worked and it didn't even exist until far more recently than that.

 

Something like that. I haven't tested it, but see no reason why that wouldn't work for symbols that are active.

 

 

 

@CALVIN2021 

To return entire row for the max value you may use something like

=INDEX(SORT(STOCKHISTORY("TSLA",DATE(1950,1,1),TODAY(),,0),2,-1),1)

Here is at the left

image.png

STOCKHISTORY() by default takes the earliest date if the range is wider. To illustrated, I took UBER which was listed in mid 2019, range starts from 1950.

Most probably errors are due to some other reasons.

@mathetes 

 

I found out the #Value error occurred because there was an #N/A error for one of the dates, which I don't know why it happens. So I am trying to exclude errors in a set of data when calculating the MAX.

 

I made the following formula but it does not work. Could you help?

 

=AGGREGATE(4,6,STOCKHISTORY(D17,"1/1/1950",TODAY(),2,0,3))

Example stock: XNYS:FOUR

 

Thanks Sergei,

 

I think the MAX() works fine. but it's good to know how to know when was it happened. 

 

I am also thinking about how to calculate its annualized increase in price. getting the price of first-day listing and the current price. Divide them by the amount of time. Sounds like huge work for me.

@CALVIN2021 

To ignore errors

image.png

Simple MAX() will work the same way if you prefer to have only one column.

 

I am also thinking about how to calculate its annualized increase in price. getting the price of first-day listing and the current price. Divide them by the amount of time.

 

Afraid didn't catch what the exact idea is. "annualized" price mean price for the each year, another story is how to calculate. However, in next sentence you say about only two dates - start and current.

@mathetes 

@Sergei Baklan 

 

OMG, just found out the max price is unadjusted. It doesn't take into account the effect on the price for share splitting. cry

@CALVIN2021 

You wrote: OMG, just found out the max price is unadjusted. It doesn't take into account the effect on the price for share splitting. 

 

Not true: try entering this formula -- giving yourself lots of room.

=STOCKHISTORY("AAPL",DATE(1980,1,1),TODAY(),,,0,3)

 

The prices are most assuredly adjusted for splits.

 

So wipe off those tears.