期货品种和主力合约映射表/ 保证金计算/ 真实合约映射关系表
发布于 2 个月前 作者 yutiansut 127 次浏览 来自 文档
import QUANTAXIS as QA
import re


x1= QA.QA_fetch_get_future_domain()
x2 = [re.search(r'[a-zA-z]+', code)[0].upper() for code in x1]
xx  = dict(zip(x2, x1))
{'IF': 'IF2008',
 'IH': 'IH2008',
 'IC': 'IC2008',
 'TF': 'TF2009',
 'T': 'T2009',
 'CU': 'cu2009',
 'AU': 'au2012',
 'AG': 'ag2012',
 'ZN': 'zn2009',
 'AL': 'al2009',
 'RU': 'ru2101',
 'RB': 'rb2010',
 'FU': 'fu2009',
 'HC': 'hc2010',
 'BU': 'bu2012',
 'PB': 'pb2009',
 'NI': 'ni2010',
 'SN': 'sn2010',
 'WR': 'wr2010',
 'SC': 'sc2009',
 'A': 'a2009',
 'B': 'b2009',
 'BB': 'bb2008',
 'C': 'c2101',
 'CS': 'cs2009',
 'FB': 'fb2009',
 'I': 'i2009',
 'J': 'j2009',
 'JD': 'jd2009',
 'JM': 'jm2009',
 'L': 'l2009',
 'M': 'm2101',
 'P': 'p2009',
 'PP': 'pp2009',
 'V': 'v2009',
 'Y': 'y2101',
 'WH': 'WH009',
 'PM': 'PM105',
 'CF': 'CF009',
 'CY': 'CY009',
 'SR': 'SR009',
 'TA': 'TA009',
 'OI': 'OI009',
 'RI': 'RI009',
 'MA': 'MA009',
 'FG': 'FG009',
 'RS': 'RS009',
 'RM': 'RM009',
 'ZC': 'ZC009',
 'JR': 'JR009',
 'LR': 'LR011',
 'SF': 'SF010',
 'SM': 'SM009',
 'AP': 'AP010',
 'TS': 'TS2009',
 'SP': 'sp2009',
 'EG': 'eg2009',
 'CJ': 'CJ009',
 'NR': 'nr2010',
 'RR': 'rr2009',
 'UR': 'UR009',
 'SS': 'ss2010',
 'EB': 'eb2009',
 'SA': 'SA009',
 'PG': 'pg2011',
 'LU': 'lu2101'}

4 回复
data = QA.QA_fetch_future_day_adv([x+'L8' for x in x2], '2020-07-22', '2020-08-01').mean.reset_index()
mp =  QA.QAARP.MARKET_PRESET()
data = data.assign(frozen_coeff = data.code.apply(lambda x: mp.get_frozen(x)*mp.get_unit(x)) )
data = data.assign(frozen_money = data.apply(lambda x: x['mean']*x.frozen_coeff, axis=1))
data =data.assign(codex =  data.code.apply(lambda x: xx[x[:-2]]))

data.set_index(‘codex’).frozen_money.to_dict()

{‘ag2012’: 8260.40625, ‘a2009’: 2325.96875, ‘al2009’: 7224.453125, ‘AP010’: 5961.8, ‘au2012’: 33924.59983825726, ‘bb2008’: 23610.000610349998, ‘b2009’: 1685.890625, ‘bu2012’: 4267.40625, ‘CF009’: 3011.015625, ‘CJ009’: 3216.2812500000005, ‘c2101’: 1138.4375, ‘cs2009’: 1320.8125, ‘cu2009’: 25885.3125, ‘CY009’: 4770.9375, ‘eb2009’: 1414.625, ‘eg2009’: 2217.075, ‘fb2009’: 132017.1875, ‘FG009’: 1682.6875, ‘fu2009’: 2554.453125, ‘hc2010’: 3412.9406249999997, ‘IC2008’: 153664.34912109398, ‘IF2008’: 138223.87527465814, ‘IH2008’: 48349.6875, ‘i2009’: 6677.75, ‘jd2009’: 2940.2406250000004, ‘j2009’: 15798.5, ‘jm2009’: 5869.05, ‘JR009’: 2743.59375, ‘l2009’: 1759.6875, ‘LR011’: 2891.53125, ‘lu2101’: 2007.1000000000001, ‘MA009’: 1222.1781250000001, ‘m2101’: 1474.703125, ‘ni2010’: 10862.0625, ‘nr2010’: 7922.390624999999, ‘OI009’: 4312.15625, ‘pb2009’: 7624.53125, ‘pg2011’: 3925.9375, ‘p2009’: 4515.25, ‘PM105’: 5809.84375, ‘pp2009’: 1884.453125, ‘rb2010’: 3385.2093749999995, ‘RI009’: 2612.3333333333335, ‘RM009’: 1455.58125, ‘rr2009’: 1740.359375, ‘RS009’: 10836.9, ‘ru2101’: 9649.265624999998, ‘SA009’: 1322.65625, ‘sc2009’: 29487.812614440623, ‘SF010’: 1945.4968750000003, ‘SM009’: 2189.99375, ‘sn2010’: 14515.46875, ‘sp2009’: 3565.0, ‘SR009’: 2531.265625, ‘ss2010’: 5481.875, ‘TA009’: 1069.78125, ‘TF2009’: 12130.0687122345, ‘T2009’: 1989703.1164169998, ‘TS2009’: 10087.343788147187, ‘UR009’: 1620.3125, ‘v2009’: 1635.1953125, ‘WH009’: 10153.125, ‘wr2010’: 3567.5999999999995, ‘y2101’: 3102.4375, ‘ZC009’: 3322.349990844712, ‘zn2009’: 9126.40625} ​

回到顶部