The opinions expressed in these forums do not represent those of C2, and any discussion of profit/loss is not indicative of future performance or success. There is a substantial risk of loss in trading. You should therefore carefully consider whether such trading is suitable for you in light of your financial condition. You should read, understand, and consider the Risk Disclosure Statement that is provided by your broker before you consider trading. Most people who trade lose money.

API: XReplace to update a stoploss

Once a week I issue several BTO orders in the premarket period with associated signal.stoploss levels. These are relatively wide stops. I then wait until after the market opens, look at the live market price and send another signal with signal.action=“STC”, signal.xreplace= and signal.stoploss=. Is this correct?

After done, I am seeing this listing:
C2_Stoploss

The first line is my original BTO.

The second line is my earlier wide stop loss that I used XReplace to cancel. This appears to have been correctly canceled.

Are the 3rd and 4th lines the correct setup for a replaced stoploss? I would have expected to only see one line representing the STC at my new stoploss level of the original BTO order.

Thank you

I assume what you are trying to do here is:

  1. You use the Signal API to place an initial “bracket order” before the market opens. This bracket order contains an entry (Buy at market) and two associated orders: one a profit target (i.e. sell at limit) and one a stop loss (sell at stop).

  2. After the market opens, you want to adjust your stop loss with a new stop-loss price. You use the Signal API to issue a cancel-and-replace (xreplace).

If my assumptions above are correct, then I see a small error in the way you used the API to issue the XRPLC.

When you attempted to xreplace your stop, you sent:

    'gtc' => 1,
    'xreplace' => 131640089,
    'gtc' => 1,
    'quant' => 900,
    'systemid' => 129373845,
    'symbol' => 'EGO',
    'stoploss' => '11.09',

     ...

but also:

'market' => 1

And that is a problem.

If you want to issue a new signal in place of signal id 131640089 (which was a stop order), and if you want your new signal also to be a stop loss, then set market = 0.

In other words, you should either:

  • set market =1 (i.e. a market order)
    OR
  • set stoploss = non-zero value and market=0 (a stop-loss order)

When C2 sees your “market=1” it ignores your stop-loss price. That’s why your stop effectively disappeared and became a market order.

Hope this helps.

Hi Matthew,

Following up on my earlier request for help, I have made some changes, but I am unsure when I look at the listing below if things are correct:

image001.png

I have attached the request all Trades Overview, plus JSONs that reflect:

  • The BTO POST for the initial BTO order

  • The Reply to the BTO POST

  • The XReplace POST for the new stop loss

  • The Reply to the XReplace POST

Can you comment on whether I am correctly set up for a TS at 29.24?

Thank you,

David

(Attachment C2_Reply_US_WQ_C2_requestAllTrades_overview.json is missing)

(Attachment C2_REPLY_US_WQ_C2_FBC_XReplace_131891645.json is missing)

(Attachment C2_PAYLOAD_US_WQ_C2_FBC_XReplace_131891645.json is missing)

(Attachment C2_PAYLOAD_US_WQ_C2_FBC_BTO_131891644.json is missing)

(Attachment C2_REPLY_US_WQ_C2_FBC_BTO_131891644.json is missing)

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’.

Thanks Matthew,

I will make this change and report back - hopefully with success - after my next round of orders next week.

David

Back to C2 Platform