-
Notifications
You must be signed in to change notification settings - Fork 8
/
01.marketDataReplay.txt
47 lines (41 loc) · 2 KB
/
01.marketDataReplay.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
stcokMarketReplay.txt
Script to replay stock market data
DolphinDB Inc.
DolphinDB server version: 2.00.6 2022.05.31
Storage engine: TSDB
Last modification time: 2022.07.07
*/
//login account
login("admin", "123456")
//create stream table: messageStream
def createStreamTableFunc(){
colName = `timestamp`source`msg
colType = [TIMESTAMP,SYMBOL, BLOB]
messageTemp = streamTable(1000000:0, colName, colType)
enableTableShareAndPersistence(table=messageTemp, tableName="messageStream", asynWrite=true, compress=true, cacheSize=1000000, retentionMinutes=1440, flushMode=0, preCache=10000)
messageTemp = NULL
}
createStreamTableFunc()
go
//replay history data
def replayStockMarketData(){
timeRS = cutPoints(09:15:00.000..15:00:00.000, 100)
orderDS = replayDS(sqlObj=<select * from loadTable("dfs://order", "order") where Date = 2020.12.31>, dateColumn=`Date, timeColumn=`Time, timeRepartitionSchema=timeRS)
tradeDS = replayDS(sqlObj=<select * from loadTable("dfs://trade", "trade") where Date = 2020.12.31>, dateColumn=`Date, timeColumn=`Time, timeRepartitionSchema=timeRS)
snapshotDS = replayDS(sqlObj=<select * from loadTable("dfs://snapshot", "snapshot") where Date =2020.12.31>, dateColumn=`Date, timeColumn=`Time, timeRepartitionSchema=timeRS)
inputDict = dict(["order", "trade", "snapshot"], [orderDS, tradeDS, snapshotDS])
submitJob("replay", "replay stock market", replay, inputDict, messageStream, `Date, `Time, , , 3)
}
replayStockMarketData()
getRecentJobs()
////load text and replay memory table
//def loadTextAndReplay(){
// orderTable= select * from loadText("/yourDataPath/replayData/order.csv") order by Time
// tradeTable = select * from loadText("/yourDataPath/replayData/trade.csv") order by Time
// snapshotTable = select * from loadText("/yourDataPath/replayData/snapshot.csv") order by Time
// inputDict = dict(["order", "trade", "snapshot"], [orderTable, tradeTable, snapshotTable])
//
// submitJob("replay", "replay memory table", replay, inputDict, messageStream, `Date, `Time, , , 1)
//}
//loadCSVAndReplay()