Skip to main content

Indices

接收訂閱股票最新指數行情資料

Example

Subscribe channel

from fugle_marketdata import WebSocketClient

def handle_message(message):
print(message)

def main():
client = WebSocketClient(api_key='YOUR_API_KEY')
stock = client.stock
stock.on('message', handle_message)
stock.connect()
stock.subscribe({
'channel': 'indices',
'symbol': 'IR0001'
})

if __name__ == '__main__':
main()

Receive data

{
"event": "data",
"data": {
"symbol": "IR0001",
"type": "INDEX",
"exchange": "TWSE",
"index": 35276.44,
"time": 1686114510000000
},
"id": "<CHANNEL_ID>",
"channel": "indices"
}