請教position=filled 的交易問題

  •   393 
  • 最後發表   石頭  2024 八月 14
石頭 發文於   2024/08/07

 

if filled = 0 and position = 0   and 進場條件 then setposition(2, c)  // 進場單

if position<>0 and  position = filled and  C>停損價  then setposition(0, market);   // 停損單1

在自動交易,現沖賣單 停損單條件寫上 position=filled,

若程式實際上委託單丟2張,實際成交到只有1張

會使得停損單, 因為 position不等於 filled,不會丟停損單?

 

還是只需要寫這樣就可了?

if position<>0  and  C>停損價  then setposition(0, market);   // 停損單2

謝謝回覆。

 

 

排序方式: 標準 | 最新
虎科大許教授 發文於   2024/08/08

送出買進2張限價買單,若只成交1張,停損條件有position=filled,會無法停損。

若設定position<>0且價格碰觸停損價位,就setposition(0,market),則未成交的委託單會被刪單,且庫存會被平倉。

石頭 發文於   2024/08/08

所以保險起見,停損單 不要寫position=filled。

謝謝許教授

XS小編 發文於   2024/08/14

Hello 石頭,

 

當 if position<>0 and  position = filled and  C>停損價  then setposition(0, market); 執行的時候,就會把部位調成0了。

而系統會依據 position 和 filled 來判斷下單的數量,故只要 position 沒有進一步被改變的話,成交一張後還是會繼續下單平倉商品的。

就以上面的案例來說,在兩張市價單的其中一張成交後,另外一張也不會刪掉。

 

關於 position 和 filled 的關係,您可以參考 自動交易語法介紹 裡的說明。

發表回覆
Close