{"id":15501650,"url":"https://github.com/amicks/speculator","last_synced_at":"2025-08-03T10:11:06.467Z","repository":{"id":57469766,"uuid":"102282685","full_name":"amicks/Speculator","owner":"amicks","description":"API for predicting the next Bitcoin and Ethereum with machine learning and technical analysis","archived":false,"fork":false,"pushed_at":"2018-09-12T18:58:48.000Z","size":143,"stargazers_count":103,"open_issues_count":1,"forks_count":35,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-07-05T00:51:52.939Z","etag":null,"topics":["algorithm","finance","machine-learning","market","python","python3-6","scikit-learn","technical-analysis","tensorflow"],"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/amicks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-03T17:43:03.000Z","updated_at":"2024-06-02T00:04:52.000Z","dependencies_parsed_at":"2022-09-19T10:20:28.554Z","dependency_job_id":null,"html_url":"https://github.com/amicks/Speculator","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/amicks/Speculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amicks%2FSpeculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amicks%2FSpeculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amicks%2FSpeculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amicks%2FSpeculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amicks","download_url":"https://codeload.github.com/amicks/Speculator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amicks%2FSpeculator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266187677,"owners_count":23890012,"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":["algorithm","finance","machine-learning","market","python","python3-6","scikit-learn","technical-analysis","tensorflow"],"created_at":"2024-10-02T09:05:12.085Z","updated_at":"2025-07-20T19:34:45.991Z","avatar_url":"https://github.com/amicks.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://i.imgur.com/AmrHhZV.png\" width=\"425\" height=\"200\"\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![travis build](https://img.shields.io/travis/amicks/Speculator.svg)](://travis-ci.org/amicks/Speculator)\n![python version](https://img.shields.io/pypi/pyversions/Speculator.svg)\n[![license](https://img.shields.io/pypi/l/Speculator.svg)](https://github.com/amicks/Speculator/blob/master/LICENSE)\n[![tag](https://img.shields.io/github/tag/amicks/speculator.svg)](https://github.com/amicks/Speculator/archive/0.1.tar.gz)\n![status](https://img.shields.io/pypi/status/Speculator.svg)\n\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\nSpeculator is an API for predicting the price trend of cryptocurrencies like Bitcoin and Ethereum.\n\nNormal markets will also be added in future updates.\n\n# Getting Started\n\n## REST API\nStart the Flask app then make requests:\n``` bash\npython app.py\ncurl http://localhost:5000/api/public/predict -X GET\n```\n\n### Dependencies\nMake sure these packages are installed before running Speculator:\n``` bash\npip3 install delorean requests numpy tensorflow scikit-learn pandas flask flask-caching flask-restful flask-sqlalchemy psycopg2 webargs scipy\n```\n\n### Routes Summary\n- GET/DELETE: `/api/private/market/`\n  - GET/DELETE: `/api/private/market/?\u003cint:id\u003e`\n    - PUT/POST: `/api/private/market/?\u003cint:id\u003e\u0026\u003cfloat:low\u003e\u0026\u003cfloat:high\u003e\u0026\u003cfloat:close\u003e\u0026\u003cfloat:volume\u003e`\n- GET: `/api/public/predict/?\u003cbool:use_db\u003e\u0026\u003cstr:model_type\u003e\u0026\u003cstr:symbol\u003e\u0026\u003cstr:unit\u003e\u0026\u003cint:count\u003e\u0026\u003cint:period\u003e\u0026\u003cint:partition\u003e\u0026\u003cint:delta\u003e\u0026\u003cint:seed\u003e\u0026\u003cint:trees\u003e\u0026\u003cint:jobs\u003e\u0026\u003cDelimitedList\u003cstr\u003e:longs\u003e`\n\n---\n\n### GET: `/api/private/market/?\u003cint:id\u003e`\n\nRetrieves market data from *optional* id.  When omitted, all entries will be returned.\n\nExample Output:\n\n```json\n[\n    {\n      \"id\": 1,\n      \"low\": 2.0,\n      \"high\": 10.0,\n      \"close\": 6.0,\n      \"volume\": 2.0\n    },\n    {\n        \"id\": 2,\n        \"low\": 23.0,\n        \"high\": 40.0,\n        \"close\": 33.0,\n        \"volume\": 5.0\n    }\n]\n```\n\n### POST: `/api/private/market/?\u003cint:id\u003e\u0026\u003cfloat:low\u003e\u0026\u003cfloat:high\u003e\u0026\u003cfloat:close\u003e\u0026\u003cfloat:volume\u003e`\n\nUpdates market data from *required* id and *optional* keyword arguments of low, high and close prices, and volume.\n\nExample Output:\n\n```json\n{\n    \"id\": 1,\n    \"low\": 2.0,\n    \"high\": 10.0,\n    \"close\": 6.0,\n    \"volume\": 2.0\n}\n```\n\n### PUT: `/api/private/market/?\u003cint:id\u003e\u0026\u003cfloat:low\u003e\u0026\u003cfloat:high\u003e\u0026\u003cfloat:close\u003e\u0026\u003cfloat:volume\u003e`\n\nCreates market data from *required* id and *optional* keyword arguments of low, high and close prices, and volume.\nA value of -1 clears the attribute.\n\nExample Output:\n\n```json\n{\n    \"id\": 1,\n    \"low\": 2.0,\n    \"high\": 10.0,\n    \"close\": 5.0,\n    \"volume\": null\n}\n```\n\n### DELETE: `/api/private/market/?\u003cint:id\u003e`\n\nDeletes market data from *optional* id.  When omitted, all entries will be deleted.\n\nExample Output:\n\n```json\n{\n    \"status\": \"successful\"\n}\n```\n\n---\n\n### GET: `/api/public/predict/?\u003cbool:use_db\u003e\u0026\u003cstr:model_type\u003e\u0026\u003cstr:symbol\u003e\u0026\u003cstr:unit\u003e\u0026\u003cint:count\u003e\u0026\u003cint:period\u003e\u0026\u003cint:partition\u003e\u0026\u003cint:delta\u003e\u0026\u003cint:seed\u003e\u0026\u003cint:trees\u003e\u0026\u003cint:jobs\u003e\u0026\u003cDelimitedList\u003cstr\u003e:longs\u003e`\n\nGets prediction of the next trend, including probabilities of various outcomes and test set accuracy.\n\nExample Output:\n\n```json\n{\n    \"trend\": \"bearish\",\n    \"test_set_accuracy\": 0.46153846153846156,\n    \"probabilities\": {\n        \"bearish\": 0.8,\n        \"neutral\": 0.0,\n        \"bullish\": 0.2\n    }\n}\n```\n\nAll arguments are optional:\n- use_db: Enables the use of DB market data from the private API\n  - note: When True, arguments for automatic gathering of data will be disabled (like unit)\n  - default: False\n- model_type: Machine learning model to train\n  - default: 'random_forest'\n  - valid values: 'random_forest', 'rf', 'deep_neural_network', or 'dnn'\n- symbol: Currency to predict\n  - default: 'USDT_BTC'\n  - valid values: Symbols/Conversions are available via [Poloniex](https://poloniex.com/exchange)\n- unit: Duration to predict from\n  - default: 'month'\n  - valid values: second, minute, hour, day, week, month, year\n- count: `units` to predict from\n  - default: 6\n- period: Seconds for each chart candlestick\n  - default: 86400\n  - valid values: 300, 900, 1800, 7200, 14400, 86400\n- partition: Market dates for each feature\n  - note: A K-day RSI would need a partition of K\n  - default: 14\n- delta: Size of price neutral zone\n  - note: Distinguishes between bearish/neutral/bullish trends\n  - default: 25\n- seed: Produces consistent results for ML models\n  - note: When omitted (seed is None), values are inconsistent and not reproducible\n  - default: None\n- trees: Trees for the Random Forest model\n  - note: Higher values (~65) are typically more accurate\n  - default: 10\n- jobs: CPU threads to use\n  - default: 1\n- longs: Uses long duration features\n  - note: A K-day RSI would also include a 2K-day RSI (*long RSI*)\n  - default: []\n\n---\n\nIf you want to access the private API, simply make the DB connection an environment variable:\n```\nexport SQLALCHEMY_DATABASE_URI='postgresql://username:password@host:port/db'\n```\n\nFor a full list of SQLALCHEMY\\_DATABASE\\_URI formats, see [SQLAlchemy's docs](http://flask-sqlalchemy.pocoo.org/2.3/config/) under \"Connection URI Format\".\n\nPrivate API access with a DB is enabled by default in api/\\_\\_init\\_\\_.py\nSet `ENABLE_DB = False` to disable this.\n\n---\n\nI plan to start a server for anyone to access this without starting their own Flask server, but with only public access.\nStarting this on your own server with authentication for users (private access) will allow you to PUT/POST/DELETE your own market data and analyze that instead of the default.\nThis is currently in development and will be extended in the future.\n\n## Python Usage\n- program: `python main.py`\n- package: `pip3 install speculator`\n\nExample Output:\n\u003cp\u003e\n  \u003cimg src=\"https://i.imgur.com/c6JdDWt.png\" width=\"700\" height=\"180\"\u003e\n\u003c/p\u003e\n\nUse the `--help` flag for a complete list of optional arguments.\n\n## Project Structure\n```\nLICENSE\nREADME.md\n\napi\n  \\_ models\n           \\_ market.py\n  \\_ resources\n              \\_ market.py\n              \\_ trend.py\n  \\_ app.py\n  \\_ helpers.py\n\ndocs\n  \\_ CONTRIBUTING.md\n  \\_ analysis.md\n  \\_ example.md\n  \\_ example.py\n  \\_ utils.md\n\nspeculator\n    \\_ main.py\n    \\_ market.py\n    \\_ features\n                \\_ obv.py\n                \\_ rsi.py\n                \\_ sma.py\n                \\_ so.py\n    \\_ models\n             \\_ deep_neural_network.py\n             \\_ random_forest.py\n    \\_ tests\n            \\_ integration\n                          \\_ test_poloniex.py\n            \\_ unit\n                   \\_ test_date.py\n                   \\_ test_poloniex.py\n                   \\_ test_obv.py\n                   \\_ test_rsi.py\n                   \\_ test_sma.py\n                   \\_ test_so.py\n                   \\_ test_stats.py\n    \\_ utils\n            \\_ date.py\n            \\_ poloniex.py\n            \\_ stats.py\n```\n\n## Contact for Feedback, Questions, or Issues\nFeel free to send me a message on Reddit at [/u/shneap](https://www.reddit.com/message/compose?to=shneap).  I am happy to hear any concerns, good or bad, in order to progress the development of this project.\n\n###### Note: A website for a friendly user experience is in development\n\n## Contributing\nPlease see the [contributing doc](docs/CONTRIBUTING.md).\n\n## Basis\nPart of this project is focused on an implementation of the research paper [\"Predicting the direction of stock market prices using random forest\"](https://arxiv.org/pdf/1605.00003.pdf) by Luckyson Khaidem, Snehanshu Saha, and Sudeepa Roy Dey. I hope to gain insights into the accuracy of market technical analysis combined with modern machine learning methods.\n\n## Disclaimer\nSpeculator is not to be used as financial advice or a guide for any financial investments.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famicks%2Fspeculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famicks%2Fspeculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famicks%2Fspeculator/lists"}