COCO研究院

 找回密碼
 註冊
搜索
查看: 2029|回復: 5

[新手問題] backtesting setting 問題

[複製鏈接]
發表於 13-11-3 16:07 | 顯示全部樓層 |閱讀模式
請問如何set指數期貨每點價值?
例如我玩恒指期貨, 如何set1點50元
看過AB簡介, 但依書方法設定完後也不行
不知哪裡出了問題
謝謝!!
發表於 13-11-3 22:54 | 顯示全部樓層
Set PointValue in Information window.
or in AFL code set variable Pointvalue = ...;

Additionally activate futures mode in backtest settings
Or via code SetOption( "FuturesMode", True);
 樓主| 發表於 13-11-3 23:33 | 顯示全部樓層
本帖最後由 jacklcl 於 13-11-3 23:35 編輯
joshsmi 發表於 13-11-3 22:54
Set PointValue in Information window.
or in AFL code set variable Pointvalue = ...;

Hi joshsmi, thanks for your help
i just followed your suggestion and set the point value to HK$50
after running the backtest, i discovered that the PnL was calcuated based on the % change of the future price multiply by the equity and the point value
e.g. buy price @ 22968 and sell @ 22982
then this trade suffered a loss of 14 points which equal to HK$ 700 (14 x HK$50)
but in AB, the calculation is as follows:
from 22982 to 22968, the % change is 0.06%
then it applied this 0.06% to my equity (say HK$ 100,000) which is 60
and then it used this 60 multiply by the point value which the loss is HK$3000 in the bactest result

發表於 13-11-4 04:06 | 顯示全部樓層
Look here it is calculated the way it should be.


So probably you seem to be doing something wrong. Obviously you haven't set a position size.
發表於 13-11-4 04:15 | 顯示全部樓層
本帖最後由 joshsmi 於 13-11-4 04:17 編輯

if you need to use variable margin calaculation then you need to add custom backtest procedure.
www.amibroker.com/guide/a_custombacktest.html
http://www.amibroker.org/userkb/ ... tester-interface-2/

The following calculation is just an example and not related to Hang Seng

//Start of Custom Backtest Interface
SetCustomBacktestProc("");         

if ( Status( "action" ) == actionPortfolio )
{
    bo = GetBacktesterObject();
    bo.preProcess();

    for ( bar = 0; bar < BarCount; bar ++ )
    {
        for ( sig = bo.GetFirstSignal( bar ); sig ; sig = bo.GetNextSignal( bar ) )
        {
            if ( sig.isEntry() )
                sig.MarginDeposit = sig.Price * sig.Pointvalue / Leverage; // calculate margin to be used
        }
        bo.ProcessTradeSignals( bar );
    }
    bo.postProcess();   
}
 樓主| 發表於 13-11-4 09:51 | 顯示全部樓層
joshsmi 發表於 13-11-4 04:15
if you need to use variable margin calaculation then you need to add custom backtest procedure.
www. ...

Thank you!
you are so nice ^^
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-11-23 08:08

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 |