Maspear / jbooktrader

Automatically exported from code.google.com/p/jbooktrader
0 stars 0 forks source link

Enable catastrophic stop loss #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
There should be a way to set a stop loss order every time the position 
changes. It would serve as a protection against events such as loss of 
power, ISP failures, etc.

Original issue reported on code.google.com by eugene.k...@gmail.com on 23 Feb 2008 at 5:31

GoogleCodeExporter commented 9 years ago
What's about something like :

int currentPosition = getPositionManager().getPosition();
double lastEntry = getPositionManager().getAvgFillPrice();

if(currentPosition <= 0 && ...) {
  cancelAllStops();
  setPosition(1);
  setStopSell(lastEntry - 5);
}
if(currentPosition >= 0 && ...) {
  cancelAllStops();
  setPosition(-1);
  setStopBuy(lastEntry + 5);
}

Original comment by Robertde...@gmail.com on 25 May 2008 at 11:58

GoogleCodeExporter commented 9 years ago
Yes, something like that, although it's probably better to handle it with the 
"One
cancels others" type of order:
http://individuals.interactivebrokers.com/en/trading/orders/oca.php

Original comment by eugene.k...@gmail.com on 25 May 2008 at 9:38

GoogleCodeExporter commented 9 years ago

Original comment by eugene.k...@gmail.com on 29 Aug 2008 at 2:41