我寫了個小台全日盤的交易策略,並在第一段判斷就設了時間到平倉的判斷:
var: hasPosition(false);
hasPosition = position <> 0 and filled <> 0 and filledAvgPrice > 0;
if hasPosition and (time = 134400 or currentTime = 134400) then begin
setPosition(0, market);
end;
實際上 13:44:00 卻沒有平倉,導致倉位留到夜盤。
但 13:44:00 的 print 紀錄裡卻有平倉紀錄,不明白為什麼沒有執行:
2022/07/18 10:21:00 | 建倉 | 交易方向: 作空 | 操作口數: 1
2022/07/18 13:44:00 | 平倉 | 交易方向: 作空 | 操作口數: 1 | 成本均價: 14637 | 出場均價: 14649
請問台指期全日盤在日盤收盤前平倉的寫法跟一般股票部位平倉寫法不同嗎?如何寫才能確保部位順利平倉呢?
10 評論