1

The structure of the tick data is different from the data structure of the K-line. When is the interception and conversion performed, can you talk about the general process?

I currently receive tick data and have written it into ticks (stream data table) in real time. If I subscribe, do I need to receive (all data fields) first, then convert it into a preparation table (such as traders), where there are only a few required fields, and finally aggregate to generate a candlestick table.

Polly
  • 603
  • 3
  • 13

1 Answers1

0

Please refer to following code:

tbColNames=`TradingDay`InstrumentID`ExchangeID`ExchangeInstID`LastPrice`Volume`Amount`OpenPosition`PreSettlementPrice`PreClosePrice`PreOpenInterest`OpenPrice`HighestPrice`LowestPrice`TotalVolume`TotalTurnover`OpenInterest`ClosePrice`SettlementPrice`UpperLimitPrice`LowerLimitPrice`ActionTime`RecvTime`BidPrice1`BidVolume1`AskPrice1`AskVolume1`BidPrice2`BidVolume2`AskPrice2`AskVolume2`BidPrice3`BidVolume3`AskPrice3`AskVolume3`BidPrice4`BidVolume4`AskPrice4`AskVolume4`BidPrice5`BidVolume5`AskPrice5`AskVolume5`AveragePrice`PreDelta`CurrDelta`RecordNo`TotalRecordNo`InDbTime

tbColTypes=[DATE,SYMBOL,SYMBOL,SYMBOL,DOUBLE,INT,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,INT,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,TIMESTAMP, TIMESTAMP,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,INT,DOUBLE,DOUBLE,DOUBLE,INT,INT,TIMESTAMP]

tbTicks = streamTable(100000:0,tbColNames,tbColTypes)


enableTableShareAndPersistence(table=tbTicks, tableName=`ticks, cacheSize=2000000, retentionMinutes=4320 )

barColNames=`UpdateTime`InstrumentID`Open`High`Low`Close`Volume`Amount`OpenPosition`TradingDay
barColTypes=[TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,INT,DOUBLE,DATE]
share streamTable(100:0, barColNames, barColTypes) as traders
metrics=<[
first(LastPrice),
max(LastPrice),
min(LastPrice),
last(LastPrice),
sum(Volume),
sum(Amount),
sum(OpenPosition),
last(TradingDay)]>

tsAggrKline = createTimeSeriesAggregator(name="aggr_kline_min01", windowSize=600000, step=600000, metrics=metrics, dummyTable=ticks, outputTable=traders, timeColumn=`InDbTime, keyColumn=`InstrumentID,updateTime=500, useWindowStartTime=true)

subscribeTable(tableName="ticks", actionName="act_tsaggr", offset=-1, handler=append!{getStreamEngine("aggr_kline_min01")}, batchSize=1000, throttle=1, hash=0, msgAsTable=true)
Polly
  • 603
  • 3
  • 13