Skip to content

maollm/futu_algo

 
 
Billerikay Logo

billpwchan/futu-algo API Reference Documentation

Issues License Downloads CommitActivity RepoSize Languages

Features

  • Developed based on FutoOpenD and FutuOpenAPI
  • Auto-Download Historical K-Line Data (up to 1M level for max. 2 years, or 1D level for max. 10 years)
  • Low-latency Trading Support (up to 1M level)
  • Daily Stock Filtering and Email Notification
  • Strategy Backtesting and Reporting

Issues

Releases

Important: Program still in Alpha Phase now.

Version Guidance

FutuAlgo Release Futu OpenAPI Specification
0.0.2-alpha.x 4.0

Deployment

Pre-Requisite: Configuration File (Config.ini)

[FutuOpenD.Config]
Host = <OpenD Host>
Port = <OpenD Port>
WebSocketPort = <OpenD WebSocketPort>
WebSocketKey = <OpenD WebSocketKey>
TrdEnv = <SIMULATE or REAL>

[FutuOpenD.Credential]
Username = <Futu Login Username>
Password_md5 = <Futu Login Password Md5 Value>

[FutuOpenD.DataFormat]
HistoryDataFormat = ["code","time_key","open","close","high","low","pe_ratio","turnover_rate","volume","turnover","change_rate","last_close"]
SubscribedDataFormat = None

[Database]
Database_path = <Your SQLite Database File Path>

[TradePreference]
LotSizeMultiplier = <# of Stocks to Buy per Signal>
MaxPercPerAsset = <Maximum % of Capital Allocated per Asset>
StockList = <Subscribed Stocks in List Format>

[Backtesting.Commission.HK]
FixedCharge = <Fixed Transaction Fee and Tax in HKD - 15.5>
PercCharge = <Percentage Transaction Fee in % - 0.1097>

[Email]
Port = <Server SMTP Setting>
SmtpServer = <Server SMTP Setting>
Sender = <Sender Email Address - account1@example.com>
Login = <Sender Email Address - account1@example.com>
Password = <Sender Email Password>
SubscriptionList = ["account1@example.com", "account2@example.com"]

IMPORTANT NOTE: The format may be changed in later commits. Please refer to this README if exception is raised.

1. Install Dependencies

Install using conda:

conda create --name <env> --file requirements.txt

2. Install FutuOpenD

For Windows/MacOS/CentOS/Ubuntu:

https://www.futunn.com/download/OpenAPI

Please do make sure that you have at least a LV1 subscription level on your interested quotes. For details, please refer to https://openapi.futunn.com/futu-api-doc/qa/quote.html

3. Initialize SQLite Database

Go to SQLite official website and follow the QuickStart instruction to install SQLite tools in the device.

Create a folder named 'database' in the root folder, and execute the SQLite DDL file stored in ./util/database_ddl.sql .

./
  ├── database
  │       └── stock_data.sqlite

4. Download Data (e.g. 1M Data for max. 2 Years)

For Windows:

python main.py -u

For MacOS/Linux:

python3 main.py -u

4. Enjoy 😄

Usages

Update all K_1M and K_DAY interval historical K-line data

python main.py -u   /   python main.py --update

IMPORTANT NOTE: This will not override existing historical data if the file exists.

If you want to refresh all data, use the following command instead (WITH CAUTION!)

python main.py -fu  /   python main.py --force_update

Store all data from CSV to SQLite Database

python main.py -d   /   python main.py --database

Execute High-Frequency Trading (HFT) with a Pre-defined Strategy

python main.py -s MACD_Cross    /   python main.py --strategy MACD_Cross

Execute Stock Filtering with Pre-defined Filtering Strategies

python main.py -f Volume_Threshold Price_Threshold   /   python main.py --filter Volume_Threshold Price_Threshold

Contributor

Bill Chan -- Main Developer

About

Futu Algorithmic Trading Framework (Python) 基于富途OpenApi所开发量化高频交易框架

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%