{"id":19437702,"url":"https://github.com/renovamen/stockbot","last_synced_at":"2026-06-10T01:31:17.321Z","repository":{"id":101152535,"uuid":"173486839","full_name":"Renovamen/StockBot","owner":"Renovamen","description":"A chatbot based on Rasa NLU aims to provide stock and weather information implemented by Python | 基于 Rasa NLU 的提供股票和天气信息的聊天机器人","archived":false,"fork":false,"pushed_at":"2019-06-03T16:31:47.000Z","size":41411,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-25T07:15:27.894Z","etag":null,"topics":["chatbot","iexfinance-api","rasa-nlu"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Renovamen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-03-02T18:55:27.000Z","updated_at":"2019-12-10T03:02:08.000Z","dependencies_parsed_at":"2023-04-10T18:31:30.402Z","dependency_job_id":null,"html_url":"https://github.com/Renovamen/StockBot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Renovamen/StockBot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Renovamen%2FStockBot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Renovamen%2FStockBot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Renovamen%2FStockBot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Renovamen%2FStockBot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Renovamen","download_url":"https://codeload.github.com/Renovamen/StockBot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Renovamen%2FStockBot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34133404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chatbot","iexfinance-api","rasa-nlu"],"created_at":"2024-11-10T15:15:38.354Z","updated_at":"2026-06-10T01:31:17.295Z","avatar_url":"https://github.com/Renovamen.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StockBot\n\nStockBot is a chatbot based on Rasa NLU aims to provide stock and weather information implemented by Python.\n\n\n\u0026nbsp;\n## Demo Video\n\n[![Demo](img/cover.png)](https://www.youtube.com/watch?v=PnmfahdQ7PI)\n\n\n\nIf the video is unable to load, you can download it: [Demo.mp4](Demo.mp4)\n\n\n\n\u0026nbsp;\n## Environment\n\n- Python 3.6.7\n- Jupyter Notebook\n\n\n\u0026nbsp;\n## Structure\n\n```\n└── StockBot                        \n    ├── StockBot.ipynb         // chatbot\n    ├── training_data.json     // training data for extracting intents and entities\n    ├── config_spacy.yml       // config for trainer\n    ├── city_code.db           // database(all provinces in China with their codes)\n    ├── Report.pdf             // report of this project\n    └── Demo.mp4               // a demo showing an example dialogue\n```\n\n\n\u0026nbsp;\n## Requirements\n\n```python\npip install rasa_nlu\npip install iexfinance\npip install wxpy\npip install sqlite3\npip install matplotlib\n```\n\n\n\u0026nbsp;\n## How to run\n\nJust download the project and run it in jupyter notebook.\n\n\n\n\n\u0026nbsp;\n## Usage\n\n### Rasa NLU\n\nDocumentation: https://rasa.com/docs/nlu/\n\n\n\nImport:\n\n```python\nfrom rasa_nlu.training_data import load_data\nfrom rasa_nlu.config import RasaNLUModelConfig\nfrom rasa_nlu.model import Trainer\nfrom rasa_nlu import config\n```\n\n\n\n#### Train\n\n```python\ntrainer = Trainer(config.load(\"config_spacy.yml\"))\ntraining_data = load_data('training_data.json')\ninterpreter = trainer.train(training_data)\n```\n\n\n\n#### Extract intents and entities\n\n```python\ninterpreter.parse(\"message\")\n```\n\n\n\n\n\u0026nbsp;\n### Iexfinance\n\nDocumentation: https://addisonlynch.github.io/iexfinance/devel/\n\n\n\nImport:\n\n```python\nfrom iexfinance.stocks import Stock\nfrom iexfinance.stocks import get_historical_data\nfrom iexfinance.stocks import get_historical_intraday\n```\n\n\n\nGet data:\n\n```\nStock(company).get_price() # get current price of a certain stock\nStock(company).get_key_stats()['ttmEPS'] # get TTM of a certain stock\nStock(company).get_news() # get relevant news of a certain stock\n```\n\n\n\n\n\u0026nbsp;\n### Weather API\n\nFirst you need to apply for a key in: https://www.juhe.cn/docs/api/id/39 (Documentation can also be found there), and put it here:\n\n```python\ndef get_weather(day_list, city):\n    weather_key = \"\"\n    \n    # actions...\n```\n\n\n\nThis API needs you to post a request with the code of the city or province which you want to query about. In order to try some database operations, this project establish a database consisting of all provinces in China with their codes  (`city_code.db`). \n\n```python\ndef get_citycode(city):\n    conn = sqlite3.connect('city_code.db')\n    c = conn.cursor()\n    query = \"SELECT * FROM city WHERE name = '\" + city + \"'\"\n    c.execute(query)\n    result =  c.fetchall()\n    \n    code = '' \n    for row in result:\n       code = row[0]\n    return code\n```\n\n\n\nIn fact this database is not necessary. If you don't want to do these database operations, you can try this API providing each province and city’s code: https://www.juhe.cn/docs/api/id/39.\n\n\n\u0026nbsp;\n### Connect to Wechat\n\n#### wxpy\n\nThis part is based on the Python package: wxpy. Documentation: https://wxpy.readthedocs.io/zh/latest/bot.html.\n\n```python\nfrom wxpy import *\n\nbot = Bot()\nmy_friend = bot.friends().search(\"name_of_your_friend\")[0]\n\n@bot.register(my_friend, TEXT)\ndef auto_reply(msg):\n    \n    # actions...\n\nbot.registered\n```\n\nA QR code will be generated after creating a bot. Use your WeChat account to scan this QR code and login, then you can use your friend's WeChat accout to chat with this chatbot.\n\n\n\n#### itchat\n\nBecause wxpy has not been updated for a long time, this project provides another way to connect to WeChat through a Python package called itchat. Documentation: https://itchat.readthedocs.io/zh/latest/\n\n```python\nimport itchat\nfrom itchat.content import *\n\nitchat.auto_login()\nmy_friend = itchat.search_friends(name=\"name_of_yourfriend\")[0]['UserName']\n\n@itchat.msg_register([TEXT])\ndef auto_reply(msg):\n    \n    # action...\n\nitchat.run()\n```\n\n\n\u0026nbsp;\n### Debug in terminal\n\nYou can debug the code in terminal in following way instead of connecting to WeChat:\n\n```python\nwhile True:\n    state = MAIN\n    pending = None\n\n    msg = input()\n    print(\"USER: \" + msg)\n\n    state, pending, final_response, message_intent = send_message(state, pending, msg)\n    print(\"BOT: \" + final_response)\n```\n\n\n\n\n\nHave fun :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenovamen%2Fstockbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frenovamen%2Fstockbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frenovamen%2Fstockbot/lists"}