#! 获取昨天主板所有股票涨幅排名，取前50股票代码

dt := yesterday();
dt_prev := dt - 1;

stocks := getAbkbyDate('上证A股;深证A股', dt);
n := length(stocks);

gains := array();
for i := 0 to n - 1 do
begin
    setSysParam(PN_Stock(), stocks[i]);
    zf := stockZf(dt_prev, dt);
    gains[i] := array("code": stocks[i], "zf": zf);
end;

top50 := select * from gains
         order by ["zf"] desc
         end;
top50 := select drange(0 to 49) * from top50 end;

echo "昨天(" $ dateToStr(dt) $ ")主板涨幅前50：";
for i := 0 to length(top50) - 1 do
begin
    echo (i + 1) $ ". " $ top50[i]["code"] $ "  涨幅:" $ top50[i]["zf"] $ "%";
end;