Dear 大大
請問 為何此XS程式得到的 資料 有誤 (可以看1101的"月漲"幅數據)


// XS 近13個月漲幅據看板 (含上市日期自動過濾)
// 支援欄位:漲幅(%)、成交量(張)、成交額(億)
Var: ListDate(0);
ListDate = GetField("公司掛牌日期"); // 取得公司上市日期 (YYYYMMDD) [1]
// ret = 1 確保列出全市場所有股票 [2]
ret = 1;
// ============================================================
// 處理邏輯:i 代表月份偏移量 (0=本月, 1=上月,..., 12=上12月)
// 每個區塊必須確保 GetFieldDate[i] 與 GetField[i] 的索引一致
// ============================================================
// --- 本月 (0) ---
if GetFieldDate("收盤價", "M") >= ListDate then begin
OutputField1(GetField("漲跌幅", "M", Adjusted:=true), 1, "本月漲幅%");
OutputField21(GetField("成交量", "M"), 0, "本月量");
OutputField41(GetField("成交金額(億)", "M"), 2, "本月額(億)");
end;
// --- 上 1 月 (1) ---
if GetFieldDate("收盤價", "M")[3] >= ListDate and GetFieldDate("收盤價", "M")[3] > 0 then begin
OutputField2(GetField("漲跌幅", "M", Adjusted:=true)[3], 1, "上1月漲幅%");
OutputField22(GetField("成交量", "M")[3], 0, "上1月量");
OutputField42(GetField("成交金額(億)", "M")[3], 2, "上1月額(億)");
end;
// --- 上 2 月 (2) ---
if GetFieldDate("收盤價", "M") >= ListDate and GetFieldDate("收盤價", "M") > 0 then begin
OutputField3(GetField("漲跌幅", "M", Adjusted:=true), 1, "上2月漲幅%");
OutputField23(GetField("成交量", "M"), 0, "上2月量");
OutputField43(GetField("成交金額(億)", "M"), 2, "上2月額(億)");
end;
// --- 上 3 月 (3) ---
if GetFieldDate("收盤價", "M")[5] >= ListDate and GetFieldDate("收盤價", "M")[5] > 0 then begin
OutputField4(GetField("漲跌幅", "M", Adjusted:=true)[5], 1, "上3月漲幅%");
OutputField24(GetField("成交量", "M")[5], 0, "上3月量");
OutputField44(GetField("成交金額(億)", "M")[5], 2, "上3月額(億)");
end;
// --- 上 4 月 (4) ---
if GetFieldDate("收盤價", "M")[6] >= ListDate and GetFieldDate("收盤價", "M")[6] > 0 then begin
OutputField5(GetField("漲跌幅", "M", Adjusted:=true)[6], 1, "上4月漲幅%");
OutputField25(GetField("成交量", "M")[6], 0, "上4月量");
OutputField45(GetField("成交金額(億)", "M")[6], 2, "上4月額(億)");
end;


2 評論