自動交易中心回測,可否模擬策略整體安控?
目前回測只有單一商品安控無策略整體,
XS如何編寫安控策略整體這三部分?
進場金額上限
最大部位限制
最多持有商品
及
控制進場時間
 
        
        自動交易中心回測,可否模擬策略整體安控?
目前回測只有單一商品安控無策略整體,
XS如何編寫安控策略整體這三部分?
進場金額上限
最大部位限制
最多持有商品
及
控制進場時間
自動交易中心的安控與自動交易有關,與回測無關。
恩恩
1. 希望能編輯XS,來安控所述策略整體的三個地方
2. 因希望用回測來"模擬實際自動交易時的狀況",而不是有符合就交易
以下的程式碼,策略管控是否正確 合適?
input: 
ITS(090002,"進場時間"),
STP(103000,"停止委託"),
PL(50,"低價位"),
PH(400,"高價位"),
INC(1.02,"獲利%"),
MaxAmount(500000,"進場金額上限"),
MaxOrders(4,"最大委買部位"),
MaxHoldings(3,"最大持有成交商品");
// 內外盤進場訊號
condition1= GetField("外盤量", "1") cross Over GetField("內盤量", "1");
// 追蹤目前持有商品數量和委買部位
vars: numHoldings(0), numOrders(0), currentAmount(0);
numHoldings = CountIf(position > 0, 1);
numOrders = CountIf(position = 0 and Filled = 0, 1);
currentAmount = close * position;
if
position = 0
and Filled = 0
and currentTime > ITS
and currentTime < STP
and close >= PL
and close <= PH
and condition1 //轉外盤較強金叉
and numOrders < MaxOrders // 檢查最大委買部位
and numHoldings < MaxHoldings // 檢查最大持有成交商品
and currentAmount + close <= MaxAmount // 檢查進場金額上限
then
setposition (maxList(position + 1, 1), getField("收盤價", "Tick"), label := "買進");
if
position > 0
and Filled > 0
and getField("收盤價", "Tick") > FilledAvgPrice * INC
then
setposition (minList(position - 1, 0), getField("收盤價", "Tick"), label := "賣出");
 程式碼B,或者這個可行嗎?
input: 
ITS(090002,"進場時間"),
STP(103000,"停止委託"),
PL(50,"低價位"),
PH(400,"高價位"),
INC(1.02,"獲利%"),
MaxAmount(500000,"進場金額上限"),
MaxOrders(4,"最大委買部位"),
MaxHoldings(3,"最大持有成交商品");
// 內外盤進場訊號
condition1 = GetField("外盤量", "1") cross Over GetField("內盤量", "1");
// 追蹤目前持有商品數量和委買部位
vars: i(0),numHoldings(0), numOrders(0), currentAmount(0);
vars: totalPosition(0), totalFilled(0), totalAmount(0);
// 計算目前的持有部位和委買部位
totalPosition = 0;
totalFilled = 0;
totalAmount = 0;
// 假設這裡的 i 是循環的商品索引
for i = 1 to 10 begin
if position[i] > 0 then
totalPosition = totalPosition + 1;
if Filled[i] = 0 then
totalFilled = totalFilled + 1;
totalAmount = totalAmount + close[i] * position[i];
end;
numHoldings = totalPosition;
numOrders = totalFilled;
currentAmount = totalAmount;
if
position = 0
and Filled = 0
and currentTime > ITS
and currentTime < STP
and close >= PL
and close <= PH
and condition1 // 轉外盤較強金叉
and numOrders < MaxOrders // 檢查最大委買部位
and numHoldings < MaxHoldings // 檢查最大持有成交商品
and currentAmount + close <= MaxAmount // 檢查進場金額上限
then
setposition (maxList(position + 1, 1), getField("收盤價", "Tick"), label := "買進");
if
position > 0
and Filled > 0
and getField("收盤價", "Tick") > FilledAvgPrice * INC
then
setposition (minList(position - 1, 0), getField("收盤價", "Tick"), label := "賣出");
程式碼A,確定無效!
在沒有全域變數之前,XS無法處理整體策略部位。
恩恩
想像期待的未來是美好的! 等待~
分享壁紙股的拋棄
有壁紙股,XQ自動交易中心,總是會讀取兩個同樣的商品但不同部位,為避免再發生執行錯誤,只好去辦理拋棄,才知道,部門明明知道早已經不存在,解散並已消滅的公司,但還是得寄存證信函,
到一個沒有該公司存在的收件地址(如果是寄給自然人,還能理解之必要)
這就是~程序! 腦袋瓜很難理解這樣的做法
7 評論