Experimenting with ChatGPT Function Calling
Python script that accepts a stock ticker symbol as a command-line argument. It fetches the stock's price, 5-day Simple Moving Average (SMA), and 200-day SMA from the Alpha Vantage API, and then asks the AI to analyze the trend based on this data.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Alpha Vantage:
Export as ALPHA_VANTAGE_API_KEY
environment variable.
OpenAI:
Export as OPENAI_API_KEY
environment variable.
$ python main.py {TICKER}
$ python main.py VTI
The trend of VTI stock is currently showing a slight downward movement. The current price is $218.18, which is slightly lower than the 5-day Simple Moving Average (SMA) of $218.48. However, it is still higher than the 200-day SMA of $197.93, indicating a long-term upward trend.