订阅期货盘中tick v1版报价资讯,范例如下:
api.quote.subscribe(
api.Contracts.Futures.TXF['TXF202110'], #期货Contract
quote_type = sj.constant.QuoteType.Tick, #报价类型为Tick
version = sj.constant.QuoteVersion.v1, #回传资讯版本为v1
)
# 定义quote_callback,即回传报价资讯时所要执行的动作
@api.on_tick_fop_v1()
def quote_callback(exchange:Exchange, tick:TickFOPv1):
print(f"Exchange: {exchange}, Tick: {tick}")
Event().wait() #盘中执行程序时,若看不到quote_callback的执行结果,请加入此行,让程序进入等待状态
Tick QuoteVersion.v1,quote_callback的执行结果
Exchange: TAIFEX, Tick: Tick(code='TXFJ1', datetime=datetime.datetime(2021, 9, 24, 11, 31, 3, 208000), open=Decimal('17191'), underlying_price=Decimal('17249.79'), bid_side_total_vol=44400, ask_side_total_vol=44529, avg_price=Decimal('17223.595502'), close=Decimal('17234'), high=Decimal('17275'), low=Decimal('17170'), amount=Decimal('34468'), total_amount=Decimal('1208510802'), volume=2, total_volume=70166, tick_type=1, chg_type=2, price_chg=Decimal('154'), pct_chg=Decimal('0.901639'), simtrade=0)
Tick QuoteVersion.v1的报价内容说明
属性 | 值 | 说明 |
---|---|---|
code | 'TXFJ1' | 期货代码 |
datetime | datetime.datetime(2021, 9, 24, 11, 31, 3, 208000) | 时间 |
open | Decimal('17191') | 开盘 |
underlying_price | Decimal('17249.79') | 标的物价格 |
bid_side_total_vol | 44400 | 买盘成交总量 |
ask_side_total_vol | 44529 | 卖盘成交总量 |
avg_price | Decimal('17223.595502') | 均价 |
close | Decimal('17234') | 成交价 |
high | Decimal('17275') | 最高 |
low | Decimal('17170') | 最低 |
amount | Decimal('34468') | 成交金额 |
total_amount | Decimal('1208510802') | 总成交金额 |
volume | 2 | 成交量 |
total_volume | 70166 | 总成交量 |
tick_type | 1 | tick类型 |
chg_type | 2 | 变动类型 |
price_chg | Decimal('154') | 价格变动 |
pct_chg | Decimal('0.901639') | 变动百分比 |
simtrade | '2330' | 是否为试撮 |
订阅期货盘中tick v0版报价资讯,范例如下:
api.quote.subscribe(
api.Contracts.Futures.TXF['TXF202110'], #期货Contract
quote_type = sj.constant.QuoteType.Tick, #报价类型为Tick
version = sj.constant.QuoteVersion.v0, #回传资讯版本为v0
)
# 定义quote_callback,即回传报价资讯时所要执行的动作
@api.quote.on_quote
def quote_callback(topic: str, quote: dict):
print(f"Topic: {topic}, Quote: {quote}")
Event().wait()
Tick QuoteVersion.v0,quote_callback的执行结果
L/TFE/TXFJ1 {'Amount': [17233.0], 'AmountSum': [1213025639.0], 'AvgPrice': [17223.62752], 'Close': [17233.0], 'Code': 'TXFJ1', 'Date': '2021/09/24', 'DiffPrice': [153.0], 'DiffRate': [0.895785], 'DiffType': [2], 'High': [17275.0], 'Low': [17170.0], 'Open': 17191.0, 'TargetKindPrice': 17244.35, 'TickType': [0], 'Time': '11:34:06.678000', 'TradeAskVolSum': 44684, 'TradeBidVolSum': 44596, 'VolSum': [70428], 'Volume': [1]}
L/TFE/TXFJ1 {'Amount': [17234.0], 'AmountSum': [1213042873.0], 'AvgPrice': [17223.627668], 'Close': [17234.0], 'Code': 'TXFJ1', 'Date': '2021/09/24', 'DiffPrice': [154.0], 'DiffRate': [0.901639], 'DiffType': [2],
'High': [17275.0], 'Low': [17170.0], 'Open': 17191.0, 'TargetKindPrice': 17244.35, 'TickType': [1], 'Time': '11:34:09.279000', 'TradeAskVolSum': 44685, 'TradeBidVolSum': 44598, 'VolSum': [70429], 'Volume': [1]}
Tick QuoteVersion.v0的报价内容说明
属性 | 值 | 说明 |
---|---|---|
Amount | [17233.0] | 成交金额(注) |
AmountSum | [1213025639.0] | 总成交金额(注) |
AvgPrice | [17223.62752] | 均价 |
Close | [17233.0] | 成交价 |
Code | 'TXFJ1' | 期货代码 |
Date | '2021/09/24' | 日期 |
DiffPrice | [153.0] | 差异价(涨跌) |
DiffRate | [0.895785] | 差异比例 |
DiffType | [2] | 差异类型 |
High | [17275.0] | 最高 |
Low | [17170.0] | 最低 |
Open | 17191.0 | 开盘 |
TargetKindPrice | 17244.35 | 标的物价格 |
TickType | [1] | Tick类型 |
Time | '11:34:09.279000' | 时间 |
TradeAskVolSum | 44685 | 卖盘成交总量 |
TradeBidVolSum | 44598 | 买盘成交总量 |
VolSum | [70429] | 总成交量 |
Volume | [1] | 成交量 |
期货虽然也有成交价格,但跟个股不同的是期货保证金是固定的,以小台指期为例,买进一口小台指期货,不管你的成交价格(点)是多少,保证金都是46,000。所以虽然在回传的报价资讯中也有Amount跟AmountSum,但实际上期货是没有在计算成交金额
订阅期货盘中bidask v1版报价资讯,范例如下:
api.quote.subscribe(
api.Contracts.Futures.TXF['TXF202110'], #期货Contract
quote_type = sj.constant.QuoteType.BidAsk, #报价类型为BidAsk
version = sj.constant.QuoteVersion.v1 #回传资讯版本为v1
)
@api.on_bidask_fop_v1()
def quote_callback(exchange:Exchange, bidask:BidAskFOPv1):
print(f"Exchange: {exchange}, BidAsk: {bidask}")
Event().wait()
BidAsk QuoteVersion.v1,quote_callback的执行结果
Exchange: TAIFEX, BidAsk: BidAsk(code='TXFJ1', datetime=datetime.datetime(2021, 9, 24, 11, 37, 20, 698000), bid_total_vol=109, ask_total_vol=90, bid_price=[Decimal('17232'), Decimal('17231'), Decimal('17230'), Decimal('17229'), Decimal('17228')], bid_volume=[14, 19, 17, 26, 33], diff_bid_vol=[-1, 0, 0, 0, 0], ask_price=[Decimal('17234'), Decimal('17235'), Decimal('17236'), Decimal('17237'), Decimal('17238')], ask_volume=[3, 15, 16, 20, 36], diff_ask_vol=[2, 0, 0, 0, 1], first_derived_bid_price=Decimal('17230'), first_derived_ask_price=Decimal('17237'), first_derived_bid_vol=5, first_derived_ask_vol=1, underlying_price=Decimal('17243.26'), simtrade=0)
BidAsk QuoteVersion.v1的报价内容说明
属性 | 值 | 说明 |
---|---|---|
code | 'TXFJ1' | 期货代码 |
datetime | datetime.datetime(2021, 9, 24, 11, 37, 20, 698000) | 时间 |
bid_total_vol | 109 | 委买总量 |
ask_total_vol | 90 | 委卖总量 |
bid_price | [Decimal('17232'), Decimal('17231'), Decimal('17230'), Decimal('17229'), Decimal('17228')] | 委买价 |
bid_volume | [14, 19, 17, 26, 33] | 委买量 |
diff_bid_vol | [-1, 0, 0, 0, 0] | 委买量差异 |
ask_price | [Decimal('17234'), Decimal('17235'), Decimal('17236'), Decimal('17237'), Decimal('17238')] | 委卖价 |
ask_volume | [3, 15, 16, 20, 36] | 委卖量 |
diff_ask_vol | [2, 0, 0, 0, 1] | 委卖量差异 |
first_derived_bid_price | Decimal('17230') | 衍生一档买价 |
first_derived_ask_price | Decimal('17237') | 衍生一档卖价 |
first_derived_bid_vol | 5 | 衍生一档买量 |
first_derived_ask_vol | 1 | 衍生一档卖量 |
underlying_price | Decimal('17243.26') | 标的物价格 |
simtrade | 0 | 是否为试撮 |
订阅期货盘中bidask v0版报价资讯,范例如下:
api.quote.subscribe(
api.Contracts.Futures.TXF['TXF202110'], #期货Contract
quote_type = sj.constant.QuoteType.BidAsk, #报价类型为BidAsk
version = sj.constant.QuoteVersion.v0 #回传资讯版本为v0
)
@api.quote.on_quote
def quote_callback(topic: str, quote: dict):
print(f"Topic: {topic}, Quote: {quote}")
Event().wait()
BidAsk QuoteVersion.v1,quote_callback的执行结果
Topic: Q/TFE/TXFJ1, Quote: {'AskPrice': [17229.0, 17230.0, 17231.0, 17232.0, 17233.0], 'AskVolSum': 64, 'AskVolume': [2, 15, 17, 14, 16], 'BidPrice': [17228.0, 17227.0, 17226.0, 17225.0, 17224.0], 'BidVolSum': 106, 'BidVolume': [3, 18, 20, 37, 28], 'Code': 'TXFJ1', 'Date': '2021/09/24', 'DiffAskVol': [-4, -1, 0, 0, 0], 'DiffAskVolSum': 0, 'DiffBidVol': [-2, 4, 0, 0, 0], 'DiffBidVolSum': 0, 'FirstDerivedAskPrice': 17231.0,
'FirstDerivedAskVolume': 1, 'FirstDerivedBidPrice': 17225.0, 'FirstDerivedBidVolume': 1, 'TargetKindPrice': 17244.94, 'Time': '11:40:26.948000'}
BidAsk QuoteVersion.v0的报价内容说明
属性 | 值 | 说明 |
---|---|---|
AskPrice | [17229.0, 17230.0, 17231.0, 17232.0, 17233.0] | 委卖价 |
AskVolSum | 64 | 委卖总量 |
AskVolume | [2, 15, 17, 14, 16] | 委卖量 |
BidPrice | [17228.0, 17227.0, 17226.0, 17225.0, 17224.0] | 委买价 |
BidVolSum | 106 | 委买总量 |
BidVolume | [3, 18, 20, 37, 28] | 委买量 |
Code | 'TXFJ1' | 期货代码 |
Date | '2021/09/24' | 日期 |
DiffAskVol | [-4, -1, 0, 0, 0] | 委卖量差异 |
DiffAskVolSum | 0 | 委卖量差异? |
DiffBidVol | [-2, 4, 0, 0, 0] | 委卖量差异 |
DiffBidVolSum | 0 | 委卖量差异? |
FirstDerivedAskPrice | 17231.0 | 衍生一档卖价 |
FirstDerivedAskVolume | 1 | 衍生一档卖量 |
FirstDerivedBidPrice | 17225.0 | 衍生一档买价 |
FirstDerivedBidVolume | 1 | 衍生一档买量 |
TargetKindPrice | 17244.94 | 标的物价格 |
Time | '11:40:26.948000' | 时间 |
所谓的「衍生一档」,也就是一般俗称ROLL单或是转仓单
详细委托及成交机制,请参考期交所文件
http://www.taifex.com.tw/chinese/9/期货商品跨月价差委托机制说明.ppt
>>: Day12|【Git】档案管理 - 忽略档案 .gitignore
今天要来带大家看看TypeScript(TS)的类别(Class)继承(Inheritance)范例...
Use Case 定义对外唯一的 method call 利用 dry-monads 的特性处理预期...
First Flutter App 看完上一篇大家对Flutter的架构应该都有初步的了解了。今天我...
...
今年的疫情蛮严重的,希望大家都过得安好,希望疫情快点过去,能回到一些线下技术聚会的时光~ 今天要接触...