karthickmj / yahoo_api

A python library to scrape Yahoo! Finance
0 stars 0 forks source link

Redex: Django website to fetch stock data #17

Open karthickmj opened 8 months ago

karthickmj commented 8 months ago

Develop a minimalistic web page that displays real-time financial data for a user-selected stock. The page will provide essential information like current stock price, market change, and basic financial highlights.

redex-ai-karthickmj[bot] commented 8 months ago

Redex Development Progress

0%

Guidelines

Don't edit this comment. This comment is managed by Redex for summary and status updates.

Step 1: Clarifications (PENDING)

Redex AI will come up with Clarification Questions related to this development task. Please answer the relevant questions. Avoid any other unrelevant question

Step 2: Change Plan (Revision 2)

"https://github.com/karthickmj/yahoo_api/issues/17#issuecomment-1855775006"

Change Plan (Revision 1) "https://github.com/karthickmj/yahoo_api/issues/17#issuecomment-1855750790"

Step 3: Pull Request (Revision 1)

Pull Request comment link: "https://github.com/karthickmj/yahoo_api/issues/17#issuecomment-1855787656"

Please review the pull request. In case if it needs any modifications, please drop a comment on the pull request directly. Then a new revision of the pull request will be generated

redex-ai-karthickmj[bot] commented 8 months ago

Based on the provided context, here are some clarifying questions that would help in accurately developing the requirement:

  1. Web Page Integration: The existing code base is a Python library for scraping financial data. How should this library be integrated into a web page? Should a new web application be created using a framework like Flask or Django, or is there an existing web application that this should be integrated into?

  2. Real-time Data: The requirement mentions "real-time financial data." The current Python library likely scrapes data at the time of the request, which may not be truly real-time. Should a mechanism like websockets or AJAX be implemented to periodically update the stock data on the web page without manual refresh?

  3. User Interface: What are the specific requirements for the user interface? Should there be a search field for entering the stock ticker symbol, and how should the results be displayed?

  4. Data Selection: Which specific pieces of financial data are required for the minimalistic web page? The ticker class has multiple methods that return various data points. Should all these data points be displayed, or only a subset?

  5. Error Handling: How should the web page handle errors, such as an invalid stock ticker symbol or issues with scraping data from Yahoo Finance?

  6. Rate Limiting and Caching: Yahoo Finance may have rate limits for scraping data. Should there be any caching mechanism to prevent hitting these limits, and how should the cache be invalidated to ensure data freshness?

  7. Dependencies: The financials method of the ticker class mentions using Selenium. Are there any constraints on using external dependencies like Selenium in the web application, and is the server environment set up to handle browser automation?

  8. API Throttling: Is there a need to implement any throttling or queuing system to manage the number of concurrent requests to Yahoo Finance, especially if multiple users are accessing the web page simultaneously?

  9. Responsive Design: Should the web page be responsive and mobile-friendly?

  10. Security: Are there any specific security concerns or requirements that need to be addressed, such as protecting against scraping abuse or securing the communication between the client and server?

  11. Hosting and Environment: Where will the web page be hosted, and are there any specific environment configurations or limitations to be aware of?

  12. Compliance and Legal: Are there any compliance or legal considerations to take into account when scraping data from Yahoo Finance and displaying it on a web page?

These questions aim to clarify the scope and technical considerations for the task at hand, ensuring that the development aligns with the project's goals and constraints.

If you just want to test us out without providing clarifying answers, please comment DEFAULT and we will take the workflow forward with assumptions :smiley:

karthickmj commented 8 months ago

We prefer Django web framework. Add all necessary django files. Don't want any real time data. Just use the methods from yahoo.py file. Refactor them if needed. Simple html page should be fine. Please have a dropdown menu to select the stock Not sure about yahoo_api rate limit For error handling, just display an alert with error message to the user No need to setup deployment. I will just run it locally. No need to worry about security. No need to do anything for caching. No need to do anything for accessibility and responsiveness.

redex-ai-karthickmj[bot] commented 8 months ago

Change Plan (Revision 1)

The change involves setting up a new Django application with models, views, URLs, forms, and templates to display stock data fetched using the existing 'yahoo.py' library. The 'yahoo.py' library will also be refactored to work with the new views.

1. File: models.py

Create a new Django model 'Stock' with a CharField 'ticker_symbol' to store stock ticker symbols. This model will be used to populate the dropdown menu in the web page.

2. File: views.py

Add a new view 'StockDataView' to handle requests for stock data. This view will use the 'ticker' class from 'yahoo.py' to fetch the summary data and return it as JSON. Input: stock ticker symbol from the request. Output: JSON response with summary data.

3. File: urls.py

Add a new URL pattern for 'StockDataView' to handle AJAX requests for fetching stock data. The URL pattern will be something like '/stocks/data//' to fetch data for a specific stock.

4. File: forms.py

Create a new form 'StockSelectionForm' with a ModelChoiceField to allow users to select a stock from the dropdown menu. The form will use the 'Stock' model to populate the choices.

5. File: templates/stock_data.html

Create a new HTML template for the web page that includes a form for stock selection using 'StockSelectionForm' and a section to display the stock data fetched from the 'StockDataView'.

6. File: yahoo.py

Refactor the 'ticker' class to ensure compatibility with Django. This includes handling exceptions and returning data in a format that can be easily converted to JSON for the AJAX response.

NOTE: Please note that code generated for this file is less accurate. It needs manual review and fix. Redex will get better at these in coming releases.

7. File: admin.py

Register the new 'Stock' model with the Django admin site to allow for easy management of stock ticker symbols.

Next steps :

After implementing the changes, the development team should lint the code, run unit tests, and perform manual testing to ensure the functionality works as expected. No deployment steps are necessary as the developer will run the application locally.

We are working on generating a pull request for the change plan. Meanwhile please review the change plan. In case if it needs any modifications, please drop a comment on the issue directly. Then a new revision of change plan and corresponding pull request will be generated

redex-ai-karthickmj[bot] commented 8 months ago

Pull Request (Revision 1.1)

Add Django web interface for fetching stock data: https://github.com/karthickmj/yahoo_api/pull/18

karthickmj commented 8 months ago

Can you please implement manage.py and other necessary django files that are not present?

redex-ai-karthickmj[bot] commented 8 months ago

Change Plan (Revision 2)

The change involves setting up a new Django application with models, views, URLs, forms, and templates to display stock data fetched using the existing 'yahoo.py' library. The 'yahoo.py' library will also be refactored to work with the new views. Additionally, the necessary Django project files such as 'manage.py', 'settings.py', 'urls.py', 'wsgi.py', and 'asgi.py' will be created to support the application.

1. File: manage.py

Create the 'manage.py' script which is the command-line utility for administrative tasks. This file is necessary to start the Django server, make migrations, and other command-line tasks.

2. File: settings.py

Set up the Django settings file with the necessary configurations for the project, including the installed apps, database configurations, and other settings required for the Django project to run.

3. File: urls.py

Set up the root URL configuration to include the URLs from the 'stocks' app, which will handle the web page requests for displaying stock data.

4. File: wsgi.py

Set up the WSGI configuration to serve the Django application in production environments.

5. File: asgi.py

Set up the ASGI configuration for asynchronous support, which is necessary for channels and other asynchronous features of Django.

6. File: models.py

Create a new Django model 'Stock' with a CharField 'ticker_symbol' to store stock ticker symbols. This model will be used to populate the dropdown menu in the web page.

7. File: views.py

Add a new view 'StockDataView' to handle requests for stock data. This view will use the 'ticker' class from 'yahoo.py' to fetch the summary data and return it as JSON. Input: stock ticker symbol from the request. Output: JSON response with summary data.

8. File: forms.py

Create a new form 'StockSelectionForm' with a ModelChoiceField to allow users to select a stock from the dropdown menu. The form will use the 'Stock' model to populate the choices.

9. File: templates/stock_data.html

Create a new HTML template for the web page that includes a form for stock selection using 'StockSelectionForm' and a section to display the stock data fetched from the 'StockDataView'.

10. File: yahoo.py

Refactor the 'ticker' class to ensure compatibility with Django. This includes handling exceptions and returning data in a format that can be easily converted to JSON for the AJAX response.

NOTE: Please note that code generated for this file is less accurate. It needs manual review and fix. Redex will get better at these in coming releases.

11. File: admin.py

Register the new 'Stock' model with the Django admin site to allow for easy management of stock ticker symbols.

Next steps :

After implementing the changes, the development team should lint the code, run unit tests, and perform manual testing to ensure the functionality works as expected. For deployment, set up a production server with WSGI/ASGI configurations, deploy the code, and run the migrations on the production database.

We are working on generating a pull request for the change plan. Meanwhile please review the change plan. In case if it needs any modifications, please drop a comment on the issue directly. Then a new revision of change plan and corresponding pull request will be generated

redex-ai-karthickmj[bot] commented 8 months ago

Pull Request (Revision 2.1)

Add Django web interface for fetching stock data with necessary project files: https://github.com/karthickmj/yahoo_api/pull/19