XS小編, 你好
我編寫以下程式碼,以讀取過去五天代號 2330台積電外資持股張數與持股佔比 :
//=================== TEST外資持股張數比率 =============
//=================== 2025/02/15 =====================
SetBarFreq("D"); // 指定選股腳本只能執行日線的頻率上面
settotalBar(60);
input : _len(5, "追蹤期間");
VAR : FRNshrhold(0); // 每日外資持股張數
VAR : FRNrtihold(0); // 每日外資持股比率
VAR : idx(0);
VAR : strfrnsh(""),strfrnrt(""), strTmp1(""), strTmp2("");
VAR : ifmatch(false);
ifmatch = false;
IF symbol = "2330.TW" then
begin
ifmatch = true;
while idx < _len
Begin
FRNshrhold = Getfield("外資持股","D")[idx];
strTmp1 = text(NumtoStr(FRNshrhold,0));
strfrnsh = strfrnsh + strTmp1 + " / ";
FRNrtihold = GetField("外資持股比例","D")[idx];
strTmp2 = text(NumtoStr(FRNrtihold,2));
strfrnrt = strfrnrt + strTmp2 + " / ";
idx += 1;
End;
end;
if ifmatch then ret =1;
OutputField(1,strfrnsh, "----外資持股五天變化");
OutputField(2,strfrnrt, "----外資持股五天比率");
執行出來結果為:
2/14日 19,094,532張, 2/13日 19,130,762張 ,........。而持股百分比卻為 73.63% / 73.7/73.77/.......
以上結果與個股籌碼分佈2/14日 減持 20,870 張致最新總持張數為 19,049,737張與佔比為 73.46並不完全相符。不知我的程式碼是否有bug, 還是系統有bug。請指正。
輸出檔案如附件。
5 評論