等级: 免费版
- 注册:
- 2021-9-28
- 曾用名:
|

楼主 |
发表于 2022-2-25 17:27
|
显示全部楼层
问题:40个品种回测,分配等值的资金,比如1000000元(每个品种),fund:=1000000, fund_double:=0.1(表示放大10倍保证金),当fund<5时,表示5手以内按实际手数算,5-100之间按 百分比lots%算,100以上计算放大的资金量的所能开的手数,问题时如果后复权后,以前价格完全变量,导致资金手数计算开仓数据会很大,测试会不准,如何解决? 见如下代码:
if holding =0 and (kd and direction>=0 or kk and direction<=0) then
begin
if fund <= 100 then //only 1 part or lots% case, don't need to be divided into NDAY_hold part
lots:= intpart(fund);
else // fund > 100 => calc the amount of stock
lots:= max(1,intpart(fund / (open*MULTIPLIER*fund_double) ) );
if fund < 5 or fund > 100 then
begin
buy(kd,lots,market);
buyshort(kk,lots,market);
end;
else
begin
buy(kd,lots%,market);
buyshort(kk,lots%,market);
end;
end; |
|