GithubHelp home page GithubHelp logo

billpwchan / futu_algo Goto Github PK

View Code? Open in Web Editor NEW
380.0 16.0 131.0 145.43 MB

Futu Algorithmic Trading Solution (Python) 基於富途OpenAPI所開發量化交易程序

License: Apache License 2.0

Python 100.00%
python finance fintech trading trading-bot trading-platform futu-api trading-strategies high-frequency-trading futu-algo

futu_algo's Issues

Create a new thread for placing buy/sell orders

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
After receiving the data, use another thread with timeout to place buy/sell orders.

Describe alternatives you've considered
N/A

Additional context
N/A

Use GitHub Actions to send daily filtered stock list to subscribers

Hi,

Would be nice to have a feature that sets up a cron job in Github Actions to process all stocks using a pre-defined strategy and send out the daily selected stocks to subscribers. The subscribers can simply include their name in a list or comment them in GitHub and you can setup a workflow to automatically update that list on a daily basis.

Let me know what's your thought! 😊

Filter Stocks based on Fundamental Stats

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
So currently, the strategy might lead to incorrect buy decisions for some stocks with tiny transaction volumes (e.g., a sudden large buy from funds will cause the technical indicators to suddenly satisfy the condition of the buy strategy). It is better to filter out these less healthy stocks in our stocks pool before starting the high-frequency trading

Describe alternatives you've considered
May be implemented before the trading starts or after the trading starts.

Additional context
Nah

Data Processing API + Pathlib Refactor

  1. Remove all dependencies in trading_engine.py, and move all data processing scripts into data_engine.py
  2. Use Pathlib instead of file path string for cross-platform support.

FileNotFoundError

Describe the bug
FileNotFoundError: [Errno 2] No such file or directory: 'D:\Users\admin\Documents\Python\futu_algo-master\data\Stock_Pool\ListOfSecurities.csv'

Stock Selector based on Technical Indicators

Is your feature request related to a problem? Please describe.
Nah

Describe the solution you'd like
Update HFT Stock Pool based on a separate stock selector (using primarily Yahoo Finance data).

Describe alternatives you've considered
Support other data sources such as Google Finance or other paid subscribed data source.

Additional context

Support LV2 / LV1 Data Subscription Plan in HK Stock Market

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Currently, the script only works if the user buys Lv2 data subscription card with 318HKD / Month. However, if the IP address is from Mainland China, FuTu automatically grant Lv1 data subscription without extra cost. However, we don't have Orderbook and some other features comparing with Lv2.

Need to update the solution and another configuration field in Config.ini to indicate which data subscription plan is used.

Describe alternatives you've considered
No

Additional context
No

Support for Options Trading Strategies

Is your feature request related to a problem? Please describe.
N/A

Describe the solution you'd like
It would be better if futu_algo can support Options Trading Strategies such as bull call spread in addition to the existing spot trading

Describe alternatives you've considered
Interactive Brokers might have a more mature solution for US market, but for HK stock market, it would be easier to just develop a simple options trading engine from scratch.

Stock Data Custom Interval

When converting 1M stock data to any time interval greater than 60M, it creates discrepancy between the generated file & actual file due to the non-trading hours.

For instance, for 1H interval, the suggested key timestamps are

  1. 9:30
  2. 10:30
  3. 11:30
  4. 12:00 -> Creating issue because the difference is only 30M between this one as the previous timestamp

Need to update the logic to support this types of conversion using 1M-based stock data.

Use Parquet instead of CSV for better performance

  1. Refactor the code so all the I/O related operations are encapsulated in data_engine
  2. Convert CSV to Parquet with 2X saving in file size...Amazing
  3. Create a utility function for ppl who've already downloaded historical data in CSV format, and they can easily use the utility function to convert all CSV to Parquet ease.

ADX & RSI Trading Strategy

ADX & RSI Strategy based on the following specification

ADXdays=Optimize("ADXdays",10,5,25,5);
ADXlimit=Optimize("ADXlimit",25,10,50,5);
RSI_threshold = Optimize("RSILimit",20,5,100,5);

Buy= RSI(2) < RSI_threshold AND ADX(ADXdays)>ADXlimit ;
buyPrice=Close;

Sell= C>Ref(H,-1);

Paper trading?

Hello

Great project you've got here! I believe Futu provides support for paper trading, Does this support paper trading though?

Switch from StockQuoteHandlerBase to RTDataHandlerBase

StockQuote Handler Base will push a message to subscriber everytime the price is changed.
RTData Handler Base will push a message every 1 minute.

To use strategies like MACD crossover, it is better to use RTDat than StockQuote which is less sensitive in real-time.

Data Inconsistency

It seems some stock's data aren't correct when I downloaded them. For instance, for stock HK.01997, the 1M data I downloaded isn't consistent with the one I observed in the Futu client. Gotta use data validator to ensure all data are correct before backtesting.

How to execute main_backend.py or setup.py files? and how to configure

Describe the bug
When execute the main_backend.py file,it return:

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help

error: no commands supplied

the setup.py --help does not work

what is the cmds, may i have the example of the parameters

if possible, we can use Chinese to communicate

Data Validator

Create a data validator to ensure all downloaded data are correct. Use futu openAPI to retrieve trading days and trading day type, then validate the number of entry

ERROR — Cannot subscribe to K-Line: No right to subscribe

Hi there. I'm trying to run the main_backend.py but I keep getting an error:

ERROR — Cannot subscribe to K-Line: No right to subscribe 00001

I have a subscription quota of 300 according to OpenD and subscription status query also shows 300:

INFO — Query Subscription Quota: {'total_used': 0, 'remain': 300, 'own_used': 0, 'sub_list': {}}

Does anyone know why this might be the case?

Any advice appreciated. Thanks.

  • Futu version 7.1.3308

Per-Stock Strategy Subscription

For each stock, use a different strategy defined in a mapping file. This is based on the observation that no single strategy can be suitable for all different types of stocks. This mapping file should be built based on backtesting results.

Calculate Close Price Slope

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Support for Email / SMS / WhatsApp

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
When we have a buy/sell signal, send an Email / SMS/ WhatsApp Message to clients

Describe alternatives you've considered
Nah

Additional context
Nah

run python main_backend.py -b MACD_Cross error

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
python main_backend.py -b MACD_Cross

Traceback (most recent call last):
File "/Users/lilili/git/shuque/stock/futu_algo/main_backend.py", line 249, in
main()
File "/Users/lilili/git/shuque/stock/futu_algo/main_backend.py", line 243, in main
init_backtesting(args.backtesting)
File "/Users/lilili/git/shuque/stock/futu_algo/main_backend.py", line 114, in init_backtesting
stock_list = YahooFinanceInterface.get_top_30_hsi_constituents()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/lilili/git/shuque/stock/futu_algo/engines/data_engine.py", line 404, in get_top_30_hsi_constituents
payload = pd.read_html(r.text)[0]
^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/pandas/io/html.py", line 1240, in read_html
return _parse(
^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/pandas/io/html.py", line 1003, in _parse
raise retained
File "/opt/miniconda3/lib/python3.12/site-packages/pandas/io/html.py", line 983, in _parse
tables = p.parse_tables()
^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/pandas/io/html.py", line 249, in parse_tables
tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/lib/python3.12/site-packages/pandas/io/html.py", line 598, in _parse_tables
raise ValueError("No tables found")
ValueError: No tables found

Additional context
Add any other context about the problem here.

futu algo error occurred

deployment futu_algo step by step , but when execute , exception occured. how to fix? thanks
(base) /home/xiaoming/anaconda3/bin/python3 main.py
Please rename stock_strategy_map_template.yml to stock_strategy_map.yml and update it.
Traceback (most recent call last):
File "/home/xiaoming/develop/futu_algo/main.py", line 31, in
from engines import *
File "/home/xiaoming/develop/futu_algo/engines/init.py", line 22, in
from .order_engine import *
File "/home/xiaoming/develop/futu_algo/engines/order_engine.py", line 21, in
from futu import ModifyOrderOp, OpenHKTradeContext, OpenQuoteContext, OrderStatus, OrderType, RET_OK,
ImportError: cannot import name 'ModifyOrderOp' from 'futu' (/home/xiaoming/anaconda3/lib/python3.9/site-packages/futu/init.py)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.