{"id":13529791,"url":"https://github.com/KVignesh122/AssetNewsSentimentAnalyzer","last_synced_at":"2025-04-01T17:31:05.591Z","repository":{"id":244995081,"uuid":"812535124","full_name":"KVignesh122/AssetNewsSentimentAnalyzer","owner":"KVignesh122","description":"A sentiment analyzer package for financial assets and securities utilizing GPT models.","archived":false,"fork":false,"pushed_at":"2024-07-27T06:16:07.000Z","size":424,"stargazers_count":107,"open_issues_count":0,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-03T12:22:29.991Z","etag":null,"topics":["commodity-trading","financial-analysis","forex-trading","google-search-api","investment-analysis","llm-inference","news-api","sentiment-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KVignesh122.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-09T07:07:02.000Z","updated_at":"2024-09-29T13:29:52.000Z","dependencies_parsed_at":"2024-06-18T22:59:26.352Z","dependency_job_id":null,"html_url":"https://github.com/KVignesh122/AssetNewsSentimentAnalyzer","commit_stats":null,"previous_names":["kvignesh122/assetnewssentimentanalyzer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KVignesh122%2FAssetNewsSentimentAnalyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KVignesh122%2FAssetNewsSentimentAnalyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KVignesh122%2FAssetNewsSentimentAnalyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KVignesh122%2FAssetNewsSentimentAnalyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KVignesh122","download_url":"https://codeload.github.com/KVignesh122/AssetNewsSentimentAnalyzer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222748141,"owners_count":17031897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commodity-trading","financial-analysis","forex-trading","google-search-api","investment-analysis","llm-inference","news-api","sentiment-analysis"],"created_at":"2024-08-01T07:00:39.450Z","updated_at":"2024-11-02T16:31:13.009Z","avatar_url":"https://github.com/KVignesh122.png","language":"Python","funding_links":[],"categories":["Recently Updated","Python"],"sub_categories":["[Jul 14, 2024](/content/2024/07/14/README.md)","Sentiment Analysis","情感分析"],"readme":"# Asset News Sentiment Analyzer\n\nThis application provides two sophisticated tools catering to sentiment analysis of financial assets and securities by using ChatGPT on Google search results and online news articles. You will just need an OpenAI API Key to get started and utilize the power of all the functionalities provided by this package, namely to fetch news articles, analyze their content, and produce insightful reports for investment and trading decisions.\n\nA simple trading strategy involving daily sentiment analysis signals from this package may provide basic market traction of the target asset (We did a sample backtest on commodities over the past 100 market days):\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cstrong\u003eCrude Oil 100 Days\u003c/strong\u003e\u003cbr\u003e\n      \u003cimg src=\"images/Crude Oil.jpg\" alt=\"Crude Oil Sample\" width=\"500\" height=\"300\"\u003e\n    \u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003cstrong\u003eGold 100 Days\u003c/strong\u003e\u003cbr\u003e\n      \u003cimg src=\"images/Gold.jpg\" alt=\"Gold Sample\" width=\"500\" height=\"300\"\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n***Disclaimer: All investments and trading involve risk. This package is intended for research/academic purposes, and coding projects. It aids algorithmic/quantitative traders and researchers in their work. The reports and signals generated by this package does not constitute financial advice, and users should perform their own due diligence before making any trading decisions.***\n\n## Contents\n\n- [Two Main Classes](#two-main-classes)\n  - [SentimentAnalyzer Tool](#1-sentimentanalyzer-tool)\n  - [WebInteractor Tool](#2-webinteractor-tool)\n- [Installation](#installation)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Two Main Classes\n\n### 1. SentimentAnalyzer Tool\n\nThe `SentimentAnalyzer` class allows users to perform sentiment analysis on news articles related to a specific financial asset for any given date. It fetches news links, retrieves the content, and if desired, uses GPT models to generate reports and assess market sentiment.\n\n**Usage**\n\n```python\nfrom asset_sentiment_analyzer import SentimentAnalyzer\n\n# Initialize the analyzer\nanalyzer = SentimentAnalyzer(asset='Crude Oil', openai_key='your-openai-key')\n\n# Get sentiment analysis as string for today or any date in the past (returns \"bullish\", \"bearish\", or \"neutral\")\nsentiment = analyzer.get_sentiment(date='06-02-2024')\nprint(f\"The sentiment for the asset is: {sentiment}\")\n\n# Fetch news links for any date with news_date argument in MM-dd-YYYY format.\nnews_links = analyzer.fetch_news_links(news_date='06-02-2024')\n\n# Display news content\nfor url in news_links:\n    print(analyzer.show_news_content(url))\n\n# Generate a report\nreport = analyzer.produce_daily_report(date='06-02-2024', max_words=300)\nprint(report)\n\n```\n\n**API Reference**\n\n* `SentimentAnalyzer(\u003casset_name\u003e)`: Initializes the SentimentAnalyzer object with specified asset and optional OpenAI key (`openai_key` parameter) and model selection (`model` parameter).\n\n__Available Methods:__\n\n* `.fetch_news_links()`: Fetches news links from Google Search News tab for the specified asset on the given date. If `news_date` parameter is not assigned, it will retrieve the current day's latests news links. `nlinks` parameter denotes the number of news links to retrieve, default is `4`.\n* `.show_news_content(\u003cnews_url\u003e)`: Parses and returns main content as string for a given news URL.\n* `.get_sentiment()`: Analyzes online results automatically and returns the news sentiment for asset/security on any given date. If `date` parameter is not assigned, it will return the current day's latest sentiment verdict.\n* `.produce_daily_report()`: Generates a daily report returned as string with insights based on the online Google Search content for any given date. If `date` parameter is not assigned, it will generate report for the current day. The default `max_words` is `100`, but this can be adjusted as preferred.\n\nNote: All dates must be in `MM-dd-YYYY` format or must be passed as a `datetime.datetime` object into the methods.\n\n### 2. WebInteractor Tool\n\nThe `WebInteractor` class provides functionalities to interact with web content, perform Google searches, and retrieve content, which can then be fed into a GPT client for further interaction.\n\n**Usage**\n\n```python\nfrom asset_sentiment_analyzer import WebInteractor\n\n# Initialize the WebInteractor\nweb_interactor = WebInteractor()\n\n# Perform a Google search and retrieve result links as list\nsearch_results = web_interactor.search_google(query=\"Apple Stocks\", nlinks=5)\nprint(search_results)\n\n# Fetch the main content of a webpage\ncontent = web_interactor.get_webpage_main_content(url=\"https://example.com\")\nprint(content)\n\n# Interact with a GPT model\nmy_prompt = f\"\"\"\nHow will this affect the latest Apple earnings report:\n{content}\n\"\"\"\nresponse = web_interactor.get_llm_response(prompt=my_prompt, openai_api_key=\"your_openai_api_key\")\nprint(response)\n\n```\n\n**API Reference**\n\n* `WebInteractor()`: Initializes a WebInteractor object which provides functionalities for interacting with web content and performing web searches.\n\n__Available Methods:__\n\n* `.search_google(\u003cquery\u003e)`: Searches Google for the specified query and retrieves a list of unique links. Parameters:\n  * `query` (str): The search query.\n  * `tld` (str, optional): The top-level domain for Google (eg. 'com' for Google.com).\n  * `lang` (str, optional): The language setting for the Google search.\n  * `date` (str, optional): The date to refine search results. (`MM-dd-YYYY` format)\n  * `country` (str, optional): The country setting for Google search results.\n  * `tab` (str, optional): Specifies the tab under which the search is performed, allowing for specific types of search results.\n  * Possible values include:\n    - `'app'` for Applications\n    - `'blg'` for Blogs\n    - `'bks'` for Books\n    - `'dsc'` for Discussions\n    - `'isch'` for Images\n    - `'nws'` for News\n    - `'pts'` for Patents\n    - `'plcs'` for Places\n    - `'rcp'` for Recipes\n    - `'shop'` for Shopping\n    - `'vid'` for Video\n  * `nlinks` (int, optional): The number of links to retrieve.\n* `.get_webpage_main_content(\u003curl\u003e)`: Fetches the main content of a webpage.\n* `.get_llm_response(\u003cprompt\u003e, \u003copenai_api_key\u003e)`: A method to interact with a GPT language model based on a specified prompt and retrieve its response.\n\n## Installation\n\nProject has been published on pip\n\n```bash\npip install asset-sentiment-analyzer\n```\n\n## Contributing\n\nIf you would like to contribute to this project, please follow the guidelines below:\n\n- Fork the repository.\n- Create a new branch (git checkout -b feature-branch).\n- Make your changes.\n- Commit your changes (git commit -m 'Add new feature').\n- Push to the branch (git push origin feature-branch).\n- Open a pull request.\n\n## License\n\nThis project is pioneered by SkyBlue Capital (Singapore), and is licensed under the Apache-2.0 License. See the LICENSE file for details.\n\n\u003cimg src=\"images/HBlack.png\" alt=\"SBC Logo\" width=\"190\" height=\"55\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKVignesh122%2FAssetNewsSentimentAnalyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKVignesh122%2FAssetNewsSentimentAnalyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKVignesh122%2FAssetNewsSentimentAnalyzer/lists"}