资源加载中... loading...

港股多品种对冲策略(2)

Author: 扫地僧, Created: 2021-09-30 19:06:40, Updated: 2024-06-13 14:17:53

img

一、摘要

在上一个章节中,我们从市场的角度出发,详细阐述了交易市场的三大风险,以及如何对冲掉市场贝塔(β)风险,最后通过列举国内A股市场历年牛股,来对比个股与指数对冲、个股与个股对冲的优缺点,通过贵州茅台和五粮液为例,探讨个股与个股之间对冲的可行性策略方案。那么本章节我们将以优宽量化交易平台(youquant.com)来实现这个交易策略。

二、策略逻辑

本质上我们是要对冲掉市场固有的风险,通过龙头股与一般股票或者龙头股与垃圾股等组合,赚取个股本身的利润。所以我们需要从个股技术面价格走势和基本面分析中,判断一个行业究竟哪一个是龙头股,哪一个是一般股票或者垃圾股。

技术面龙头股特点 1、龙头股多出现于涨停股中,除了超级大盘股之外,龙头股的第一个特性是涨停。并且涨停多半是在开盘后不久就涨停,这是因为主力意见趋同没有分歧,或者蓄势已久涨停一触即发。相反如果是磨磨蹭蹭到尾盘才涨停,通常是被动涨停,这种并不是龙头股。

2、龙头股的第二个特性是走势流利,一种是高开高走,主力收集完筹码后,迅速封涨停,吸引散户营造热点,好让别人给自己抬轿,所以根本不会给散户上车的机会。另一种是跳空高开低走,在拉升之前通过洗盘,将跟风获利盘洗出去。

3、第三个特性是龙头股与大盘或者垃圾股走势通常不一致,龙头股通常基本面良好业绩优秀,市场认同度高,所以会出现大盘或者垃圾股小涨,龙头股大涨,大盘或者垃圾股下跌,龙头股小跌或者不跌。

基本面龙头股特点 1、龙头股拥有政策和市场的支持,国家政策支持的行业在市场中能得到更多的认可和支持。比如最近国家支持的新能源汽车行业、风电和光伏发电行业等等。

2、可以从公司基本情况分析、业务分析、财务分析中窥探出龙头股的蛛丝马迹,比如:应收账款说明商品销售之后没有回款,这说明企业低位下降,反之龙头企业很多是在商品销售之前就收到预收账款;净资产比率反映了企业资金实力和偿债安全性,很多优秀的龙头企业的净资产比率是负的;还有诸如其他:毛利率、净利率、净资产收益率等等…

3、龙头股具有持续的市场人气,龙头股一般都有机构资金持续入市,持续强劲走势,对整个市场有虹吸效应,形成强者恒强的局面。此外龙头股在技术形态上非常完美,能吸引游资和散户都能参与其中。

三、策略分析

# 创建 FMZ 本地回测环境
from fmz import *
task = VCtx('''backtest
start: 2021-09-28 00:00:00
end: 2021-09-29 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_XTP","currency":"STOCK","minFee":0}]
''')
# 订阅港股李宁数据
infoA = exchange.SetContractType("02331.HK")
print(infoA)
{'ExchangeID': 'HK', 'ExchangeInstID': '02331.HK', 'InstrumentID': '02331.HK', 'InstrumentName': '李宁', 'LongMarginRatio': 1, 'MaxLimitOrderVolume': 10000, 'MinBuyVolume': 1, 'OpenDate': '', 'PriceTick': 0.05, 'ShortMarginRatio': 1, 'VolumeMultiple': 500}
# 港股李宁K线
barsA = exchange.GetRecords()
print(barsA)
[{'Time': 1596643200000, 'Open': 27.8, 'High': 27.8, 'Low': 27.8, 'Close': 27.8, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1596729600000, 'Open': 28.2, 'High': 28.2, 'Low': 26.6, 'Close': 27.2, 'Volume': 12410625.9999, 'OpenInterest': 0.0}, {'Time': 1596816000000, 'Open': 26.55, 'High': 27.5, 'Low': 26.55, 'Close': 27.25, 'Volume': 8165100.9999, 'OpenInterest': 0.0}, {'Time': 1596988800000, 'Open': 28.0, 'High': 28.0, 'Low': 26.7, 'Close': 26.8, 'Volume': 4547639.0, 'OpenInterest': 0.0}, {'Time': 1597075200000, 'Open': 27.3, 'High': 27.3, 'Low': 27.3, 'Close': 27.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597161600000, 'Open': 26.95, 'High': 30.0, 'Low': 26.95, 'Close': 28.85, 'Volume': 48237055.0, 'OpenInterest': 0.0}, {'Time': 1597248000000, 'Open': 29.5, 'High': 29.5, 'Low': 29.5, 'Close': 29.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597334400000, 'Open': 29.55, 'High': 31.0, 'Low': 28.45, 'Close': 31.0, 'Volume': 11159052.9999, 'OpenInterest': 0.0}, {'Time': 1597420800000, 'Open': 29.9, 'High': 32.3, 'Low': 29.9, 'Close': 31.55, 'Volume': 38387556.0, 'OpenInterest': 0.0}, {'Time': 1597593600000, 'Open': 32.0, 'High': 32.0, 'Low': 32.0, 'Close': 32.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597680000000, 'Open': 31.5, 'High': 32.8, 'Low': 31.35, 'Close': 32.0, 'Volume': 35849039.9997, 'OpenInterest': 0.0}, {'Time': 1597766400000, 'Open': 32.3, 'High': 32.3, 'Low': 31.55, 'Close': 31.75, 'Volume': 8045301.0, 'OpenInterest': 0.0}, {'Time': 1597852800000, 'Open': 32.15, 'High': 32.15, 'Low': 31.2, 'Close': 31.75, 'Volume': 6493556.0, 'OpenInterest': 0.0}, {'Time': 1597939200000, 'Open': 31.85, 'High': 31.85, 'Low': 31.85, 'Close': 31.85, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1598025600000, 'Open': 31.5, 'High': 32.5, 'Low': 31.5, 'Close': 32.2, 'Volume': 16767156.0, 'OpenInterest': 0.0}, {'Time': 1598198400000, 'Open': 32.5, 'High': 34.2, 'Low': 32.35, 'Close': 34.2, 'Volume': 16354943.0, 'OpenInterest': 0.0}, {'Time': 1598284800000, 'Open': 34.35, 'High': 34.35, 'Low': 34.35, 'Close': 34.35, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1598371200000, 'Open': 33.15, 'High': 34.6, 'Low': 33.15, 'Close': 34.0, 'Volume': 12666025.9999, 'OpenInterest': 0.0}, {'Time': 1598457600000, 'Open': 33.4, 'High': 34.5, 'Low': 33.4, 'Close': 34.25, 'Volume': 16772577.0, 'OpenInterest': 0.0}, {'Time': 1598544000000, 'Open': 34.35, 'High': 34.75, 'Low': 33.6, 'Close': 34.75, 'Volume': 6795582.0, 'OpenInterest': 0.0}, {'Time': 1598630400000, 'Open': 34.8, 'High': 34.8, 'Low': 33.45, 'Close': 34.45, 'Volume': 9775945.9999, 'OpenInterest': 0.0}, {'Time': 1598803200000, 'Open': 34.4, 'High': 34.4, 'Low': 34.4, 'Close': 34.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1598889600000, 'Open': 34.45, 'High': 34.45, 'Low': 32.4, 'Close': 32.8, 'Volume': 13367707.9999, 'OpenInterest': 0.0}, {'Time': 1598976000000, 'Open': 32.4, 'High': 33.45, 'Low': 32.4, 'Close': 33.45, 'Volume': 12835194.9999, 'OpenInterest': 0.0}, {'Time': 1599062400000, 'Open': 33.1, 'High': 33.95, 'Low': 33.1, 'Close': 33.4, 'Volume': 13732190.9999, 'OpenInterest': 0.0}, {'Time': 1599148800000, 'Open': 31.9, 'High': 31.9, 'Low': 31.9, 'Close': 31.9, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1599235200000, 'Open': 31.75, 'High': 32.95, 'Low': 31.75, 'Close': 32.75, 'Volume': 9880642.9999, 'OpenInterest': 0.0}, {'Time': 1599408000000, 'Open': 32.15, 'High': 34.35, 'Low': 32.15, 'Close': 32.5, 'Volume': 11703318.0, 'OpenInterest': 0.0}, {'Time': 1599494400000, 'Open': 32.7, 'High': 32.7, 'Low': 32.7, 'Close': 32.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1599580800000, 'Open': 33.1, 'High': 33.1, 'Low': 30.6, 'Close': 31.05, 'Volume': 11888287.9999, 'OpenInterest': 0.0}, {'Time': 1599667200000, 'Open': 30.7, 'High': 32.1, 'Low': 30.7, 'Close': 32.1, 'Volume': 10885131.9999, 'OpenInterest': 0.0}, {'Time': 1599753600000, 'Open': 32.8, 'High': 32.8, 'Low': 31.55, 'Close': 32.05, 'Volume': 9239388.0, 'OpenInterest': 0.0}, {'Time': 1599840000000, 'Open': 31.45, 'High': 33.2, 'Low': 31.45, 'Close': 32.75, 'Volume': 4576875.9999, 'OpenInterest': 0.0}, {'Time': 1600012800000, 'Open': 32.75, 'High': 33.85, 'Low': 32.75, 'Close': 33.25, 'Volume': 4054642.0, 'OpenInterest': 0.0}, {'Time': 1600099200000, 'Open': 33.3, 'High': 33.3, 'Low': 33.3, 'Close': 33.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600185600000, 'Open': 32.8, 'High': 35.0, 'Low': 32.8, 'Close': 35.0, 'Volume': 8097523.9999, 'OpenInterest': 0.0}, {'Time': 1600272000000, 'Open': 35.6, 'High': 35.6, 'Low': 34.15, 'Close': 34.55, 'Volume': 9963966.0, 'OpenInterest': 0.0}, {'Time': 1600358400000, 'Open': 33.95, 'High': 35.25, 'Low': 33.95, 'Close': 35.0, 'Volume': 7211238.0, 'OpenInterest': 0.0}, {'Time': 1600444800000, 'Open': 34.6, 'High': 37.8, 'Low': 34.6, 'Close': 37.05, 'Volume': 21575313.9998, 'OpenInterest': 0.0}, {'Time': 1600617600000, 'Open': 37.0, 'High': 37.0, 'Low': 37.0, 'Close': 37.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600704000000, 'Open': 37.7, 'High': 37.7, 'Low': 34.85, 'Close': 35.25, 'Volume': 13489663.9999, 'OpenInterest': 0.0}, {'Time': 1600790400000, 'Open': 35.75, 'High': 35.75, 'Low': 34.0, 'Close': 34.9, 'Volume': 9903828.9999, 'OpenInterest': 0.0}, {'Time': 1600876800000, 'Open': 34.8, 'High': 36.15, 'Low': 34.8, 'Close': 35.1, 'Volume': 18631317.9998, 'OpenInterest': 0.0}, {'Time': 1600963200000, 'Open': 35.95, 'High': 35.95, 'Low': 34.55, 'Close': 34.9, 'Volume': 6366949.9999, 'OpenInterest': 0.0}, {'Time': 1601049600000, 'Open': 35.3, 'High': 35.3, 'Low': 34.5, 'Close': 34.85, 'Volume': 7024819.9999, 'OpenInterest': 0.0}, {'Time': 1601222400000, 'Open': 34.7, 'High': 34.7, 'Low': 34.7, 'Close': 34.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1601308800000, 'Open': 35.25, 'High': 35.25, 'Low': 34.3, 'Close': 35.2, 'Volume': 4787607.9999, 'OpenInterest': 0.0}, {'Time': 1601395200000, 'Open': 34.95, 'High': 36.5, 'Low': 34.95, 'Close': 36.0, 'Volume': 12917513.0, 'OpenInterest': 0.0}, {'Time': 1601827200000, 'Open': 36.25, 'High': 38.75, 'Low': 35.85, 'Close': 38.75, 'Volume': 12853599.0, 'OpenInterest': 0.0}, {'Time': 1601913600000, 'Open': 39.25, 'High': 39.25, 'Low': 39.25, 'Close': 39.25, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1602000000000, 'Open': 39.35, 'High': 39.35, 'Low': 37.3, 'Close': 37.3, 'Volume': 9852036.9999, 'OpenInterest': 0.0}, {'Time': 1602086400000, 'Open': 37.1, 'High': 38.4, 'Low': 37.1, 'Close': 37.5, 'Volume': 7971372.9999, 'OpenInterest': 0.0}, {'Time': 1602172800000, 'Open': 37.15, 'High': 38.55, 'Low': 37.15, 'Close': 38.5, 'Volume': 5405556.0, 'OpenInterest': 0.0}, {'Time': 1602259200000, 'Open': 38.8, 'High': 38.8, 'Low': 37.6, 'Close': 37.75, 'Volume': 8545458.9999, 'OpenInterest': 0.0}, {'Time': 1602432000000, 'Open': 37.7, 'High': 37.7, 'Low': 37.7, 'Close': 37.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1602518400000, 'Open': 37.55, 'High': 39.55, 'Low': 37.55, 'Close': 39.45, 'Volume': 9833125.9999, 'OpenInterest': 0.0}, {'Time': 1602604800000, 'Open': 39.3, 'High': 39.3, 'Low': 39.3, 'Close': 39.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1602691200000, 'Open': 39.5, 'High': 39.5, 'Low': 37.95, 'Close': 38.05, 'Volume': 13144110.9999, 'OpenInterest': 0.0}, {'Time': 1602777600000, 'Open': 38.35, 'High': 38.35, 'Low': 37.3, 'Close': 38.0, 'Volume': 6771769.9999, 'OpenInterest': 0.0}, {'Time': 1602864000000, 'Open': 37.8, 'High': 39.35, 'Low': 37.8, 'Close': 38.9, 'Volume': 7829899.9999, 'OpenInterest': 0.0}, {'Time': 1603036800000, 'Open': 38.5, 'High': 38.5, 'Low': 38.5, 'Close': 38.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1603123200000, 'Open': 38.9, 'High': 38.9, 'Low': 37.85, 'Close': 38.4, 'Volume': 6927588.0, 'OpenInterest': 0.0}, {'Time': 1603209600000, 'Open': 38.35, 'High': 42.6, 'Low': 38.35, 'Close': 42.6, 'Volume': 24351081.9998, 'OpenInterest': 0.0}, {'Time': 1603296000000, 'Open': 42.0, 'High': 42.0, 'Low': 42.0, 'Close': 42.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1603382400000, 'Open': 42.3, 'High': 42.3, 'Low': 38.6, 'Close': 39.75, 'Volume': 30254842.0, 'OpenInterest': 0.0}, {'Time': 1603728000000, 'Open': 39.15, 'High': 39.15, 'Low': 39.15, 'Close': 39.15, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1603814400000, 'Open': 38.55, 'High': 40.55, 'Low': 38.55, 'Close': 40.1, 'Volume': 20025813.9998, 'OpenInterest': 0.0}, {'Time': 1603900800000, 'Open': 39.15, 'High': 41.4, 'Low': 39.15, 'Close': 40.0, 'Volume': 10692087.0, 'OpenInterest': 0.0}, {'Time': 1603987200000, 'Open': 39.25, 'High': 41.2, 'Low': 39.25, 'Close': 40.7, 'Volume': 5200704.0, 'OpenInterest': 0.0}, {'Time': 1604073600000, 'Open': 40.8, 'High': 40.8, 'Low': 39.65, 'Close': 40.0, 'Volume': 5517303.9999, 'OpenInterest': 0.0}, {'Time': 1604246400000, 'Open': 40.5, 'High': 40.5, 'Low': 40.5, 'Close': 40.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1604332800000, 'Open': 40.1, 'High': 41.2, 'Low': 40.1, 'Close': 40.75, 'Volume': 3252906.9999, 'OpenInterest': 0.0}, {'Time': 1604419200000, 'Open': 41.2, 'High': 41.2, 'Low': 40.15, 'Close': 40.5, 'Volume': 9344682.0, 'OpenInterest': 0.0}, {'Time': 1604505600000, 'Open': 40.05, 'High': 42.8, 'Low': 40.05, 'Close': 42.8, 'Volume': 4995178.9999, 'OpenInterest': 0.0}, {'Time': 1604592000000, 'Open': 42.2, 'High': 44.95, 'Low': 42.2, 'Close': 44.95, 'Volume': 7113132.9999, 'OpenInterest': 0.0}, {'Time': 1604678400000, 'Open': 43.8, 'High': 45.3, 'Low': 43.8, 'Close': 45.05, 'Volume': 10024089.0, 'OpenInterest': 0.0}, {'Time': 1604851200000, 'Open': 45.75, 'High': 45.75, 'Low': 45.75, 'Close': 45.75, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1604937600000, 'Open': 46.5, 'High': 47.0, 'Low': 44.5, 'Close': 47.0, 'Volume': 9536640.9999, 'OpenInterest': 0.0}, {'Time': 1605024000000, 'Open': 47.5, 'High': 47.5, 'Low': 43.85, 'Close': 44.8, 'Volume': 11119147.9999, 'OpenInterest': 0.0}, {'Time': 1605110400000, 'Open': 45.45, 'High': 45.45, 'Low': 39.7, 'Close': 42.45, 'Volume': 32808592.9998, 'OpenInterest': 0.0}, {'Time': 1605196800000, 'Open': 42.75, 'High': 42.75, 'Low': 42.75, 'Close': 42.75, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1605283200000, 'Open': 43.15, 'High': 43.15, 'Low': 41.65, 'Close': 42.4, 'Volume': 7270818.9999, 'OpenInterest': 0.0}, {'Time': 1605456000000, 'Open': 43.2, 'High': 44.4, 'Low': 42.55, 'Close': 44.4, 'Volume': 13041995.0, 'OpenInterest': 0.0}, {'Time': 1605542400000, 'Open': 44.4, 'High': 44.4, 'Low': 44.4, 'Close': 44.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1605628800000, 'Open': 44.95, 'High': 46.5, 'Low': 43.35, 'Close': 45.95, 'Volume': 14926031.0, 'OpenInterest': 0.0}, {'Time': 1605715200000, 'Open': 46.2, 'High': 46.2, 'Low': 46.2, 'Close': 46.2, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1605801600000, 'Open': 45.5, 'High': 47.7, 'Low': 45.5, 'Close': 46.95, 'Volume': 10230550.9999, 'OpenInterest': 0.0}, {'Time': 1605888000000, 'Open': 47.5, 'High': 47.5, 'Low': 45.1, 'Close': 45.75, 'Volume': 15927270.0, 'OpenInterest': 0.0}, {'Time': 1606060800000, 'Open': 46.0, 'High': 46.0, 'Low': 46.0, 'Close': 46.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1606147200000, 'Open': 46.1, 'High': 46.1, 'Low': 44.45, 'Close': 45.55, 'Volume': 7960614.0, 'OpenInterest': 0.0}, {'Time': 1606233600000, 'Open': 45.6, 'High': 45.6, 'Low': 43.6, 'Close': 44.55, 'Volume': 9113731.9999, 'OpenInterest': 0.0}, {'Time': 1606320000000, 'Open': 44.85, 'High': 44.85, 'Low': 41.4, 'Close': 42.65, 'Volume': 14318883.0, 'OpenInterest': 0.0}, {'Time': 1606406400000, 'Open': 42.3, 'High': 43.8, 'Low': 42.3, 'Close': 43.0, 'Volume': 10547572.9999, 'OpenInterest': 0.0}, {'Time': 1606492800000, 'Open': 43.3, 'High': 43.3, 'Low': 42.25, 'Close': 42.95, 'Volume': 7199919.9999, 'OpenInterest': 0.0}, {'Time': 1606665600000, 'Open': 43.0, 'High': 43.0, 'Low': 43.0, 'Close': 43.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1606752000000, 'Open': 43.05, 'High': 43.05, 'Low': 41.6, 'Close': 42.0, 'Volume': 14939703.9999, 'OpenInterest': 0.0}, {'Time': 1606838400000, 'Open': 41.7, 'High': 43.8, 'Low': 41.7, 'Close': 43.6, 'Volume': 6877071.9999, 'OpenInterest': 0.0}, {'Time': 1606924800000, 'Open': 43.7, 'High': 43.7, 'Low': 41.75, 'Close': 42.2, 'Volume': 9150687.0, 'OpenInterest': 0.0}, {'Time': 1607011200000, 'Open': 41.6, 'High': 43.25, 'Low': 41.6, 'Close': 43.25, 'Volume': 8804169.0, 'OpenInterest': 0.0}, {'Time': 1607097600000, 'Open': 42.55, 'High': 43.45, 'Low': 42.55, 'Close': 43.3, 'Volume': 4409854.9999, 'OpenInterest': 0.0}, {'Time': 1607270400000, 'Open': 43.55, 'High': 43.55, 'Low': 42.05, 'Close': 42.45, 'Volume': 7024153.0, 'OpenInterest': 0.0}, {'Time': 1607356800000, 'Open': 42.6, 'High': 42.6, 'Low': 42.6, 'Close': 42.6, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1607443200000, 'Open': 42.35, 'High': 44.25, 'Low': 42.35, 'Close': 44.25, 'Volume': 5341153.9999, 'OpenInterest': 0.0}, {'Time': 1607529600000, 'Open': 44.7, 'High': 44.7, 'Low': 43.1, 'Close': 43.15, 'Volume': 9371248.9999, 'OpenInterest': 0.0}, {'Time': 1607616000000, 'Open': 42.65, 'High': 46.85, 'Low': 42.65, 'Close': 45.15, 'Volume': 12624052.0, 'OpenInterest': 0.0}, {'Time': 1607875200000, 'Open': 45.55, 'High': 45.55, 'Low': 45.55, 'Close': 45.55, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1607961600000, 'Open': 44.85, 'High': 46.8, 'Low': 44.85, 'Close': 46.8, 'Volume': 7354236.0, 'OpenInterest': 0.0}, {'Time': 1608048000000, 'Open': 46.2, 'High': 49.1, 'Low': 46.2, 'Close': 48.25, 'Volume': 11847009.0, 'OpenInterest': 0.0}, {'Time': 1608134400000, 'Open': 49.0, 'High': 49.0, 'Low': 46.8, 'Close': 48.0, 'Volume': 11774077.9999, 'OpenInterest': 0.0}, {'Time': 1608220800000, 'Open': 48.2, 'High': 48.2, 'Low': 45.8, 'Close': 46.3, 'Volume': 24315729.9998, 'OpenInterest': 0.0}, {'Time': 1608480000000, 'Open': 46.95, 'High': 46.95, 'Low': 46.95, 'Close': 46.95, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1608566400000, 'Open': 46.05, 'High': 49.45, 'Low': 46.05, 'Close': 48.1, 'Volume': 8900236.9999, 'OpenInterest': 0.0}, {'Time': 1608652800000, 'Open': 49.5, 'High': 49.5, 'Low': 47.15, 'Close': 47.65, 'Volume': 8276745.9999, 'OpenInterest': 0.0}, {'Time': 1608739200000, 'Open': 47.35, 'High': 49.8, 'Low': 47.35, 'Close': 49.65, 'Volume': 9600448.9999, 'OpenInterest': 0.0}, {'Time': 1608825600000, 'Open': 48.5, 'High': 50.65, 'Low': 48.5, 'Close': 50.0, 'Volume': 5478708.9999, 'OpenInterest': 0.0}, {'Time': 1609084800000, 'Open': 50.25, 'High': 50.25, 'Low': 50.25, 'Close': 50.25, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1609171200000, 'Open': 50.0, 'High': 52.05, 'Low': 50.0, 'Close': 52.0, 'Volume': 6628302.9999, 'OpenInterest': 0.0}, {'Time': 1609257600000, 'Open': 52.2, 'High': 52.5, 'Low': 49.85, 'Close': 51.95, 'Volume': 10667187.9999, 'OpenInterest': 0.0}, {'Time': 1609344000000, 'Open': 52.3, 'High': 53.3, 'Low': 51.5, 'Close': 53.3, 'Volume': 4812344.0, 'OpenInterest': 0.0}, {'Time': 1609689600000, 'Open': 53.0, 'High': 53.0, 'Low': 53.0, 'Close': 53.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1609776000000, 'Open': 51.05, 'High': 54.0, 'Low': 51.05, 'Close': 53.7, 'Volume': 9803124.9999, 'OpenInterest': 0.0}, {'Time': 1609862400000, 'Open': 52.45, 'High': 55.2, 'Low': 52.45, 'Close': 54.55, 'Volume': 15146559.0, 'OpenInterest': 0.0}, {'Time': 1609948800000, 'Open': 54.0, 'High': 54.0, 'Low': 52.0, 'Close': 52.6, 'Volume': 6437363.0, 'OpenInterest': 0.0}, {'Time': 1610035200000, 'Open': 53.25, 'High': 53.25, 'Low': 53.25, 'Close': 53.25, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610121600000, 'Open': 52.7, 'High': 54.75, 'Low': 52.7, 'Close': 54.35, 'Volume': 9272505.0, 'OpenInterest': 0.0}, {'Time': 1610294400000, 'Open': 54.15, 'High': 54.15, 'Low': 54.15, 'Close': 54.15, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610380800000, 'Open': 54.35, 'High': 54.35, 'Low': 49.3, 'Close': 51.2, 'Volume': 16089399.9999, 'OpenInterest': 0.0}, {'Time': 1610467200000, 'Open': 51.5, 'High': 51.5, 'Low': 48.85, 'Close': 51.05, 'Volume': 16251111.9999, 'OpenInterest': 0.0}, {'Time': 1610553600000, 'Open': 51.4, 'High': 51.4, 'Low': 49.0, 'Close': 49.4, 'Volume': 11825349.0, 'OpenInterest': 0.0}, {'Time': 1610640000000, 'Open': 50.75, 'High': 50.8, 'Low': 48.1, 'Close': 50.8, 'Volume': 26425451.0, 'OpenInterest': 0.0}, {'Time': 1610899200000, 'Open': 51.3, 'High': 51.3, 'Low': 51.3, 'Close': 51.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610985600000, 'Open': 51.1, 'High': 53.6, 'Low': 51.1, 'Close': 53.4, 'Volume': 10880124.9999, 'OpenInterest': 0.0}, {'Time': 1611072000000, 'Open': 52.15, 'High': 55.5, 'Low': 52.15, 'Close': 55.5, 'Volume': 13633171.9999, 'OpenInterest': 0.0}, {'Time': 1611158400000, 'Open': 57.6, 'High': 57.6, 'Low': 51.5, 'Close': 52.1, 'Volume': 32853868.9998, 'OpenInterest': 0.0}, {'Time': 1611244800000, 'Open': 52.1, 'High': 52.1, 'Low': 52.1, 'Close': 52.1, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611331200000, 'Open': 52.5, 'High': 52.5, 'Low': 50.1, 'Close': 50.5, 'Volume': 20532126.0, 'OpenInterest': 0.0}, {'Time': 1611504000000, 'Open': 50.85, 'High': 50.85, 'Low': 50.85, 'Close': 50.85, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611590400000, 'Open': 50.3, 'High': 52.3, 'Low': 50.3, 'Close': 51.7, 'Volume': 14428134.0, 'OpenInterest': 0.0}, {'Time': 1611676800000, 'Open': 51.85, 'High': 51.85, 'Low': 46.6, 'Close': 48.85, 'Volume': 31419973.0, 'OpenInterest': 0.0}, {'Time': 1611763200000, 'Open': 47.85, 'High': 47.85, 'Low': 47.85, 'Close': 47.85, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611849600000, 'Open': 48.9, 'High': 50.2, 'Low': 45.3, 'Close': 48.55, 'Volume': 34541409.0, 'OpenInterest': 0.0}, {'Time': 1612108800000, 'Open': 48.45, 'High': 48.45, 'Low': 48.45, 'Close': 48.45, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1612195200000, 'Open': 47.55, 'High': 51.3, 'Low': 47.55, 'Close': 51.3, 'Volume': 11063736.9999, 'OpenInterest': 0.0}, {'Time': 1612281600000, 'Open': 52.2, 'High': 52.2, 'Low': 49.95, 'Close': 51.05, 'Volume': 16967433.0, 'OpenInterest': 0.0}, {'Time': 1612368000000, 'Open': 51.7, 'High': 51.7, 'Low': 46.65, 'Close': 47.95, 'Volume': 34752159.9997, 'OpenInterest': 0.0}, {'Time': 1612454400000, 'Open': 46.5, 'High': 46.5, 'Low': 46.5, 'Close': 46.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1612540800000, 'Open': 46.45, 'High': 51.9, 'Low': 46.45, 'Close': 50.9, 'Volume': 20721496.9998, 'OpenInterest': 0.0}, {'Time': 1612713600000, 'Open': 52.0, 'High': 52.0, 'Low': 52.0, 'Close': 52.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1612800000000, 'Open': 52.35, 'High': 52.5, 'Low': 50.5, 'Close': 52.5, 'Volume': 8421429.9999, 'OpenInterest': 0.0}, {'Time': 1612886400000, 'Open': 51.8, 'High': 53.4, 'Low': 51.8, 'Close': 52.8, 'Volume': 6224124.9999, 'OpenInterest': 0.0}, {'Time': 1612972800000, 'Open': 51.8, 'High': 53.4, 'Low': 51.8, 'Close': 53.4, 'Volume': 6588813.9999, 'OpenInterest': 0.0}, {'Time': 1613404800000, 'Open': 54.5, 'High': 54.5, 'Low': 54.5, 'Close': 54.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1613491200000, 'Open': 55.4, 'High': 55.4, 'Low': 52.5, 'Close': 52.5, 'Volume': 6578880.0, 'OpenInterest': 0.0}, {'Time': 1613577600000, 'Open': 51.6, 'High': 54.55, 'Low': 51.05, 'Close': 51.95, 'Volume': 18708984.0, 'OpenInterest': 0.0}, {'Time': 1613664000000, 'Open': 51.4, 'High': 51.4, 'Low': 51.4, 'Close': 51.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1613750400000, 'Open': 50.2, 'High': 52.2, 'Low': 50.2, 'Close': 52.0, 'Volume': 6851712.0, 'OpenInterest': 0.0}]
# 订阅港股安踏数据
infoB = exchange.SetContractType("02020.HK")
print(infoB)
{'ExchangeID': 'HK', 'ExchangeInstID': '02020.HK', 'InstrumentID': '02020.HK', 'InstrumentName': '安踏体育', 'LongMarginRatio': 1, 'MaxLimitOrderVolume': 10000, 'MinBuyVolume': 1, 'OpenDate': '', 'PriceTick': 0.1, 'ShortMarginRatio': 1, 'VolumeMultiple': 1000}
# 港股安踏K线
barsB = exchange.GetRecords()
print(barsB)
[{'Time': 1596643200000, 'Open': 75.7, 'High': 75.7, 'Low': 73.0, 'Close': 73.6, 'Volume': 4061486.0, 'OpenInterest': 0.0}, {'Time': 1596729600000, 'Open': 73.9, 'High': 73.9, 'Low': 73.9, 'Close': 73.9, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1596816000000, 'Open': 72.8, 'High': 74.4, 'Low': 72.8, 'Close': 74.1, 'Volume': 3738885.9999, 'OpenInterest': 0.0}, {'Time': 1596988800000, 'Open': 73.4, 'High': 73.4, 'Low': 73.4, 'Close': 73.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597075200000, 'Open': 75.9, 'High': 75.9, 'Low': 72.7, 'Close': 74.1, 'Volume': 6865347.0, 'OpenInterest': 0.0}, {'Time': 1597161600000, 'Open': 73.6, 'High': 79.0, 'Low': 73.6, 'Close': 76.8, 'Volume': 12271083.0, 'OpenInterest': 0.0}, {'Time': 1597248000000, 'Open': 75.2, 'High': 79.1, 'Low': 75.2, 'Close': 79.1, 'Volume': 4597555.9999, 'OpenInterest': 0.0}, {'Time': 1597334400000, 'Open': 77.9, 'High': 81.4, 'Low': 77.9, 'Close': 81.2, 'Volume': 8316876.0, 'OpenInterest': 0.0}, {'Time': 1597420800000, 'Open': 80.0, 'High': 84.7, 'Low': 80.0, 'Close': 82.7, 'Volume': 11601010.9999, 'OpenInterest': 0.0}, {'Time': 1597593600000, 'Open': 83.9, 'High': 83.9, 'Low': 83.9, 'Close': 83.9, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597680000000, 'Open': 85.5, 'High': 85.5, 'Low': 82.3, 'Close': 83.6, 'Volume': 7057011.0, 'OpenInterest': 0.0}, {'Time': 1597766400000, 'Open': 82.4, 'High': 86.7, 'Low': 82.4, 'Close': 82.6, 'Volume': 8875732.0, 'OpenInterest': 0.0}, {'Time': 1597852800000, 'Open': 81.8, 'High': 81.8, 'Low': 81.8, 'Close': 81.8, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1597939200000, 'Open': 80.8, 'High': 83.7, 'Low': 80.8, 'Close': 83.7, 'Volume': 3063948.0, 'OpenInterest': 0.0}, {'Time': 1598025600000, 'Open': 82.3, 'High': 84.9, 'Low': 82.3, 'Close': 84.0, 'Volume': 2801787.9999, 'OpenInterest': 0.0}, {'Time': 1598198400000, 'Open': 85.3, 'High': 85.3, 'Low': 85.3, 'Close': 85.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1598284800000, 'Open': 84.1, 'High': 87.6, 'Low': 84.1, 'Close': 87.6, 'Volume': 5531595.9999, 'OpenInterest': 0.0}, {'Time': 1598371200000, 'Open': 87.9, 'High': 87.9, 'Low': 82.2, 'Close': 82.2, 'Volume': 5625426.9999, 'OpenInterest': 0.0}, {'Time': 1598457600000, 'Open': 81.9, 'High': 84.7, 'Low': 81.7, 'Close': 81.7, 'Volume': 17708242.9998, 'OpenInterest': 0.0}, {'Time': 1598544000000, 'Open': 83.1, 'High': 83.1, 'Low': 80.9, 'Close': 80.9, 'Volume': 10317207.9999, 'OpenInterest': 0.0}, {'Time': 1598630400000, 'Open': 80.4, 'High': 83.1, 'Low': 80.4, 'Close': 81.8, 'Volume': 10493271.0, 'OpenInterest': 0.0}, {'Time': 1598803200000, 'Open': 82.0, 'High': 82.0, 'Low': 82.0, 'Close': 82.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1598889600000, 'Open': 83.6, 'High': 83.6, 'Low': 75.4, 'Close': 77.1, 'Volume': 15197907.9999, 'OpenInterest': 0.0}, {'Time': 1598976000000, 'Open': 76.4, 'High': 79.5, 'Low': 76.4, 'Close': 79.5, 'Volume': 6286587.9999, 'OpenInterest': 0.0}, {'Time': 1599062400000, 'Open': 77.0, 'High': 80.4, 'Low': 77.0, 'Close': 77.9, 'Volume': 6487386.9999, 'OpenInterest': 0.0}, {'Time': 1599148800000, 'Open': 79.8, 'High': 79.8, 'Low': 76.6, 'Close': 76.6, 'Volume': 4922896.9999, 'OpenInterest': 0.0}, {'Time': 1599235200000, 'Open': 77.0, 'High': 77.0, 'Low': 74.8, 'Close': 76.3, 'Volume': 7641165.9999, 'OpenInterest': 0.0}, {'Time': 1599408000000, 'Open': 76.3, 'High': 76.3, 'Low': 76.3, 'Close': 76.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1599494400000, 'Open': 77.3, 'High': 77.3, 'Low': 74.4, 'Close': 76.2, 'Volume': 5552905.9999, 'OpenInterest': 0.0}, {'Time': 1599580800000, 'Open': 76.3, 'High': 76.3, 'Low': 74.0, 'Close': 74.0, 'Volume': 3262165.9999, 'OpenInterest': 0.0}, {'Time': 1599667200000, 'Open': 73.1, 'High': 75.8, 'Low': 73.1, 'Close': 74.3, 'Volume': 7736348.9999, 'OpenInterest': 0.0}, {'Time': 1599753600000, 'Open': 73.9, 'High': 76.5, 'Low': 73.9, 'Close': 75.5, 'Volume': 4867582.0, 'OpenInterest': 0.0}, {'Time': 1600012800000, 'Open': 76.0, 'High': 76.0, 'Low': 76.0, 'Close': 76.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600099200000, 'Open': 75.1, 'High': 78.5, 'Low': 75.1, 'Close': 77.1, 'Volume': 6661629.9999, 'OpenInterest': 0.0}, {'Time': 1600185600000, 'Open': 76.7, 'High': 78.8, 'Low': 76.7, 'Close': 78.8, 'Volume': 5791984.9999, 'OpenInterest': 0.0}, {'Time': 1600272000000, 'Open': 77.6, 'High': 79.8, 'Low': 77.3, 'Close': 77.7, 'Volume': 10232601.9999, 'OpenInterest': 0.0}, {'Time': 1600358400000, 'Open': 77.7, 'High': 77.7, 'Low': 77.7, 'Close': 77.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600444800000, 'Open': 77.6, 'High': 81.5, 'Low': 77.6, 'Close': 80.6, 'Volume': 9246159.9999, 'OpenInterest': 0.0}, {'Time': 1600617600000, 'Open': 81.4, 'High': 81.4, 'Low': 81.4, 'Close': 81.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600704000000, 'Open': 81.5, 'High': 81.5, 'Low': 76.5, 'Close': 76.8, 'Volume': 7744753.9999, 'OpenInterest': 0.0}, {'Time': 1600790400000, 'Open': 77.2, 'High': 77.2, 'Low': 77.2, 'Close': 77.2, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1600876800000, 'Open': 76.8, 'High': 80.6, 'Low': 76.8, 'Close': 79.8, 'Volume': 4552305.9999, 'OpenInterest': 0.0}, {'Time': 1600963200000, 'Open': 80.5, 'High': 80.5, 'Low': 78.3, 'Close': 78.8, 'Volume': 3516066.0, 'OpenInterest': 0.0}, {'Time': 1601049600000, 'Open': 78.9, 'High': 78.9, 'Low': 76.1, 'Close': 76.9, 'Volume': 3496378.9999, 'OpenInterest': 0.0}, {'Time': 1601222400000, 'Open': 77.7, 'High': 77.7, 'Low': 77.7, 'Close': 77.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1601308800000, 'Open': 77.9, 'High': 79.0, 'Low': 76.5, 'Close': 79.0, 'Volume': 3084264.9999, 'OpenInterest': 0.0}, {'Time': 1601395200000, 'Open': 79.8, 'High': 79.8, 'Low': 78.0, 'Close': 79.8, 'Volume': 3096108.9999, 'OpenInterest': 0.0}, {'Time': 1601481600000, 'Open': 79.1, 'High': 81.0, 'Low': 79.1, 'Close': 80.1, 'Volume': 3317808.9999, 'OpenInterest': 0.0}, {'Time': 1601827200000, 'Open': 83.0, 'High': 83.0, 'Low': 83.0, 'Close': 83.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1601913600000, 'Open': 80.9, 'High': 84.8, 'Low': 80.9, 'Close': 84.7, 'Volume': 7364857.9999, 'OpenInterest': 0.0}, {'Time': 1602000000000, 'Open': 85.8, 'High': 85.8, 'Low': 82.5, 'Close': 83.0, 'Volume': 2927293.9999, 'OpenInterest': 0.0}, {'Time': 1602086400000, 'Open': 81.1, 'High': 84.2, 'Low': 81.1, 'Close': 83.5, 'Volume': 2279148.0, 'OpenInterest': 0.0}, {'Time': 1602172800000, 'Open': 82.5, 'High': 85.8, 'Low': 82.5, 'Close': 85.8, 'Volume': 4151670.0, 'OpenInterest': 0.0}, {'Time': 1602259200000, 'Open': 85.0, 'High': 87.3, 'Low': 85.0, 'Close': 85.9, 'Volume': 8893686.0, 'OpenInterest': 0.0}, {'Time': 1602432000000, 'Open': 86.5, 'High': 88.6, 'Low': 86.5, 'Close': 87.5, 'Volume': 10299944.0, 'OpenInterest': 0.0}, {'Time': 1602604800000, 'Open': 86.3, 'High': 86.3, 'Low': 86.3, 'Close': 86.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1602691200000, 'Open': 88.7, 'High': 88.7, 'Low': 85.0, 'Close': 85.0, 'Volume': 5640195.9999, 'OpenInterest': 0.0}, {'Time': 1602777600000, 'Open': 84.6, 'High': 86.7, 'Low': 84.6, 'Close': 85.6, 'Volume': 6124497.0, 'OpenInterest': 0.0}, {'Time': 1602864000000, 'Open': 90.9, 'High': 90.9, 'Low': 84.7, 'Close': 85.4, 'Volume': 14347911.9999, 'OpenInterest': 0.0}, {'Time': 1603036800000, 'Open': 85.9, 'High': 85.9, 'Low': 85.9, 'Close': 85.9, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1603123200000, 'Open': 87.1, 'High': 87.1, 'Low': 84.8, 'Close': 86.5, 'Volume': 5645878.9999, 'OpenInterest': 0.0}, {'Time': 1603209600000, 'Open': 83.5, 'High': 89.8, 'Low': 83.5, 'Close': 88.8, 'Volume': 8770530.9999, 'OpenInterest': 0.0}, {'Time': 1603296000000, 'Open': 87.2, 'High': 89.7, 'Low': 87.2, 'Close': 88.9, 'Volume': 6132067.9999, 'OpenInterest': 0.0}, {'Time': 1603382400000, 'Open': 86.8, 'High': 90.0, 'Low': 86.8, 'Close': 89.3, 'Volume': 5863203.9999, 'OpenInterest': 0.0}, {'Time': 1603468800000, 'Open': 89.8, 'High': 89.8, 'Low': 86.1, 'Close': 86.6, 'Volume': 7011504.9999, 'OpenInterest': 0.0}, {'Time': 1603728000000, 'Open': 85.7, 'High': 85.7, 'Low': 85.7, 'Close': 85.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1603814400000, 'Open': 86.8, 'High': 86.8, 'Low': 84.5, 'Close': 85.7, 'Volume': 8666331.0, 'OpenInterest': 0.0}, {'Time': 1603900800000, 'Open': 83.6, 'High': 88.8, 'Low': 83.6, 'Close': 86.0, 'Volume': 4406250.9999, 'OpenInterest': 0.0}, {'Time': 1603987200000, 'Open': 85.1, 'High': 88.6, 'Low': 85.1, 'Close': 86.7, 'Volume': 5069493.9999, 'OpenInterest': 0.0}, {'Time': 1604073600000, 'Open': 87.8, 'High': 87.8, 'Low': 84.6, 'Close': 85.3, 'Volume': 5263374.0, 'OpenInterest': 0.0}, {'Time': 1604246400000, 'Open': 85.3, 'High': 85.3, 'Low': 85.3, 'Close': 85.3, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1604332800000, 'Open': 85.0, 'High': 87.2, 'Low': 85.0, 'Close': 87.0, 'Volume': 4139778.9999, 'OpenInterest': 0.0}, {'Time': 1604419200000, 'Open': 86.1, 'High': 89.3, 'Low': 86.1, 'Close': 89.3, 'Volume': 3894643.9999, 'OpenInterest': 0.0}, {'Time': 1604505600000, 'Open': 87.2, 'High': 95.0, 'Low': 87.2, 'Close': 95.0, 'Volume': 8027269.9999, 'OpenInterest': 0.0}, {'Time': 1604592000000, 'Open': 93.3, 'High': 102.0, 'Low': 93.3, 'Close': 101.1, 'Volume': 20145794.9998, 'OpenInterest': 0.0}, {'Time': 1604851200000, 'Open': 104.6, 'High': 104.6, 'Low': 104.6, 'Close': 104.6, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1604937600000, 'Open': 104.8, 'High': 104.8, 'Low': 99.1, 'Close': 103.8, 'Volume': 13210212.9999, 'OpenInterest': 0.0}, {'Time': 1605024000000, 'Open': 104.3, 'High': 104.3, 'Low': 99.4, 'Close': 102.2, 'Volume': 7117153.9999, 'OpenInterest': 0.0}, {'Time': 1605110400000, 'Open': 104.6, 'High': 104.6, 'Low': 95.6, 'Close': 98.9, 'Volume': 11493129.9999, 'OpenInterest': 0.0}, {'Time': 1605196800000, 'Open': 97.1, 'High': 102.5, 'Low': 97.1, 'Close': 102.3, 'Volume': 8017696.9999, 'OpenInterest': 0.0}, {'Time': 1605283200000, 'Open': 102.5, 'High': 102.5, 'Low': 99.4, 'Close': 101.5, 'Volume': 6410535.0, 'OpenInterest': 0.0}, {'Time': 1605456000000, 'Open': 108.0, 'High': 108.0, 'Low': 108.0, 'Close': 108.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1605542400000, 'Open': 104.5, 'High': 109.7, 'Low': 104.5, 'Close': 108.0, 'Volume': 15565195.9999, 'OpenInterest': 0.0}, {'Time': 1605628800000, 'Open': 108.5, 'High': 108.5, 'Low': 103.9, 'Close': 107.0, 'Volume': 6378078.0, 'OpenInterest': 0.0}, {'Time': 1605715200000, 'Open': 106.1, 'High': 109.5, 'Low': 106.1, 'Close': 109.5, 'Volume': 7325010.9999, 'OpenInterest': 0.0}, {'Time': 1605801600000, 'Open': 108.8, 'High': 114.3, 'Low': 108.8, 'Close': 111.6, 'Volume': 8203845.0, 'OpenInterest': 0.0}, {'Time': 1605888000000, 'Open': 111.9, 'High': 111.9, 'Low': 108.7, 'Close': 110.0, 'Volume': 6798786.0, 'OpenInterest': 0.0}, {'Time': 1606060800000, 'Open': 110.0, 'High': 110.0, 'Low': 110.0, 'Close': 110.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1606147200000, 'Open': 111.0, 'High': 111.0, 'Low': 107.3, 'Close': 109.7, 'Volume': 11305515.0, 'OpenInterest': 0.0}, {'Time': 1606233600000, 'Open': 109.7, 'High': 109.7, 'Low': 109.7, 'Close': 109.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1606320000000, 'Open': 110.2, 'High': 110.2, 'Low': 102.7, 'Close': 103.8, 'Volume': 9149233.9999, 'OpenInterest': 0.0}, {'Time': 1606406400000, 'Open': 103.3, 'High': 106.7, 'Low': 103.3, 'Close': 106.5, 'Volume': 7479276.0, 'OpenInterest': 0.0}, {'Time': 1606492800000, 'Open': 103.7, 'High': 109.1, 'Low': 103.7, 'Close': 108.1, 'Volume': 4604331.0, 'OpenInterest': 0.0}, {'Time': 1606665600000, 'Open': 109.0, 'High': 109.0, 'Low': 104.4, 'Close': 105.4, 'Volume': 9254879.0, 'OpenInterest': 0.0}, {'Time': 1606752000000, 'Open': 106.4, 'High': 106.4, 'Low': 106.4, 'Close': 106.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1606838400000, 'Open': 105.3, 'High': 113.0, 'Low': 105.3, 'Close': 110.2, 'Volume': 13621346.9999, 'OpenInterest': 0.0}, {'Time': 1606924800000, 'Open': 109.6, 'High': 109.6, 'Low': 109.6, 'Close': 109.6, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1607011200000, 'Open': 108.7, 'High': 113.4, 'Low': 108.7, 'Close': 113.4, 'Volume': 4954701.9999, 'OpenInterest': 0.0}, {'Time': 1607097600000, 'Open': 113.8, 'High': 113.8, 'Low': 110.4, 'Close': 110.6, 'Volume': 22377865.9998, 'OpenInterest': 0.0}, {'Time': 1607270400000, 'Open': 110.6, 'High': 110.6, 'Low': 110.6, 'Close': 110.6, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1607356800000, 'Open': 111.1, 'High': 111.1, 'Low': 105.2, 'Close': 107.3, 'Volume': 14837214.0, 'OpenInterest': 0.0}, {'Time': 1607443200000, 'Open': 105.6, 'High': 109.7, 'Low': 105.6, 'Close': 109.0, 'Volume': 9640022.0, 'OpenInterest': 0.0}, {'Time': 1607529600000, 'Open': 108.6, 'High': 110.2, 'Low': 107.1, 'Close': 110.2, 'Volume': 6046546.0, 'OpenInterest': 0.0}, {'Time': 1607616000000, 'Open': 110.7, 'High': 110.7, 'Low': 108.2, 'Close': 109.6, 'Volume': 5489808.0, 'OpenInterest': 0.0}, {'Time': 1607875200000, 'Open': 107.2, 'High': 107.2, 'Low': 107.2, 'Close': 107.2, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1607961600000, 'Open': 106.2, 'High': 109.5, 'Low': 106.2, 'Close': 109.1, 'Volume': 5076670.9999, 'OpenInterest': 0.0}, {'Time': 1608048000000, 'Open': 108.7, 'High': 113.5, 'Low': 108.7, 'Close': 111.4, 'Volume': 5946084.0, 'OpenInterest': 0.0}, {'Time': 1608134400000, 'Open': 110.5, 'High': 113.5, 'Low': 109.5, 'Close': 109.5, 'Volume': 6516697.9999, 'OpenInterest': 0.0}, {'Time': 1608220800000, 'Open': 110.6, 'High': 110.6, 'Low': 105.8, 'Close': 106.7, 'Volume': 16965220.9998, 'OpenInterest': 0.0}, {'Time': 1608307200000, 'Open': 107.0, 'High': 107.0, 'Low': 103.6, 'Close': 105.1, 'Volume': 18734265.0, 'OpenInterest': 0.0}, {'Time': 1608480000000, 'Open': 106.0, 'High': 106.0, 'Low': 106.0, 'Close': 106.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1608566400000, 'Open': 104.7, 'High': 114.5, 'Low': 104.7, 'Close': 111.9, 'Volume': 18758388.9998, 'OpenInterest': 0.0}, {'Time': 1608652800000, 'Open': 112.4, 'High': 115.8, 'Low': 112.4, 'Close': 114.6, 'Volume': 5218794.0, 'OpenInterest': 0.0}, {'Time': 1608739200000, 'Open': 116.0, 'High': 116.0, 'Low': 116.0, 'Close': 116.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1608825600000, 'Open': 116.5, 'High': 116.5, 'Low': 114.0, 'Close': 115.7, 'Volume': 2438743.9999, 'OpenInterest': 0.0}, {'Time': 1609084800000, 'Open': 113.7, 'High': 120.7, 'Low': 113.7, 'Close': 119.6, 'Volume': 9469978.0, 'OpenInterest': 0.0}, {'Time': 1609171200000, 'Open': 120.8, 'High': 120.8, 'Low': 120.8, 'Close': 120.8, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1609257600000, 'Open': 122.0, 'High': 122.0, 'Low': 116.4, 'Close': 118.3, 'Volume': 3955947.9999, 'OpenInterest': 0.0}, {'Time': 1609344000000, 'Open': 117.9, 'High': 123.4, 'Low': 117.9, 'Close': 123.2, 'Volume': 4701900.0, 'OpenInterest': 0.0}, {'Time': 1609430400000, 'Open': 124.2, 'High': 124.2, 'Low': 121.6, 'Close': 122.9, 'Volume': 3145185.0, 'OpenInterest': 0.0}, {'Time': 1609689600000, 'Open': 123.0, 'High': 123.0, 'Low': 123.0, 'Close': 123.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1609776000000, 'Open': 122.3, 'High': 127.5, 'Low': 122.3, 'Close': 126.8, 'Volume': 5706069.9999, 'OpenInterest': 0.0}, {'Time': 1609862400000, 'Open': 125.2, 'High': 129.9, 'Low': 125.2, 'Close': 129.4, 'Volume': 6707995.9999, 'OpenInterest': 0.0}, {'Time': 1609948800000, 'Open': 128.6, 'High': 133.4, 'Low': 127.7, 'Close': 130.7, 'Volume': 13803867.9999, 'OpenInterest': 0.0}, {'Time': 1610035200000, 'Open': 130.7, 'High': 130.7, 'Low': 130.7, 'Close': 130.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610121600000, 'Open': 129.1, 'High': 134.9, 'Low': 129.1, 'Close': 131.2, 'Volume': 7210272.0, 'OpenInterest': 0.0}, {'Time': 1610294400000, 'Open': 132.8, 'High': 132.8, 'Low': 132.8, 'Close': 132.8, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610380800000, 'Open': 132.9, 'High': 132.9, 'Low': 125.7, 'Close': 128.6, 'Volume': 7813584.0, 'OpenInterest': 0.0}, {'Time': 1610467200000, 'Open': 126.8, 'High': 133.8, 'Low': 126.8, 'Close': 133.0, 'Volume': 5878152.0, 'OpenInterest': 0.0}, {'Time': 1610553600000, 'Open': 133.4, 'High': 133.4, 'Low': 128.0, 'Close': 128.0, 'Volume': 3718293.0, 'OpenInterest': 0.0}, {'Time': 1610640000000, 'Open': 127.8, 'High': 135.0, 'Low': 127.8, 'Close': 130.3, 'Volume': 8895847.9999, 'OpenInterest': 0.0}, {'Time': 1610726400000, 'Open': 134.0, 'High': 134.0, 'Low': 128.3, 'Close': 129.5, 'Volume': 6790486.9999, 'OpenInterest': 0.0}, {'Time': 1610899200000, 'Open': 128.6, 'High': 128.6, 'Low': 128.6, 'Close': 128.6, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1610985600000, 'Open': 128.0, 'High': 143.9, 'Low': 128.0, 'Close': 143.9, 'Volume': 22806808.0, 'OpenInterest': 0.0}, {'Time': 1611072000000, 'Open': 143.9, 'High': 143.9, 'Low': 143.9, 'Close': 143.9, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611158400000, 'Open': 144.0, 'High': 144.0, 'Low': 137.5, 'Close': 138.0, 'Volume': 14852481.0, 'OpenInterest': 0.0}, {'Time': 1611244800000, 'Open': 140.5, 'High': 140.5, 'Low': 134.3, 'Close': 136.0, 'Volume': 10383478.9999, 'OpenInterest': 0.0}, {'Time': 1611331200000, 'Open': 131.8, 'High': 138.7, 'Low': 131.8, 'Close': 136.9, 'Volume': 12083832.0, 'OpenInterest': 0.0}, {'Time': 1611504000000, 'Open': 137.4, 'High': 137.4, 'Low': 137.4, 'Close': 137.4, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611590400000, 'Open': 139.3, 'High': 139.3, 'Low': 135.0, 'Close': 135.0, 'Volume': 11703862.9999, 'OpenInterest': 0.0}, {'Time': 1611676800000, 'Open': 137.0, 'High': 137.0, 'Low': 128.0, 'Close': 130.6, 'Volume': 18740979.9998, 'OpenInterest': 0.0}, {'Time': 1611763200000, 'Open': 127.2, 'High': 127.2, 'Low': 127.2, 'Close': 127.2, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1611849600000, 'Open': 131.0, 'High': 131.0, 'Low': 124.7, 'Close': 128.1, 'Volume': 9029736.9999, 'OpenInterest': 0.0}, {'Time': 1611936000000, 'Open': 127.8, 'High': 132.1, 'Low': 127.8, 'Close': 128.3, 'Volume': 10184757.9999, 'OpenInterest': 0.0}, {'Time': 1612108800000, 'Open': 128.0, 'High': 128.0, 'Low': 128.0, 'Close': 128.0, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1612195200000, 'Open': 126.5, 'High': 135.0, 'Low': 126.5, 'Close': 134.9, 'Volume': 6503337.0, 'OpenInterest': 0.0}, {'Time': 1612281600000, 'Open': 134.4, 'High': 141.0, 'Low': 134.4, 'Close': 138.3, 'Volume': 5619399.9999, 'OpenInterest': 0.0}, {'Time': 1612368000000, 'Open': 140.5, 'High': 140.5, 'Low': 134.1, 'Close': 139.0, 'Volume': 7556025.9999, 'OpenInterest': 0.0}, {'Time': 1612454400000, 'Open': 140.9, 'High': 144.4, 'Low': 135.9, 'Close': 141.7, 'Volume': 12642481.0, 'OpenInterest': 0.0}, {'Time': 1612713600000, 'Open': 145.2, 'High': 145.2, 'Low': 141.0, 'Close': 142.7, 'Volume': 3642160.0, 'OpenInterest': 0.0}, {'Time': 1612800000000, 'Open': 141.7, 'High': 141.7, 'Low': 141.7, 'Close': 141.7, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1612886400000, 'Open': 140.8, 'High': 146.0, 'Low': 140.8, 'Close': 146.0, 'Volume': 3236061.0, 'OpenInterest': 0.0}, {'Time': 1612972800000, 'Open': 144.0, 'High': 146.9, 'Low': 143.4, 'Close': 145.3, 'Volume': 3161740.9999, 'OpenInterest': 0.0}, {'Time': 1613404800000, 'Open': 154.3, 'High': 154.3, 'Low': 146.8, 'Close': 147.1, 'Volume': 3381912.0, 'OpenInterest': 0.0}, {'Time': 1613491200000, 'Open': 146.5, 'High': 146.5, 'Low': 146.5, 'Close': 146.5, 'Volume': 0.0, 'OpenInterest': 0.0}, {'Time': 1613577600000, 'Open': 143.2, 'High': 148.6, 'Low': 143.2, 'Close': 147.2, 'Volume': 3687456.9999, 'OpenInterest': 0.0}, {'Time': 1613664000000, 'Open': 149.0, 'High': 149.0, 'Low': 143.0, 'Close': 143.1, 'Volume': 5707675.9999, 'OpenInterest': 0.0}, {'Time': 1613750400000, 'Open': 140.0, 'High': 144.6, 'Low': 140.0, 'Close': 143.7, 'Volume': 4629735.9999, 'OpenInterest': 0.0}]
import datetime

datesA = []
priceA = []
for i in barsA:
    data_time = datetime.datetime.fromtimestamp(int(i['Time']/1000))
    datesA.append(data_time.strftime("%Y-%m-%d"))
    priceA.append(i['Close'])
    
datesB = []
priceB = []
for i in barsA:
    data_time = datetime.datetime.fromtimestamp(int(i['Time']/1000))
    datesB.append(data_time.strftime("%Y-%m-%d"))
    priceB.append(i['Close'])
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

plt.plot(datesA,priceA)
axA=plt.gca()
axA.set_title("LI-NING && ANTA Price Chart", fontsize=30)
axA.set_ylabel('LI-NING')
axB=axA.twinx()
axB.plot(datesB, price, 'r')
axB.set_ylabel('ANTA')
axA.xaxis.set_major_locator(ticker.MultipleLocator(15))
plt.gcf().set_size_inches(17, 8)
plt.xlim
plt.show()
<Figure size 1224x576 with 2 Axes>

四、总结

如上面的策略分析所示,采用的是港股李宁(02331)与港股安踏(02020)作为两支对冲的股票,其中蓝色的线是港股李宁(02331)的收盘价格,红色的线是港股安踏(02020)的收盘价格。在股票性质上李宁和安踏同属于中国的运动品牌,从时间上看1990年李宁创立,1991年安踏成立,但是到95年的时候李宁已经成为国内第一运动品牌,而安踏才刚刚步入正轨,直到2012年才有所超越。那么我们的策略初步定为:做多李宁(02331),同时做空安踏(02020)。

OK,在下一个章节中,我们将利用优宽量化(youquant.com)的回测环境,针对这两支股票做对冲交易,看看最后的结果到底如何,并且我们在下一个章节中,会加入更多的股票对,作为对冲的标的,实现港股多品种对冲策略。


更多内容