Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.8K Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Saving Financial Data for faster access.

I am interested in reading financial data and I use the following statement: originalData = FinancialData[stock, "OHLCV", dateRange] // Normal // QuantityMagnitude;

However, this always requires getting the data through the Internet (at least in my understanding). I would like to be able to read the data for a number of stocks (perhaps all of the S&P 500) over a certain period (and I don't care if it takes all night), but I would like to be able to store the data in a set of files (each file would be named after the stock whose data it has) so that in the future, when I want to read the data for a stock during a period of time included in the data, I can read it directly from the file on my computer. This would make it: 1) Faster 2) No longer dependent on me being connected to the Internet (since I use a Satellite connection (one of the disadvantages of living in a rural area is that a Satellite connection might be all you have) Could someone tell me how I could do that? I understand that perhaps using paclets might be the way to do it. Is it possible for me to do that?

POSTED BY: Henrick Jeanty
3 Replies
Posted 5 years ago
POSTED BY: Hans Milton

Thank You Lee! What else can I say? Again, thank you!

POSTED BY: Henrick Jeanty
Posted 5 years ago

Here is one way to do it.

Get stock data:

ticker = "AAPL";
dateRange = {{2020, 1, 1}, Today};
originalData = FinancialData[ticker, "OHLCV", dateRange] // Normal // QuantityMagnitude;

Create a file name:

fileName = StringJoin[ticker, "_", DateString[Today, {"Year", "Month", "Day"}]]

Put in file:

Put[originalData, fileName]

Read in and check:

newData = Get[fileName];
newData == originalData

You can gather up the code in a function to create files for all the stocks and date ranges you'd like to store.

POSTED BY: Lee Godfrey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard