跟这个记录不是按updatetime升序有关,你排一下序再试试
代码如下所示:
dbPath = "dfs://ctp_market_data"
tableName = "ctp_market_data"
T = loadTable(dbPath,tableName)
// 设置查询的时间范围
date_range = [2023.06.12]
for (date_t in date_range) {
contract_code = select concatDateTime(TradingDay, time(string(UpdateTime) + "." + lpad(string(UpdateMillisec), 3, "0"))) as TradingTime, UpdateTime, BidPrice1,BidVolume1,AskPrice1,AskVolume1,InstrumentID from T where TradingDay = date_t}
//提取合约代码中的各个部分
update contract_code set symbol_code = contract_code.InstrumentID.substr(0, regexFind(contract_code.InstrumentID, "[0-9]",1)) //品种代码
update contract_code set InstrumentID2=strReplace(InstrumentID,"-","")//去杠
update contract_code set future_code = InstrumentID2.substr(0,regexFind(InstrumentID2, "C|P",2))//标的代码
update contract_code set strike_prices = substr(contract_code.InstrumentID2.substr(regexFind(contract_code.InstrumentID2, "C|P",4)),regexFind(InstrumentID2.substr(regexFind(InstrumentID2, "C|P",4)), "[0-9]+"))//执行价
update contract_code set OptionType = InstrumentID2.substr(regexFind(InstrumentID2, "C|P",4),1)//区分看跌看涨
//提取所有看涨 和 看跌期权数据 和 标的期货数据
contract_code_c = select * from contract_code where OptionType = "C"
contract_code_p = select * from contract_code where OptionType = "P"
contract_code_f = select * from contract_code where OptionType = NULL
// 合并成同一行
data = select * from aj(contract_code_c, contract_code_p , `strike_prices`UpdateTime)
aj前,contract_code_c和contract_code_p有strike_prices相同的数据如下: