You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- 计算复权数据DROPTABLE IF EXISTS rustdx.qfq_x;
CREATETABLErustdx.qfq_x (
-- 前复权系数
code FixedString(6),
x Float64,
PRIMARY KEY(code)
) ENGINE = MergeTree AS
WITH
qfq AS (
SELECT code, LAST_VALUE(close) / LAST_VALUE(factor) AS qfq_multi
FROMrustdx.factorGROUP BY code
ORDER BY code
)
SELECT*FROM qfq;
-- SELECT * FROM rustdx.qfq_x LIMIT 2;DROPTABLE IF EXISTS rustdx.qfq;
CREATETABLErustdx.qfq (
-- 前复权价格dateDate,
code FixedString(6),
close Float64,
open Float64,
high Float64,
low Float64,
PRIMARY KEY(date, code)
) ENGINE = MergeTree AS
WITH
qfq_x AS (SELECT*FROMrustdx.qfq_x),
fct AS (
SELECTdate, code, open/close AS open, high/close AS high, low/close AS low, factor
FROMrustdx.factor
),
raw AS (
SELECT*FROM fct
LEFT JOIN qfq_x ONqfq_x.code=fct.code
)
SELECTdate, code, factor*x AS close, open*close AS open, high*close AS high, low*close AS low
FROM raw
ORDER BYdate, code
计算后的数据在 rustdx.qfq 表,并且每次运行此脚本时,将原表删除再重建。
The text was updated successfully, but these errors were encountered:
计算后的数据在
rustdx.qfq
表,并且每次运行此脚本时,将原表删除再重建。The text was updated successfully, but these errors were encountered: