I tried using this code to access Australian stock data, but I received an error stating “No right to get the quote.” After investigating, I discovered that a subscription is required for Australian stock data. The service, called Australian LV2, costs $32 AUD per month, $95 AUD per quarter, and $379 AUD per year—which is quite expensive.
To purchase the subscription, go to Moomoo App → Me → Market Data → Australian LV2.
class a:
pass
A = a()
A.port = 11113
A.stockAU = 'AU.BHP'
A.stockUS = 'US.TSLA'
A.stockHK = 'HK.00700'
from moomoo import *
quote_ctx = OpenQuoteContext(host='127.0.0.1', port=A.port)
quote_ctx.subscribe([A.stockUS], [SubType.QUOTE])
ret, data = quote_ctx.query_subscription()
if ret == RET_OK:
print(data)
else:
print('error:', data)
ret, data = quote_ctx.get_market_snapshot([A.stockUS])
if ret == RET_OK:
print(data)
print(data['code'][0]) # Take the first stock code
print(data['code'].values.tolist()) # Convert to list
else:
print('error:', data)
quote_ctx.close() # After using the connection, remember to close it to prevent the number of connections from running out
我尝试使用这段代码访问澳大利亚股市数据,但收到错误提示:“No right to get the quote.”(无权限获取报价)。经过调查,我发现需要订阅澳大利亚股市数据。该服务名为 Australian LV2,费用为 每月 32 AUD,每季度 95 AUD,每年 379 AUD,价格较高。
要购买订阅,请进入 Moomoo App → 我的 → 行情数据 → Australian LV2。