input:
monthCount(36, "統計月份"),
minScore(5, "通過門檻項目數");
Vars:
revenueNow(0), epsNow(0), grossNow(0), opNow(0),
netNow(0), roaNow(0), roeNow(0),
revenueHistoryHigh(false), revenueSamePeriodHigh(true),
epsHistoryHigh(false), epsSamePeriodHigh(true),
grossHistoryHigh(false), grossSamePeriodHigh(true),
opHistoryHigh(false), opSamePeriodHigh(true),
netHistoryHigh(false), netSamePeriodHigh(true),
roaHistoryHigh(false), roaSamePeriodHigh(true),
roeHistoryHigh(false), roeSamePeriodHigh(true),
score(0), i(0),
realMonthCount(0), realQuarterCount(0),
tempVal(0),
quitLoop(false),
maxMonthDataCount(0),
maxQuarterDataCount(0);
// 預設最大資料長度
maxMonthDataCount = monthCount;
maxQuarterDataCount = monthCount / 3;
// 計算有效月資料長度,遇到0或無資料停止計數
realMonthCount = 0;
quitLoop = false;
for i = 0 to maxMonthDataCount - 1 begin
if quitLoop then break;
tempVal = GetField("月營收", "M")[i];
if tempVal > 0 then
realMonthCount += 1
else
quitLoop = true;
end;
// 計算有效季資料長度,遇到0或無資料停止計數
realQuarterCount = 0;
quitLoop = false;
for i = 0 to maxQuarterDataCount - 1 begin
if quitLoop then break;
tempVal = GetField("EPS", "Q")[i];
if tempVal > 0 then
realQuarterCount += 1
else
quitLoop = true;
end;
// 若有效資料比設定少,使用有效資料數
maxMonthDataCount = realMonthCount;
maxQuarterDataCount = realQuarterCount;
// 取得最新資料 (index 0 是最新)
revenueNow = GetField("月營收", "M");
epsNow = GetField("EPS", "Q");
grossNow = GetField("營業毛利率", "Q");
opNow = GetField("營業利益率", "Q");
netNow = GetField("稅後淨利率", "Q");
roaNow = GetField("資產報酬率", "Q");
roeNow = GetField("股東權益報酬率", "Q");
// 歷史新高判斷 (需至少3筆資料)
if maxMonthDataCount >= 3 then
revenueHistoryHigh = (revenueNow >= Highest(GetField("月營收", "M"), maxMonthDataCount))
else
revenueHistoryHigh = false;
if maxQuarterDataCount >= 3 then begin
epsHistoryHigh = (epsNow >= Highest(GetField("EPS", "Q"), maxQuarterDataCount));
grossHistoryHigh = (grossNow >= Highest(GetField("營業毛利率", "Q"), maxQuarterDataCount));
opHistoryHigh = (opNow >= Highest(GetField("營業利益率", "Q"), maxQuarterDataCount));
netHistoryHigh = (netNow >= Highest(GetField("稅後淨利率", "Q"), maxQuarterDataCount));
roaHistoryHigh = (roaNow >= Highest(GetField("資產報酬率", "Q"), maxQuarterDataCount));
roeHistoryHigh = (roeNow >= Highest(GetField("股東權益報酬率", "Q"), maxQuarterDataCount));
end else begin
epsHistoryHigh = false;
grossHistoryHigh = false;
opHistoryHigh = false;
netHistoryHigh = false;
roaHistoryHigh = false;
roeHistoryHigh = false;
end;
// 同期新高判斷(非歷史高時且有足夠資料才判斷)
// 月營收同期新高:需有13筆以上資料,且從12期開始比
if (not revenueHistoryHigh) and (maxMonthDataCount >= 13) then begin
revenueSamePeriodHigh = true;
for i = 12 to maxMonthDataCount - 1 begin
if GetField("月營收", "M")[i] >= revenueNow then
revenueSamePeriodHigh = false;
end;
end else
revenueSamePeriodHigh = revenueHistoryHigh;
3 評論