CREATE CONTINUOUS QUERY cq_calc_min_kline ON Kline1m RESAMPLE EVERY 5s For 2m
BEGIN
SELECT max("price") AS "high", min("price") AS "low", first("price") as open, last("price") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline"
FROM "TopCoinDB"."autogen"."trade"
GROUP BY "exchange", "symbol", "unit",time(1m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_3m ON Kline3m RESAMPLE EVERY 5s FOR 6m
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_3m"
FROM "TopCoinDB"."autogen"."calc_kline"
GROUP BY "exchange", "symbol", "unit",time(3m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_5m ON Kline5m RESAMPLE EVERY 5s FOR 10m
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_5m"
FROM "TopCoinDB"."autogen"."calc_kline"
GROUP BY "exchange", "symbol", "unit",time(5m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_10m ON Kline10m RESAMPLE EVERY 5s FOR 20m
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_10m"
FROM "TopCoinDB"."autogen"."calc_kline_5m"
GROUP BY "exchange", "symbol", "unit",time(10m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_15m ON Kline15m RESAMPLE EVERY 10s FOR 30m
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_15m"
FROM "TopCoinDB"."autogen"."calc_kline_5m"
GROUP BY "exchange", "symbol", "unit",time(15m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_30m ON Kline30m RESAMPLE EVERY 15s FOR 1h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_30m"
FROM "TopCoinDB"."autogen"."calc_kline_15m"
GROUP BY "exchange", "symbol", "unit",time(30m)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_1h ON Kline1h RESAMPLE EVERY 15s FOR 2h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_1h"
FROM "TopCoinDB"."autogen"."calc_kline_30m"
GROUP BY "exchange", "symbol", "unit",time(1h)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_2h ON Kline2h RESAMPLE EVERY 15s FOR 4h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_2h"
FROM "TopCoinDB"."autogen"."calc_kline_1h"
GROUP BY "exchange", "symbol", "unit",time(2h)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_4h ON Kline4h RESAMPLE EVERY 15s FOR 8h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_4h"
FROM "TopCoinDB"."autogen"."calc_kline_2h"
GROUP BY "exchange", "symbol", "unit",time(4h)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_6h ON Kline6h RESAMPLE EVERY 15s FOR 12h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_6h"
FROM "TopCoinDB"."autogen"."calc_kline_2h"
GROUP BY "exchange", "symbol", "unit",time(6h)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_12h ON Kline12h RESAMPLE EVERY 15s FOR 24h
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_12h"
FROM "TopCoinDB"."autogen"."calc_kline_6h"
GROUP BY "exchange", "symbol", "unit",time(12h)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_1d ON Kline1d RESAMPLE EVERY 15s FOR 2d
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_1D"
FROM "TopCoinDB"."autogen"."calc_kline_12h"
GROUP BY "exchange", "symbol", "unit",time(1d)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_3d ON Kline3d RESAMPLE EVERY 15s FOR 6d
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_3D"
FROM "TopCoinDB"."autogen"."calc_kline_1D"
GROUP BY "exchange", "symbol", "unit",time(3d)
END;
CREATE CONTINUOUS QUERY cq_calc_kline_1w ON Kline1w RESAMPLE EVERY 15s FOR 2w
BEGIN
SELECT max("high") AS "high", min("low") AS "low", first("open") as open, last("close") as close, first("onlyKey") as "onlyKey", sum("volume") AS "volume",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."calc_kline_1W"
FROM "TopCoinDB"."autogen"."calc_kline_1D"
GROUP BY "exchange", "symbol", "unit",time(1w)
END;
DROP CONTINUOUS QUERY "cq_calc_min_kline" ON "Kline1m";
DROP CONTINUOUS QUERY "cq_calc_kline_3m" ON "Kline3m";
DROP CONTINUOUS QUERY "cq_calc_kline_5m" ON "Kline5m";
DROP CONTINUOUS QUERY "cq_calc_kline_10m" ON "Kline10m";
DROP CONTINUOUS QUERY "cq_calc_kline_15m" ON "Kline15m";
DROP CONTINUOUS QUERY "cq_calc_kline_30m" ON "Kline30m";
DROP CONTINUOUS QUERY "cq_calc_kline_1h" ON "Kline1h";
DROP CONTINUOUS QUERY "cq_calc_kline_2h" ON "Kline2h";
DROP CONTINUOUS QUERY "cq_calc_kline_4h" ON "Kline4h";
DROP CONTINUOUS QUERY "cq_calc_kline_6h" ON "Kline6h";
DROP CONTINUOUS QUERY "cq_calc_kline_12h" ON "Kline12h";
DROP CONTINUOUS QUERY "cq_calc_kline_1d" ON "Kline1d";
DROP CONTINUOUS QUERY "cq_calc_kline_3d" ON "Kline3d";
DROP CONTINUOUS QUERY "cq_calc_kline_7w" ON "Kline1w";
生成无量K线
CREATE CONTINUOUS QUERY calc_no_vol_kline_1m ON Kline1m
RESAMPLE EVERY 5s FOR 2m
BEGIN
SELECT max("last") AS "high", min("last") AS "low",first("last") as open,last("last") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline"
FROM "TopCoinDB"."autogen"."market"
GROUP BY *,time(1m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_3m ON Kline3m
RESAMPLE EVERY 5s FOR 6m
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_3m"
FROM "TopCoinDB"."autogen"."no_vol_kline"
GROUP BY *,time(3m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_5m ON Kline5m
RESAMPLE EVERY 5s FOR 10m
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_5m"
FROM "TopCoinDB"."autogen"."no_vol_kline"
GROUP BY *,time(5m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_10m ON Kline10m
RESAMPLE EVERY 10s FOR 20m
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_10m"
FROM "TopCoinDB"."autogen"."no_vol_kline_5m"
GROUP BY *,time(10m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_15m ON Kline15m
RESAMPLE EVERY 15s FOR 30m
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_15m"
FROM "TopCoinDB"."autogen"."no_vol_kline_5m"
GROUP BY *,time(15m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_30m ON Kline30m
RESAMPLE EVERY 15s FOR 1h
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_30m"
FROM "TopCoinDB"."autogen"."no_vol_kline_15m"
GROUP BY *,time(30m)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_1h ON Kline1h
RESAMPLE EVERY 15s FOR 2h
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_1h"
FROM "TopCoinDB"."autogen"."no_vol_kline_30m"
GROUP BY *,time(1h)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_2h ON Kline2h
RESAMPLE EVERY 15s FOR 4h
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_2h"
FROM "TopCoinDB"."autogen"."no_vol_kline_1h"
GROUP BY *,time(2h)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_4h ON Kline4h
RESAMPLE EVERY 15s FOR 8h
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_4h"
FROM "TopCoinDB"."autogen"."no_vol_kline_2h"
GROUP BY *,time(4h)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_6h ON Kline6h
RESAMPLE EVERY 15s FOR 12h
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_6h"
FROM "TopCoinDB"."autogen"."no_vol_kline_2h"
GROUP BY *,time(6h)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_12h ON Kline12h
RESAMPLE EVERY 15s FOR 1d
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_12h"
FROM "TopCoinDB"."autogen"."no_vol_kline_6h"
GROUP BY *,time(12h)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_1d ON Kline1d
RESAMPLE EVERY 15s FOR 2d
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_1D"
FROM "TopCoinDB"."autogen"."no_vol_kline_12h"
GROUP BY *,time(1d)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_3d ON Kline3d
RESAMPLE EVERY 15s FOR 6d
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_3D"
FROM "TopCoinDB"."autogen"."no_vol_kline_1D"
GROUP BY *,time(3d)
END;
CREATE CONTINUOUS QUERY calc_no_vol_kline_1w ON Kline1w
RESAMPLE EVERY 15s FOR 2w
BEGIN
SELECT max("high") AS "high", min("low") AS "low",first("open") as open,last("close") as close,first("onlyKey") as "onlyKey",last("bRate") as bRate,last("cRate") as cRate
INTO "TopCoinDB"."autogen"."no_vol_kline_1W"
FROM "TopCoinDB"."autogen"."no_vol_kline_1D"
GROUP BY *,time(1w)
END;
DROP CONTINUOUS QUERY "calc_no_vol_kline_1m" ON "Kline1m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_3m" ON "Kline3m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_5m" ON "Kline5m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_10m" ON "Kline10m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_15m" ON "Kline15m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_30m" ON "Kline30m";
DROP CONTINUOUS QUERY "calc_no_vol_kline_1h" ON "Kline1h";
DROP CONTINUOUS QUERY "calc_no_vol_kline_2h" ON "Kline2h";
DROP CONTINUOUS QUERY "calc_no_vol_kline_4h" ON "Kline4h";
DROP CONTINUOUS QUERY "calc_no_vol_kline_6h" ON "Kline6h";
DROP CONTINUOUS QUERY "calc_no_vol_kline_12h" ON "Kline12h";
DROP CONTINUOUS QUERY "calc_no_vol_kline_1d" ON "Kline1d";
DROP CONTINUOUS QUERY "calc_no_vol_kline_3d" ON "Kline3d";
DROP CONTINUOUS QUERY "calc_no_vol_kline_1w" ON "Kline1w";