-
-
Save shihyu/307eb7587b44f197d132586cfc1b0399 to your computer and use it in GitHub Desktop.
成交+委買賣顯示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quote_callback(topic, data): | |
""" | |
# L/TFE/TXFF9 | |
{'Amount': [21088.0], 'AmountSum': [1028165646.0], 'AvgPrice': [10562.513699263414], | |
'Close': [10544.0], 'Code': 'TXFF9', 'Date': '2019/05/16', 'DiffPrice': [-37.0], | |
'DiffRate': [-0.34968339476419996], 'DiffType': [4], 'High': [10574.0], | |
'Low': [10488.0], 'Open': 10537.0, 'TargetKindPrice': 10548.47, 'TickType': [2], | |
'Time': '11:15:11.911000', 'TradeAskVolSum': 52599, 'TradeBidVolSum': 53721, | |
'VolSum': [97341], 'Volume': [2]} | |
# Q/TFE/TXFF9 | |
{'AskPrice': [10545.0, 10546.0, 10547.0, 10548.0, 10549.0], 'AskVolSum': 262, | |
'AskVolume': [17, 99, 59, 45, 42], 'BidPrice': [10544.0, 10543.0, 10542.0, 10541.0, 10540.0], | |
'BidVolSum': 289, 'BidVolume': [16, 41, 32, 123, 77], 'Code': 'TXFF9', 'Date': '2019/05/16', | |
'DiffAskVol': [0, 0, 0, -1, 0], 'DiffAskVolSum': -1, 'DiffBidVol': [0, 0, 0, 0, 0], 'DiffBidVolSum': 0, | |
'FirstDerivedAskPrice': 10547.0, 'FirstDerivedAskVolume': 1, 'FirstDerivedBidPrice': 10542.0, | |
'FirstDerivedBidVolume': 1, 'TargetKindPrice': 10548.47, 'Time': '11:15:11.911000'} | |
#MKT/idcdmzpcr01/TSE/2330 | |
{'Close': [248.0], 'Time': '09:53:00.706928','VolSum': [7023], 'Volume': [1]} | |
# QUT/idcdmzpcr01/TSE/2330 | |
{'AskPrice': [248.0, 248.5, 249.0, 249.5, 250.0], 'AskVolume': [355, 632, 630, 301, 429], | |
'BidPrice': [247.5, 247.0, 246.5, 246.0, 245.5], 'BidVolume': [397, 389, 509, 703, 434], | |
'Date': '2019/05/17', 'Time': '09:53:00.706928'} | |
""" | |
topics = topic.split("/") | |
realtime_type = topics[0] | |
if realtime_type == "L": #期貨-成交 | |
print(data['Close'][0]) #欄位請參照上面註解的內容 L 取得 | |
elif realtime_type == "Q": #期貨-委買賣 | |
#以下分別顯示委買賣五檔的 **委買價格,委買數量,委賣價格,委賣數量** | |
print( data["BidPrice"][0],data["BidPrice"][1],data["BidPrice"][2],data["BidPrice"][3],data["BidPrice"][4]) | |
print( data["BidVolume"][0],data["BidVolume"][1],data["BidVolume"][2],data["BidVolume"][3],data["BidVolume"][4]) | |
print( data["AskPrice"][0],data["AskPrice"][1],data["AskPrice"][2],data["AskPrice"][3],data["AskPrice"][4]) | |
print( data["AskVolume"][0],data["AskVolume"][1],data["AskVolume"][2],data["AskVolume"][3],data["AskVolume"][4]) | |
elif realtime_type == "MKT": #現貨 成交 | |
print(data['Close'][0]) #欄位請參照上面註解的內容 MKT取得 | |
elif realtime_type == "QUT": #現貨 委買賣 | |
#以下分別顯示委買賣五檔的 **委買價格,委買數量,委賣價格,委賣數量** | |
print( data["BidPrice"][0],data["BidPrice"][1],data["BidPrice"][2],data["BidPrice"][3],data["BidPrice"][4]) | |
print( data["BidVolume"][0],data["BidVolume"][1],data["BidVolume"][2],data["BidVolume"][3],data["BidVolume"][4]) | |
print( data["AskPrice"][0],data["AskPrice"][1],data["AskPrice"][2],data["AskPrice"][3],data["AskPrice"][4]) | |
print( data["AskVolume"][0],data["AskVolume"][1],data["AskVolume"][2],data["AskVolume"][3],data["AskVolume"][4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment