# Historical Stock Data

Stock data is crucial for generating user features and backtesting the prediction algorithm. More specifically, the data needed are the open and close prices of a set list of stocks from the NASDAQ and NYSE. The historical data is fetched and stored from 2 sources: [yfinance](https://pypi.org/project/yfinance/) and [IEX Cloud](https://iexcloud.io/). An example of the data:

```python
{
    '_id': 'AAPL 2020-04-02',
    'open': 209.3,
    'close': 210.1
}
```

The primary use of this price data is for the percent difference between the close price of the current trading day and the open of the next trading day. While this data is stored in a MongoDB collection, it can be more efficiently accessed from the `findCloseOpenCached` function. By providing a symbol and time, it will return the close open price using a locally cached object of all price data.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lijeffrey39.gitbook.io/sentiment-ai/data-collection/stock-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
