- Python 3.11.7
- MongoDB 7.0.2
- cURL 8.4.0
git clone https://github.com/sudiptab2100/stock-price-view.git
Make sure Python virtual environment (virtualenv) is installed.
python -m venv env
source env/bin/activate
pip install -r requirements.txt
python app.py
Top stocks are the stocks with highest growth rate considering the oldest date in the database as the base date.
curl -X GET http://localhost:8000/get_top_k/<k>
It searches for the stock by name and returns the stock with stock code, stock name, pnl & other details.
curl -X GET http://localhost:8000/search/<name>
curl -X GET http://localhost:8000/get_favorites
curl -X POST http://localhost:8000/add_favorite/<stock_code>
curl -X DELETE http://localhost:8000/remove_favorite/<stock_code>
It returns the price history of the stock in the database. It returns a json object with two keys: days & prices, where days is a list of dates in ddmmyy format in sorted order and prices is a list of prices corresponding to the dates in days.
curl -X GET http://localhost:8000/get_price_history/<stock_code>
See the Chart UI at
http://localhost:8001/chart.html
Here you can see the price chart by putting the stock code in the input field.
-
The app runs the preset script and then start API.
-
It download and stores past 50 days data (excluding weekends) of all the stocks in the database for the first time only, later it only updates the database with the latest data.
-
The DB can be refreshed by changing the refresh variable in app.py (line no. 42) to True.
if __name__ == "__main__": preset(days=50, refresh=True)