如何使用XS選股腳本撰寫"某段時間內,變化沒有超過10%"?
以下使用【每股營業額】與【營業利益】的資料為範例說明,
設定【某段時間內,變化沒有超過10%】來挑選股票商品,
程式碼範例如下:
input:
Length_Credit(1),
Length_interest(1),
Range_Credit(0.1),
Range_interest(0.1);
setinputname(1, "前幾期的每股營業額(元)");
setinputname(2, "前幾期的營業利益");
setinputname(3, "前一期的營業額乘以多少");
setinputname(4, "前一期的營業利益乘以多少");
settotalbar(maxlist(Length_Credit, Length_interest, 10));
condition1 =
GetField("每股營業額(元)")[Length_Credit] * (1+Range_Credit) >= GetField("每股營業額(元)")
and
GetField("每股營業額(元)") >= GetField("每股營業額(元)")[Length_Credit] * Range_Credit;
condition2 =
GetField("營業利益")[Length_interest] * (1+Range_interest) >= GetField("營業利益")
and
GetField("營業利益") >= GetField("營業利益")[Length_interest] * Range_interest;
if condition1 and condition2 then ret = 1;
以上,提供給大家參考。