{"id":18895670,"url":"https://github.com/binance/ai-trading-prototype-headlines","last_synced_at":"2025-04-15T01:14:01.319Z","repository":{"id":191602108,"uuid":"684995811","full_name":"binance/ai-trading-prototype-headlines","owner":"binance","description":"News Headlines Fetcher. Outputs headlines intended for use with the ai-trading-prototype sentiment-based trading bot.","archived":false,"fork":false,"pushed_at":"2023-08-30T09:50:33.000Z","size":6,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T01:13:56.613Z","etag":null,"topics":["auto","binance","headlines","news","prototype"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binance.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-30T09:36:28.000Z","updated_at":"2025-04-05T15:00:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"e66262ff-7338-41de-861d-970ded6b1721","html_url":"https://github.com/binance/ai-trading-prototype-headlines","commit_stats":null,"previous_names":["binance/ai-trading-prototype-headlines"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fai-trading-prototype-headlines","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fai-trading-prototype-headlines/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fai-trading-prototype-headlines/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binance%2Fai-trading-prototype-headlines/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binance","download_url":"https://codeload.github.com/binance/ai-trading-prototype-headlines/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248986315,"owners_count":21194025,"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":["auto","binance","headlines","news","prototype"],"created_at":"2024-11-08T08:29:17.520Z","updated_at":"2025-04-15T01:14:01.303Z","avatar_url":"https://github.com/binance.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AI Trading Prototype Headlines\n\nThis project complements the [ai-trading-prototype](https://github.com/binance/ai-trading-prototype) and [ai-trading-prototype-backtester](https://github.com/binance/ai-trading-prototype-backtester) projects by offering a tool to download news headlines in a compatible format.\n\n It fetches news headlines and their publication timestamps related to a specific search term from a defined news source, and saves them into a CSV file.\n\n The headlines can then be used for sentiment analysis, which can be a factor in trading decisions.\n\n## Installation\n\nClone from GitHub:\n```\ngit clone git@github.com:binance/ai-trading-prototype-headlines.git\n```\n\nTo run the project, you need to have Python installed and install the required Python packages, which are listed in the `requirements.txt` file. You can install them with pip:\n\n```\ncd \u003cpath_to_cloned_repository\u003e\npip install -r requirements.txt\n```\n\n## Usage\n\n### Configuration\n\n1. Create `config.yaml` from `config.yaml.example` and fill the following settings:\n    - `search_term`: The term to search for in the news headlines. For example, if you're interested in trading Bitcoin, you would set this to \"bitcoin\".\n    - `start_date`: The start date for the news search, in the format \"YYYY-MM-DD\". The search will include articles published on or after this date.\n    - `end_date`: The end date for the news search, in the format \"YYYY-MM-DD\". The search will include articles published on or before this date.\n    - `news_sources`: A list of news sources to fetch news headlines. The default is \"NewsAPI\". Additional options: \"Hackernews\".\n    - `logging_level`: The level of logging. This can be set to \"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", or \"CRITICAL\". The default is \"INFO\", which logs most messages.\n\n2. Next, you need a free API key from [newsapi.org](https://newsapi.org/register). Once you register for an account, create `.env` from `.env.example` and paste your API key into the `NEWS_API_KEY` variable.\n\n### Running the Project\n\nRun the project with:\n\n```\npython src/main.py\n```\n\nThis will first load all the enabled News Source Classes from `news_sources` directory, as defined in `config.yaml`. It will then use the News Source(s) to fetch news headlines from the specified date-range and save them all into a file named `headlines.csv` in the current directory.\n\n## Example Headlines\nBelow is an example of the `headlines.csv` file created by this project.\nThe format is: `\"headline collected source\",\"headline collected timestamp (ms)\",\"headline published timestamp (ms)\",\"headline\"`\n```headlines.csv\n\"HackerNews\",\"1693197442000\",\"1691417271000\",\"PayPal launches PYUSD stablecoin backed by the US dollar\"\n\"NewsAPI\",\"1693197442000\",\"1690815300000\",\"SEC Reportedly Asked Coinbase to Halt All Trading—Except for Bitcoin\"\n\"NewsAPI\",\"1693197442000\",\"1690898340000\",\"Crypto stocks dip after bitcoin slumps to six-week low - Reuters\"\n\"HackerNews\",\"1693197442000\",\"1691087111000\",\"Razzlekhan and husband guilty of $4.5bn Bitcoin launder\"\n```\n\n## Contributing\n\n### Adding Custom News Sources\n- To add a new news source, create a new Python file in the `news_sources` directory. The new file should consist of a Class with 3 methods: `__init__`, `query` and `process_data`. The Class' name should begin with a capital letter, with the rest of the letters all being lowercase. Eg. `Hackernews`, `Newsapi`.\n  - `__init__`: This method should simply initialize the config (`self.config = load_config()`) if neccessary, along with any other variables to be used by the other methods.\n  - `query`: This method should return a raw `response` from the news source. In most cases, it will consist of an API call to the relevant News Source API and should return a `response` containing all the articles with their publish dates for the specified date-range.\n  - `process_data`: This method should take the raw `response` from the `query` method and return a list of `(timestamp,title)`'s. The `timestamp` should be a unix epoch, eg. `1691381271` and the `title` should be a string containing the news headline.\n- Once the Class is created, simply add the filename to the `news_sources` list in the `config.yaml` file in order to enable it.\n- Tip: Use the 2 existing news sources as a template/reference.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinance%2Fai-trading-prototype-headlines","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinance%2Fai-trading-prototype-headlines","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinance%2Fai-trading-prototype-headlines/lists"}