# Generate Stock Features

First save stock tweets locally before generating stock features:

{% content-ref url="../project-setup/tweet-setup" %}
[tweet-setup](https://lijeffrey39.gitbook.io/sentiment-ai/project-setup/tweet-setup)
{% endcontent-ref %}

Stock features are generated based on tweets made about a stock within a range of dates. For each stock, user tweets are first filtered to only include tweets made by 'expert' users determined by pre-generated [user features](https://lijeffrey39.gitbook.io/sentiment-ai/data-collection/user-setup/user-feature). The general purpose of these stock features is to associate a user's tweeted prediction with their corresponding user feature. [Example](https://lijeffrey39.gitbook.io/sentiment-ai/data-collection/stock-setup/stock-feature) stock feature

```python
for symbol in stocks:
    for date in date_range:
        tweets = findTweets(symbol, date)
        for tweet in tweets:
            username = tweet['username']
            date = tweet['time']
            user_feature = findUserFeature(symbol, date, date)
```

The tweets for each stock and date are first fetched and scanned. For each tweet, the user's features are found and saved with the tweet.

### Notes about these features

* Features are generated by only looking at the latest prediction by a user on a given day.
* A user's associated feature is found by looking at the most recent updated feature before the current prediction date&#x20;


---

# 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-setup.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.
