billpwchan / futu_algo

Futu Algorithmic Trading Solution (Python) 基於富途OpenAPI所開發量化交易程序
Apache License 2.0
377 stars 130 forks source link

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

Open munum opened 1 year ago

munum commented 1 year ago

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.

github-actions[bot] commented 1 year ago

Hello @munum , thank you for submitting an issue! 👍 We highly appreciate it if you work on it as well.

billpwchan commented 1 year ago

Hmm from the error message, I think there may be an issue with the stock code you've provided.

If you want to subscribe HK.00001, need to input "HK.00001" instead of "00001" only, cuz this error message may be thrown either if you are illegible to subscribe (e.g., used up all the subscription quota) or providing an illegal stock code.

Let me know if you have any issue after changing the stock code. Thanks for using FutuAlgo!

munum commented 1 year ago

I've been working on this issue for a while now. I can confirm that "HK.00001" is the input. Is it essential to have LV2 for it to behave correctly? Is BMP adequate?

ireneyu9898 commented 1 year ago

No, BMP level subscription is sufficient to do paper trading, historical data download (with limited quota) and other functions like stock filtering.

This error code was thrown by Futu library, and I suspect it is because of incorrect stock code was provided so they cannot download/subscribe any data of this ticker. On 25 Mar 2023 at 00:43 +0800, Michael @.***>, wrote:

I've been working on this issue for a while now. Is it essential to have LV2 for it to behave correctly? Is BMP adequate? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

munum commented 1 year ago

But doesn't place_buy_order() need more than BMP level even when paper trading? place_buy_order calls get_ask_and_bid, which calls quote_ctx.get_order_book. quote_ctx.get_order_book needs the stock to be subscribed first:

> self.trading_util.get_ask_and_bid("HK.00700")
2023-03-28 11:43:46,253 — trading_util — INFO — Get order book failed: No right to get this quote

No, BMP level subscription is sufficient to do paper trading, historical data download (with limited quota) and other functions like stock filtering. This error code was thrown by Futu library, and I suspect it is because of incorrect stock code was provided so they cannot download/subscribe any data of this ticker.