{"id":13551182,"url":"https://github.com/achillesrasquinha/bulbea","last_synced_at":"2025-04-08T08:12:34.128Z","repository":{"id":37412417,"uuid":"84404972","full_name":"achillesrasquinha/bulbea","owner":"achillesrasquinha","description":":boar: :bear: Deep Learning based Python Library for Stock Market Prediction and Modelling","archived":false,"fork":false,"pushed_at":"2021-01-17T09:07:36.000Z","size":2768,"stargazers_count":2114,"open_issues_count":36,"forks_count":478,"subscribers_count":129,"default_branch":"master","last_synced_at":"2025-04-01T05:33:59.861Z","etag":null,"topics":["deep-learning","finance","machine-learning","prediction","python-library","quantitative-finance","quantitative-trading","sentiment-analysis","stock-market","stock-market-prediction","stock-prediction"],"latest_commit_sha":null,"homepage":"http://bulbea.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/achillesrasquinha.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}},"created_at":"2017-03-09T06:11:06.000Z","updated_at":"2025-03-31T01:30:09.000Z","dependencies_parsed_at":"2022-07-09T04:17:04.831Z","dependency_job_id":null,"html_url":"https://github.com/achillesrasquinha/bulbea","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achillesrasquinha%2Fbulbea","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achillesrasquinha%2Fbulbea/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achillesrasquinha%2Fbulbea/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achillesrasquinha%2Fbulbea/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/achillesrasquinha","download_url":"https://codeload.github.com/achillesrasquinha/bulbea/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801169,"owners_count":20998339,"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":["deep-learning","finance","machine-learning","prediction","python-library","quantitative-finance","quantitative-trading","sentiment-analysis","stock-market","stock-market-prediction","stock-prediction"],"created_at":"2024-08-01T12:01:43.765Z","updated_at":"2025-04-08T08:12:34.099Z","avatar_url":"https://github.com/achillesrasquinha.png","language":"Python","funding_links":[],"categories":["Python","Code"],"sub_categories":["Trading \u0026 Backtesting","交易与回测","Events \u0026 Sentiment trading"],"readme":"# bulbea\n\u003e *\"Deep Learning based Python Library for Stock Market Prediction and Modelling.\"*\n\n[![Gitter](https://img.shields.io/gitter/room/bulbea/bulbea.svg)](https://gitter.im/bulbea/bulbea) [![Documentation Status](https://readthedocs.org/projects/bulbea/badge/?version=latest)](http://bulbea.readthedocs.io/en/latest/?badge=latest)\n\n![](.github/bulbea.png)\n\n### Table of Contents\n* [Installation](#installation)\n* [Usage](#usage)\n* [Documentation](#documentation)\n* [Dependencies](#dependencies)\n* [License](#license)\n\n### Installation\nClone the git repository:\n```console\n$ git clone https://github.com/achillesrasquinha/bulbea.git \u0026\u0026 cd bulbea\n```\n\nInstall necessary dependencies\n```console\n$ pip install -r requirements.txt\n```\n\nGo ahead and install as follows:\n```console\n$ python setup.py install\n```\n\nYou may have to install TensorFlow:\n```console\n$ pip install tensorflow     # CPU\n$ pip install tensorflow-gpu # GPU - Requires CUDA, CuDNN\n```\n\n### Usage\n#### 1. Prediction\n##### a. Loading\nCreate a share object.\n```python\n\u003e\u003e\u003e import bulbea as bb\n\u003e\u003e\u003e share = bb.Share('YAHOO', 'GOOGL')\n\u003e\u003e\u003e share.data\n# Open        High         Low       Close      Volume  \\\n# Date                                                                     \n# 2004-08-19   99.999999  104.059999   95.959998  100.339998  44659000.0   \n# 2004-08-20  101.010005  109.079998  100.500002  108.310002  22834300.0   \n# 2004-08-23  110.750003  113.479998  109.049999  109.399998  18256100.0   \n# 2004-08-24  111.239999  111.599998  103.570003  104.870002  15247300.0   \n# 2004-08-25  104.960000  108.000002  103.880003  106.000005   9188600.0\n...\n```\n##### b. Preprocessing\nSplit your data set into training and testing sets.\n```python\n\u003e\u003e\u003e from bulbea.learn.evaluation import split\n\u003e\u003e\u003e Xtrain, Xtest, ytrain, ytest = split(share, 'Close', normalize = True)\n```\n\n##### c. Modelling\n```python\n\u003e\u003e\u003e import numpy as np\n\u003e\u003e\u003e Xtrain = np.reshape(Xtrain, (Xtrain.shape[0], Xtrain.shape[1], 1))\n\u003e\u003e\u003e Xtest  = np.reshape( Xtest, ( Xtest.shape[0],  Xtest.shape[1], 1))\n\n\u003e\u003e\u003e from bulbea.learn.models import RNN\n\u003e\u003e\u003e rnn = RNN([1, 100, 100, 1]) # number of neurons in each layer\n\u003e\u003e\u003e rnn.fit(Xtrain, ytrain)\n# Epoch 1/10\n# 1877/1877 [==============================] - 6s - loss: 0.0039\n# Epoch 2/10\n# 1877/1877 [==============================] - 6s - loss: 0.0019\n...\n```\n\n##### d. Testing\n```python\n\u003e\u003e\u003e from sklearn.metrics import mean_squared_error\n\u003e\u003e\u003e p = rnn.predict(Xtest)\n\u003e\u003e\u003e mean_squared_error(ytest, p)\n0.00042927869370525931\n\u003e\u003e\u003e import matplotlib.pyplot as pplt\n\u003e\u003e\u003e pplt.plot(ytest)\n\u003e\u003e\u003e pplt.plot(p)\n\u003e\u003e\u003e pplt.show()\n```\n![](.github/plot.png)\n\n#### 2. Sentiment Analysis\nAdd your Twitter credentials to your environment variables.\n```bash\nexport BULBEA_TWITTER_API_KEY=\"\u003cYOUR_TWITTER_API_KEY\u003e\"\nexport BULBEA_TWITTER_API_SECRET=\"\u003cYOUR_TWITTER_API_SECRET\u003e\"\n\nexport BULBEA_TWITTER_ACCESS_TOKEN=\"\u003cYOUR_TWITTER_ACCESS_TOKEN\u003e\"\nexport BULBEA_TWITTER_ACCESS_TOKEN_SECRET=\"\u003cYOUR_TWITTER_ACCESS_TOKEN_SECRET\u003e\"\n```\nAnd then,\n```python\n\u003e\u003e\u003e bb.sentiment(share)\n0.07580128205128206\n```\n\n### Documentation\nDetailed documentation is available [here](http://bulbea.readthedocs.io/en/latest/).\n\n### Dependencies\n1. quandl\n2. keras\n3. tweepy\n4. textblob\n\n### License\nThis code has been released under the [Apache 2.0 License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachillesrasquinha%2Fbulbea","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachillesrasquinha%2Fbulbea","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachillesrasquinha%2Fbulbea/lists"}