David -
Your file attachments aren’t accepted by this public forum software, but I did have a chance to look at the logs. I see an error in how you’re using the API.
When you tried to cancel-and-replace (XRPLC) the initial stop order, you had an error in syntax. You sent your xreplace order like this:
{
'xreplace' => '131891645',
'gtc' => 1,
'quant' => 700,
'systemid' => 129373845,
'symbol' => 'FBC',
…
all of the above is correct so far. But, unfortunately, the following is an error:
'stoploss' => '29.24',
}
Actually, you should have specified:
'stop' => '29.24'
(notice: not stoploss)
I understand why this is confusing, but let me try to explain the variations of the terminology from a higher-level perspective.
When you first submit an OPENING order to C2 – one which will create a position – you specify the opening signal parameters such as action: BTO or STO (or SSHORT).
You also specify the order type – i.e. is the order a ‘stop’, ‘limit’, or ‘market’ order?
Now, whenever you want to XREPLACE an order that is a STOP order, you specify a new ‘stop’ price.
Okay, then… what is ‘stoploss’?
Well, ‘stoploss’ is a convenience parameter provided by the API that lets you ALSO specify a stop loss that hangs off your entry order. Any ‘stoploss’ you specify will itself become a ‘stop’ type of order, but note that the entry order itself can also be a ‘stop.’
In other words, it’s conceivable that you can enter a position using a STOP order, and then once that position is created, it can itself have a stoploss. An example of this might be:
{
action => 'BTO',
stop => 100.12,
stoploss => 90.01,
…
}
Notice the excerpt above has BOTH a ‘stop’ (telling C2 the entry order itself is a ‘stop’ order; i.e. you want to buy when the price crosses above 100.12) and an associated ‘stoploss’ (telling C2: "Hey, create another STOP order conditional upon the entry; this conditional order will be Sell Stop 90.01).
If I want to xreplace either of the two orders that results from the command above (i.e. either the Buy @ Stop 100.12; or the Sell @ Stop 90.01) I need to specify a ‘stop’ parameter when I issue my xreplace. That is because each of these orders already has a ‘stop’ price. Once the stop is set, you can XREPLACE it by specifying a new ‘stop’ parameter.
TLDR: use ‘stoploss’ in the initial entry signal to set an exit-order-stop-loss. Any subsequent XRPLC changes of either the entry or the conditional exit should use ‘stop’.