請問SetPosition的問題,反向單的寫法

  •   85 
  • 最後發表   帥哥元  2022 五月 05
帥哥元 發文於   2022/05/01

請問一下小幫手,關於反向單的寫法

if 條件成立 and Position = 0 then SetPosition(1);

if 條件成立 and Filled = 1 then SetPosition(-1);

這樣的寫法是對的嗎? 從多單直接轉空單

排序方式: 標準 | 最新
XQ小幫手 發文於   2022/05/05

Hello 帥哥元,

 

是的,您可以這樣寫沒錯。

不過 if 條件成立 and Filled = 1 then SetPosition(-1); 這樣在條件成立且庫存為1的時候會持續確認是否要下單。

小幫手會建議您可以這樣寫:

if 條件成立 and Filled = 1 and position = 1 then SetPosition(-1);

這樣就只會在條件符合時且部位庫存皆為1的時候下單,下單後就算沒有馬上成交,部位也會變成-1不再觸發這個SetPosition。

帥哥元 發文於   2022/05/05

了解,謝謝小幫手,因為我是用IOC,所以,就沒寫 position = 1 了

發表回覆
Close