Symbol
做為參數,因此還需要透過 Tickers
取得不同商品的中文名稱和 Symbol。>>> qm.get_ticker(session='AFTERHOURS')
{'type': 'FUTURE', 'exchange': 'TAIFEX', 'session': 'AFTERHOURS', 'product': 'MXF', 'contractType': 'I', 'data': [{'symbol': 'MXFC5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-03-19', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指035', 'referencePrice': 22353, 'settlementDate': '2025-03-19', 'startDate': '2024-03-21'}, {'symbol': 'MXFF5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-06-18', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指065', 'referencePrice': 22359, 'settlementDate': '2025-06-18', 'startDate': '2024-06-20'}, {'symbol': 'MXFI5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-09-17', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指095', 'referencePrice': 22104, 'settlementDate': '2025-09-17', 'startDate': '2024-09-19'}, {'symbol': 'MXFJ4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-10-16', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指104', 'referencePrice': 22338, 'settlementDate': '2024-10-16', 'startDate': '2024-07-18'}, {'symbol': 'MXFK4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-11-20', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指114', 'referencePrice': 22351, 'settlementDate': '2024-11-20', 'startDate': '2024-08-22'}, {'symbol': 'MXFL4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-12-18', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指124', 'referencePrice': 22360, 'settlementDate': '2024-12-18', 'startDate': '2023-12-21'}]}
>>> tks = qm.get_ticker(session='AFTERHOURS')
>>> for tk in tks['data']:
>>> print(tk)
{'symbol': 'MXFC5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-03-19', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指035', 'referencePrice': 22353, 'settlementDate': '2025-03-19', 'startDate': '2024-03-21'}
{'symbol': 'MXFF5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-06-18', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指065', 'referencePrice': 22359, 'settlementDate': '2025-06-18', 'startDate': '2024-06-20'}
{'symbol': 'MXFI5', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2025-09-17', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指095', 'referencePrice': 22104, 'settlementDate': '2025-09-17', 'startDate': '2024-09-19'}
{'symbol': 'MXFJ4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-10-16', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指104', 'referencePrice': 22338, 'settlementDate': '2024-10-16', 'startDate': '2024-07-18'}
{'symbol': 'MXFK4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-11-20', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指114', 'referencePrice': 22351, 'settlementDate': '2024-11-20', 'startDate': '2024-08-22'}
{'symbol': 'MXFL4', 'type': 'FUTURE_AH', 'contractType': 'I', 'endDate': '2024-12-18', 'flowGroup': 10, 'isDynamicBanding': True, 'name': '小型臺指124', 'referencePrice': 22360, 'settlementDate': '2024-12-18', 'startDate': '2023-12-21'}
symbol
名稱、一個中文名稱 name
以及最重要的結算日期 endDate
和settlementDate
,接下來是我們要從結算日來確認 symbol。7
, 14
, 21
號。6
, 13
, 20
號。5
, 12
, 19
號。4
, 11
, 18
號。3
, 10
, 17
號。2
, 9
, 16
號。1
, 8
, 15
號。15
~ 21
之間; 遇到颱風或放假,則會順延至下一個開盤日。21 + (該月一號時遇到星期三還有幾天) - 6
weekday()
函數,用來看是星期幾的功能,如果是 0 則表示星期一。21-(dt.date(y,m,1).weekday()+4)%7
即可得到第三個星期三是幾號...>>> from quote.mtxmonitor import MTXMonitor
>>> mm = MTXMonitor()
>>> mm.run()
{"event":"subscribed","data":{"id":"xxxxx","channel":"trades","symbol":"MXFJ4","afterHours":true}}
{"event":"snapshot","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22649,"size":1,"bid":22649,"ask":22651}],"total":{"tradeVolume":98779,"totalBidMatch":73370,"totalAskMatch":72853},"time":1727188412566000,"serial":123022},"id":"xxxxx","channel":"trades"}
{"event":"data","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22649,"size":1,"bid":22649,"ask":22650}],"total":{"tradeVolume":98780,"totalBidMatch":73371,"totalAskMatch":72854},"time":1727188415724000,"serial":123026},"id":"xxxxx","channel":"trades"}
{"event":"data","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22650,"size":1,"bid":22648,"ask":22650}],"total":{"tradeVolume":98781,"totalBidMatch":73372,"totalAskMatch":72855},"time":1727188415806000,"serial":123028},"id":"xxxxx","channel":"trades"}
{"event":"data","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22649,"size":1,"bid":22648,"ask":22649}],"total":{"tradeVolume":98782,"totalBidMatch":73373,"totalAskMatch":72856},"time":1727188416143000,"serial":123029},"id":"xxxxx","channel":"trades"}
{"event":"data","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22651,"size":1,"bid":22648,"ask":22651}],"total":{"tradeVolume":98783,"totalBidMatch":73374,"totalAskMatch":72857},"time":1727188416247000,"serial":123030},"id":"xxxxx","channel":"trades"}
{"event":"data","data":{"symbol":"MXFJ4","type":"FUTURE_AH","exchange":"TAIFEX","trades":[{"price":22650,"size":1,"bid":22650,"ask":22651}],"total":{"tradeVolume":98784,"totalBidMatch":73375,"totalAskMatch":72858},"time":1727188417120000,"serial":123033},"id":"xxxxx","channel":"trades"}
09/15 (週日休市)
09/16 中石化 +352
09/16 新復興 +4,946
09/17 (中秋節休市)
09/18 彩晶 -87
09/18 華星光 +1,079
09/18 名軒 +142
09/19 (掛單未成交)
09/20 ~ 09/23 選擇權交易:+ 16,459
09/23 ~ 09/24 選擇權梭哈中,尚未結單...
資產: 32,791 -> 可能要被歸零了QQ