{"id":13672469,"url":"https://github.com/billpwchan/futu_algo","last_synced_at":"2025-04-27T22:32:24.996Z","repository":{"id":40650091,"uuid":"323702688","full_name":"billpwchan/futu_algo","owner":"billpwchan","description":"Futu Algorithmic Trading Solution (Python) 基於富途OpenAPI所開發量化交易程序","archived":false,"fork":false,"pushed_at":"2024-02-23T11:27:20.000Z","size":148921,"stargazers_count":483,"open_issues_count":15,"forks_count":155,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-25T19:10:04.077Z","etag":null,"topics":["collaborate","finance","fintech","futu-algo","futu-api","high-frequency-trading","learn","python","trading","trading-bot","trading-platform","trading-strategies"],"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/billpwchan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-12-22T18:22:50.000Z","updated_at":"2025-04-25T09:21:40.000Z","dependencies_parsed_at":"2024-01-14T17:16:59.475Z","dependency_job_id":"093d7e65-01ec-4a0b-86ef-85b97179a440","html_url":"https://github.com/billpwchan/futu_algo","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billpwchan%2Ffutu_algo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billpwchan%2Ffutu_algo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billpwchan%2Ffutu_algo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billpwchan%2Ffutu_algo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billpwchan","download_url":"https://codeload.github.com/billpwchan/futu_algo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251219601,"owners_count":21554444,"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":["collaborate","finance","fintech","futu-algo","futu-api","high-frequency-trading","learn","python","trading","trading-bot","trading-platform","trading-strategies"],"created_at":"2024-08-02T09:01:36.543Z","updated_at":"2025-04-27T22:32:19.972Z","avatar_url":"https://github.com/billpwchan.png","language":"Python","funding_links":["https://www.buymeacoffee.com/billpwchan98"],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg alt=\"FutuAlgo Logo\" src=\"https://raw.githubusercontent.com/billpwchan/futu_algo/master/images/logo.png\" width=\"400px\" /\u003e\n\n**billpwchan/futu-algo API Reference Documentation**\n\n\u003ca href=\"https://www.buymeacoffee.com/billpwchan98\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"\u003e\u003c/a\u003e\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9bd8017de7e94474aa5254c5061f17d6)](https://app.codacy.com/gh/billpwchan/futu_algo?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=billpwchan/futu_algo\u0026utm_campaign=Badge_Grade_Settings)\n\n[![Issues](https://img.shields.io/github/issues/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo/issues)\n[![License](https://img.shields.io/github/license/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo/blob/master/LICENSE)\n[![LastCommit](https://img.shields.io/github/last-commit/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo/blob/master/LICENSE)\n[![CommitActivity](https://img.shields.io/github/commit-activity/y/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo/commits/master)\n[![WorkflowStatus](https://img.shields.io/github/workflow/status/billpwchan/futu_algo/CodeQL?style=for-the-badge)](https://github.com/billpwchan/futu_algo/commits/master)\n[![RepoSize](https://img.shields.io/github/repo-size/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo)\n[![Languages](https://img.shields.io/github/languages/top/billpwchan/futu_algo?style=for-the-badge)](https://github.com/billpwchan/futu_algo)\n\n\u003c/div\u003e\n\n## Highlights\n\n- **Supported Platforms and Markets**\n\n  Futu_algo is a algorithmic trading solution developed based on FutuOpenD and FutuOpenAPI. Fully support FutuNiuNiu and\n  FutuMooMoo users in Hong Kong stock market. *(More market support is coming soon)*\n- **Historical K-Line Data**\n\n  Allow users to automatically downloading historical data for your interested stocks into CSV and storing to SQLite\n  database for backtesting. *(up to 1M level for max. 2 years, or 1D level for max. 10 years)*\n- **Backtesting Trading Strategies (BETA)**\n\n  Backtest your own trading strategies on historical data with a summarized reports and visualizations using Pyfolio.\n  For more demanding users, feel free to other commercial solutions such as Amibroker for backtesting.\n- **Algorithmic Trading**\n\n  Real-time low-latency trading features that allows applying your own basket of trading strategies on your stock pool.\n  User can specify the trading strategy to be used for each stock based on their preference.\n\n  ***EXAMPLE: 0.01s/STOCK TO DECIDE BUY/SELL ORDER WITH A 3-TECHNICAL INDICATORS STRATEGY (MACD, KDJ AND CLOSE PRICE)***\n\n- **Advanced Stock Screener**\n\n  Screens high-quality stocks using your own stock screening strategies, and notify your friends using the email\n  subscription feature. **Feel free to subscribe by submitting this Google Form! https://forms.gle/C9y4kyYUArKmFzu86**\n- **Trading Strategy Editor**\n\n  Write your own trading strategy following a simple template (buy, sell, calculate technical indicators). Common\n  strategies such as MACD and KDJ-based trading rules are provided as guidelines.\n- **GUI Support (Upcoming)**\n\n  Easy-to-use GUI for users to adjust their configurations, trading, downloading data and filtering stocks within one\n  application. No longer need to type any command for trading!\n\n## Version Guidance\n\n| FutuAlgo Release | Futu OpenAPI Specification |\n|:-----------------|:---------------------------|\n| 1.0              | 6.1                        |\n\n## Deployment\n\n### Pre-Requisite: Configuration File (Config.ini)\n\n```ini\n[FutuOpenD.Config]\nHost = \u003cOpenD Host\u003e\nPort = \u003cOpenD Port\u003e\nWebSocketPort = \u003cOpenD WebSocketPort\u003e\nWebSocketKey = \u003cOpenD WebSocketKey\u003e\nTrdEnv = \u003cSIMULATE or REAL\u003e\n\n[FutuOpenD.Credential]\nUsername = \u003cFutu Login Username\u003e\nPassword_md5 = \u003cFutu Login Password Md5 Value\u003e\n\n[FutuOpenD.DataFormat]\nHistoryDataFormat = [\"code\",\"time_key\",\"open\",\"close\",\"high\",\"low\",\"pe_ratio\",\"turnover_rate\",\"volume\",\"turnover\",\"change_rate\",\"last_close\"]\nSubscribedDataFormat = None\n\n[TradePreference]\nLotSizeMultiplier = \u003c# of Stocks to Buy per Signal\u003e\nMaxPercPerAsset = \u003cMaximum % of Capital Allocated per Asset\u003e\nStockList = \u003cSubscribed Stocks in List Format\u003e\n\n[Backtesting.Commission.HK]\nFixedCharge = \u003cFixed Transaction Fee and Tax in HKD - 15.5\u003e\nPercCharge = \u003cPercentage Transaction Fee in % - 0.1097\u003e\n\n[Email]\nPort = \u003cServer SMTP Setting\u003e\nSmtpServer = \u003cServer SMTP Setting\u003e\nSender = \u003cSender Email Address - account1@example.com\u003e\nLogin = \u003cSender Email Address - account1@example.com\u003e\nPassword = \u003cSender Email Password\u003e\nSubscriptionList = [\"account1@example.com\", \"account2@example.com\"]\n\n[TuShare.Credential]\ntoken = 2134342ABC2D03780772038A7816\n```\n\n**IMPORTANT NOTE:** The format may be changed in later commits. Please refer to this README if exception is raised.\n\n### 1. Install Dependencies\n\nInstall using [conda](https://docs.conda.io/en/latest/):\n\n```bash\nconda env create -f environment.yml\n```\n\nTo export current environment, use the following command\n\n```bash\nconda env export \u003e environment.yml\n```\n\nTo update current environment with the latest dependencies, use the following command\n\n```bash\nconda env update --name futu_trade --file environment.yml --prune\n```\n\nFor GitHub Actions - with pip dependencies, use the following command\n\n```bash\npip list --format=freeze \u003e requirements.txt\n```\n\n### 2. Install FutuOpenD\n\nFor **Windows/MacOS/CentOS/Ubuntu**:\n\nhttps://www.futunn.com/download/OpenAPI\n\nPlease do make sure that you have at least a LV1 subscription level on your interested quotes. For details, please refer\nto https://openapi.futunn.com/futu-api-doc/qa/quote.html\n\n**MAKE SURE YOU LOGIN TO FUTU OPEND FIRST BEFORE STARTING FUTU_ALGO!**\n\n### 4. Download Data (e.g. 1M Data for max. 2 Years)\n\nFor **Windows**:\n\n    python main_backend.py --force_update\n\nFor **MacOS/Linux**:\n\n    python3 main_backend.py --force_update\n\n### 4. Enjoy :smile:\n\n## Command-line Interface Usages\n\n### Historical Data Download \u0026 Processing\n\nUpdate all `K_1M` and `K_DAY` interval historical K-line data\n\n    python main_backend.py -u   /   python main_backend.py --update\n\n**IMPORTANT NOTE:** This will not override existing historical data if the file exists. It will automatically detect\nthe latest stock data you have downloaded in the folder and resume from there.\n\nIf you want to refresh all data, use the following command instead (WITH CAUTION!)\n\n    python main_backend.py -fu   /   python main_backend.py --force_update\n\n### Algorithmic Trading\n\nExecute Algorithmic Trading with a Pre-defined Strategy (By default use **1M data**)\n\n    python main_backend.py -s MACD_Cross   /   python main_backend.py --strategy MACD_Cross\n\nIf you would like to use another time interval based date (e.g., Day data), use the following command\n\n    python main_backend.py -s MACD_Cross --time_interval K_DAY\n\nIf you do not have a pre-defined stock list in `config.ini`, then you can just trade the Top 30 HSI stocks\n\n    python main_backend.py -s MACD_Cross --include_hsi --time_interval K_DAY\n\n**IMPORTANT NOTE:** The supported time intervals are: K_1M, K_30M, K_5M, K_15M, K_30M, K_60M, K_DAY, K_WEEK, K_MON,\nK_YEAR.\n\n### Stock Filtering and Email Subscription\n\nExecute Stock Filtering with Pre-defined Filtering Strategies with Email Title \"MACD_Cross_Technique\" in HK and\nChina (Shanghai and Shenzhen) Stock Market\n\n    python main_backend.py -f Volume_Threshold Price_Threshold -en MACD_Cross_Technique -m HK CHINA\n\n## GUI Usages\n\nStart the GUI with `main.py` (**NOT FINISHED YET**)\n\n    python main.py\n\n## Future Plans\n\n- [ ] [NEED A GREAT NAME FOR THIS ALGO TRADE!!](https://github.com/billpwchan/futu_algo/issues/23)\n- [x] [Custom Backtesting Time Interval]()\n- [x] [Dynamic Instantiation](https://github.com/billpwchan/futu_algo/issues/18)\n\n-----------\n\n## Contributor\n\n[Bill Chan -- Main Developer](https://github.com/billpwchan/)\n\n## Disclaimer\n\nFutures, stocks and options trading involves substantial risk of loss and is not suitable for every investor. The\nvaluation of futures, stocks and options may fluctuate, and, as a result, clients may lose more than their original\ninvestment. The impact of seasonal and geopolitical events is already factored into market prices. The highly leveraged\nnature of futures trading means that small market movements will have a great impact on your trading account and this\ncan work against you, leading to large losses or can work for you, leading to large gains.\n\nIf the market moves against you, you may sustain a total loss greater than the amount you deposited into your account.\nYou are responsible for all the risks and financial resources you use and for the chosen trading system. You should not\nengage in trading unless you fully understand the nature of the transactions you are entering into and the extent of\nyour exposure to loss. If you do not fully understand these risks you must seek independent advice from your financial\nadvisor.\n\nAll trading strategies are used at your own risk.\n\nAny content in this repository should not be relied upon as advice or construed as providing recommendations of any\nkind. It is your responsibility to confirm and decide which trades to make. Trade only with risk capital; that is, trade\nwith money that, if lost, will not adversely impact your lifestyle and your ability to meet your financial obligations.\nPast results are no indication of future performance. In no event should the content of this correspondence be construed\nas an express or implied promise or guarantee.\n\nThis repository and its author are not responsible for any losses incurred as a result of using any of our trading\nstrategies. Loss-limiting strategies such as stop loss orders may not be effective because market conditions or\ntechnological issues may make it impossible to execute such orders. Likewise, strategies using combinations of options\nand/or futures positions such as “spread” or “straddle” trades may be just as risky as simple long and short positions.\nInformation provided in this correspondence is intended solely for informational purposes and is obtained from sources\nbelieved to be reliable. Information is in no way guaranteed. No guarantee of any kind is implied or possible where\nprojections of future conditions are attempted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillpwchan%2Ffutu_algo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillpwchan%2Ffutu_algo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillpwchan%2Ffutu_algo/lists"}