Yes, this looks right. After the rejected order is handled, you may want to
disable the corresponding strategy so that it doesn't endlessly submit
orders. Better yet, configure JBT so that it doesn't trade too close to the
margin limits.
On Monday, April 22, 2013 4:39:23 AM UTC-4, Borg Alexander wrote:
>
> There are several reasons for order rejection by IB, the most common being
> 'margin requirements not met'. So if you have an account of $10000 and want
> to buy 10 ES contracts, you most probably will get this error.
>
> JBookTrader will not execute any more orders after encoutering this error.
> So if you have an open position from Startegy A and encounter this error
> when Strategy B attempts to open a position, the position of Strategy A
> will never be closed throughout the whole session.
>
> For the time being, I have replaced line 166 of Trader.java by
>
> *if* (errorCode == 202 || errorCode == 201) { // Order Canceled/Rejected
>
> This means that the condition 'order rejected' is handled the same way as
> 'order cancelled'.
>
> I tested it this morning with my simulation account with the following
> result:
>
> Strategy A opens a position with 1 contract.
> Strategy B attempts to open a position with 50 contracts and gets error
> 201 because of insufficient margin.
> Strategy B attempts to open this position every second as long as the
> condition for opening a position for Strategy B is met, and always gets the
> error 201.
> Strategy A closes its position.
> Strategy B ceases attempting to open a position as soon as the condition
> for opening a position for Strategy B is not met anymore.
>
> Probably there is a better solution to handle this condition but this one
> at least avoids knockout of JBookTrader.
>
--
You received this message because you are subscribed to the Google Groups
"JBookTrader" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/jbooktrader?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.