Hi,
This is my source table. And here is the zip file containing csv data. tcs_2.zip
enableTableShareAndPersistence(table=streamTable(25000:0,`ts`symbol`price`ltq`vol`time,`TIMESTAMP`SYMBOL`DOUBLE`DOUBLE`DOUBLE`TIMESTAMP), tableName=`tcs_2, cacheSize=1200000)
Now I want to create OHLC data for 1 min, 5 min, 10 min, 15 min, 30 min, 1Hr, 1 Day etc In a single Table. How can I achieve this ? I tried following things but they are not complete. Please help me.
I have created two types of timeSeriesEngine, one with multiple windowSize another with single windowSize. The results of multiple windowSize are not correct. Please help me what to do.
1) Multiple windowSize
m = table(1000:0, `ts`symbol`o1`h1`l1`c1`v1`o5`h5`l5`c5`v5`o10`h10`l10`c10`v10`o15`h15`l15`c15 `v15, [TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])
sm = createTimeSeriesEngine(name="sm", windowSize=[60000,60000*5,60000*10,60000*15], step=60000, metrics=[[<[first(price), max(price), min( price), last(price), sum(ltq)]>],[<[first(price), max(price), min(price), last(price), sum(ltq)]>],[<[ first(price), max(price), min(price), last(price), sum(ltq)]>],[<[first(price), max(price), min(price), last(price) , sum(ltq)]>]], dummyTable=tcs_2, outputTable=m, timeColumn=`ts, useSystemTime=false, keyColumn=`symbol, useWindowStartTime=false, updateTime=60000)
subscribeTable(tableName="tcs_2", actionName="sm", offset=0, handler=append!{sm}, msgAsTable=true)
Output of Multiple Windowsize: (as you can see, the open price for 5 min sale only change at 20:15 But it changes in between. This can be observed for all other windowSizes. Which is incorrect.)
2) Individual Windowsize
To show each and every minute output, keyedTable is not used here.
m1 = table(1000:0, `ts`symbol`o1`h1`l1`c1`v1, [TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])
m5 = table(1000:0, `ts`symbol`o5`h5`l5`c5`v5, [TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])
m10= table(1000:0, `ts`symbol`o10`h10`l10`c10`v10, [TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])
m15= table(1000:0, `ts`symbol`o15`h15`l15`c15`v15, [TIMESTAMP,SYMBOL,DOUBLE,DOUBLE,DOUBLE,DOUBLE,DOUBLE])
SM1 = CreatetimeSeriesengine (name = "sm1", Windowsize = 60000, step = 60000, metrics = <[first (price), MAX (Price), Last (Price), Sum (LTQ)]>, DummyTable = TCS_2, OUTPUTTABLE = M1, TIMECOLUMN = `TS, UdeSystemTime = false, keycolumn =` symbol, usewindowstarttime = false, updatetime = 60000)
SM5 = CreatetimeSeriesengine (Name = "SM5", Windowsize = 60000 * 5, Step = 60000 * 5, Metrics = <[First (Price), MAX (Price), Last (Price), SUM (LTQ) ]>, dummyTable=tcs_2, outputTable=m5, timeColumn=`ts, useSystemTime=false, keyColumn=`symbol, useWindowStartTime=false, updateTime=60000)
SM10 = CreatetimeSeriesengine (name = "sm10", Windowsize = 60000 * 10, step = 60000 * 10, metrics = <[first (Price), MAX (Price), Last (Price), SUM (LTQ) ]>, dummyTable=tcs_2, outputTable=m10, timeColumn=`ts, useSystemTime=false, keyColumn=`symbol, useWindowStartTime=false, updateTime=60000)
SM15 = CreateTimeSeriesengine (name = "sm15", Windowsize = 60000 * 15, step = 60000 * 15, Metrics = <[first (Price), MAX (Price), Last (Price), SUM (LTQ) ]>, dummyTable=tcs_2, outputTable=m15, timeColumn=`ts, useSystemTime=false, keyColumn=`symbol, useWindowStartTime=false, updateTime=60000)
subscribeTable(tableName="tcs_2", actionName="sm1", offset=0, handler=append!{sm1}, msgAsTable=true)
subscribeTable(tableName="tcs_2", actionName="sm5", offset=0, handler=append!{sm5}, msgAsTable=true)
subscribeTable(tableName="tcs_2", actionName="sm10", offset=0, handler=append!{sm10}, msgAsTable=true)
subscribeTable(tableName="tcs_2", actionName="sm15", offset=0, handler=append!{sm15}, msgAsTable=true)
Output of single windowSize: ( As we can see the open of 5 min at 20:15 is not changing until 20:20. This can be observed for all other windowSizes. Which is correct )
5 Min windowSize:
10 Min windowSize:
15 Min windowSize:
Questions:
1) How to make single OHLC table (like table m) of multiple windowSize directly with realtime streaming data ?
2) How to join multiple windowSize / timeframe tables (like tables m1,m5,m10,m15 etc) and make a single OHLC table (like table m) which contains all OHLC data for all windowSizes with realtime streaming data ?
please refer https://ask.dolphindb.net/question/1140 for updates and / or solutions