Order ID Not found

Created at 01 Mar 2024, 09:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
JA

jan.schmid

Joined 19.02.2024

Order ID Not found
01 Mar 2024, 09:18


Hello, so i try to close a position via FIX API with the call “OrderCancelRequest”. if i try to send this cancel reqeust i get the answer

Received:  8=FIX.4.4|9=157|35=j|34=2|49=cServer|50=TRADE|52=20240301-09:07:43.458|56=demo.ctrader.4136405|57=TRADE|58=ORDER_NOT_FOUND:Order with clientOrderId=B not found.|379=B|380=0|10=206|

But if i try to get the status with “OrderStatusRequest” then i get following answer

Received:  8=FIX.4.4|9=210|35=8|34=3|49=cServer|50=TRADE|52=20240301-09:07:43.487|56=demo.ctrader.4136405|57=TRADE|6=1893.55|11=B|14=1|32=0|37=126764977|38=1|39=2|40=1|54=1|55=22312|59=3|60=20240301-07:40:19.925|150=F|151=0|721=71037805|10=162|

so the api can find my positon to get the status but not to delete it?

 


@jan.schmid
Replies

PanagiotisCharalampous
01 Mar 2024, 12:10

Hi there,

Please share the messages you sent as well

Best regards,


@PanagiotisCharalampous

jan.schmid
01 Mar 2024, 13:01

I use these python funktions with the classes from ctrader.

def closerfunktion(client):
    closer = OrderCancelRequest(config)
    closer.OrigClOrdID = "D"
    closer.ClOrdID = "D"
    client.send(closer)


def getStatus(client):
    status = OrderStatusRequest(config)
    status.ClOrdID = "D" #15678945
    client.send(status)
   
def order(client):
    order = NewOrderSingle(config)
    order.ClOrdID = "D"                 # Eindeutige Bestell-ID
    order.Symbol = con.symbolID             # Symbol für Gold (XAUUSD,22312)
    order.Side = var.orderSide              # 1 für Kauf (buy), 2 für Verkauf (sell)
    order.OrderQty = var.quantity           # Handelsgröße (1 Unze Gold)
    order.OrdType = "1"                     # 1 für Market-Order
    client.send(order)
    print("Order Send")

I tried to print the messages I send but i havent found the right code to print it properly :(


@jan.schmid

PanagiotisCharalampous
02 Mar 2024, 07:24

It's hard to help you without the actual FIX messages


@PanagiotisCharalampous

jan.schmid
04 Mar 2024, 07:33

8=FIX.4.4|9=134|35=D|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:30:09|11=D|55=22312|54=1|60=20240304-07:30:09|38=1|40=1|10=178|

So this is my message to buy a position.

and this is my try so close the position

8=FIX.4.4|9=94|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:31:56|41=D|11=D|10=069|

@jan.schmid

PanagiotisCharalampous
04 Mar 2024, 13:58

So the message you get is correct. You are trying to cancel an order with ID. This is not a valid order id

 


@PanagiotisCharalampous

jan.schmid
04 Mar 2024, 14:15 ( Updated at: 05 Mar 2024, 06:49 )

RE: Order ID Not found

PanagiotisCharalampous said: 

So the message you get is correct. You are trying to cancel an order with ID. This is not a valid order id

 

so This is my order and i use the Order ID for the Cancel Request.

8=FIX.4.4|9=116|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-14:06:15|41=OID127198522|11=OID127199999|10=088|
8=FIX.4.4|9=110|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240305-06:45:59|41=127198522|11=127199999|10=167|

I tried these Fix messages with the OrderCancelRequest() function. And the following are my Responses.

8=FIX.4.4|9=179|35=j|34=2|49=cServer|50=TRADE|52=20240304-14:06:15.263|56=demo.ctrader.4136405|57=TRADE|58=ORDER_NOT_FOUND:Order with clientOrderId=OID127198522 not found.|379=OID127199999|380=0|10=186|

8=FIX.4.4|9=173|35=j|34=2|49=cServer|50=TRADE|52=20240305-06:45:59.088|56=demo.ctrader.4136405|57=TRADE|58=ORDER_NOT_FOUND:Order with clientOrderId=127198522 not found.|379=127199999|380=0|10=014|

It's a Order ID made by ctrader so why does it dont want to work?


@jan.schmid

ctid1980098
05 Mar 2024, 11:09 ( Updated at: 05 Mar 2024, 11:12 )

RE: Order ID Not found

jan.schmid said: 

8=FIX.4.4|9=134|35=D|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:30:09|11=D|55=22312|54=1|60=20240304-07:30:09|38=1|40=1|10=178|

So this is my message to buy a position.

and this is my try so close the position

8=FIX.4.4|9=94|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:31:56|41=D|11=D|10=069|

Hi. You opened a position using “35=D” (buy position) and cannot close this position with “35=F” as 35=F is only for orders( like pending orders and not for opened positions). To close your position you need to use “35=D” again to close. So you will need to close your buy position with a corresponding sell position. So to close your position it should look something like this…i think: 

8=FIX.4.4|9=?|35=D|34=?|49=demo.ctrader.4136405|56=CSERVER|57=TRADE|50=TRADE|11=D|55=22312|54=2|60=?|38=1|40=1|721={id_of_your_buy_position}|10=?|

You can only close your buy position with a corresponding sell market order. You cannot use tag “35=F” here. Take note 54=2 (sell to close position). Hope it helps


@ctid1980098

jan.schmid
05 Mar 2024, 12:34

RE: RE: Order ID Not found

ctid1980098 said: 

jan.schmid said: 

8=FIX.4.4|9=134|35=D|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:30:09|11=D|55=22312|54=1|60=20240304-07:30:09|38=1|40=1|10=178|

So this is my message to buy a position.

and this is my try so close the position

8=FIX.4.4|9=94|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:31:56|41=D|11=D|10=069|

Hi. You opened a position using “35=D” (buy position) and cannot close this position with “35=F” as 35=F is only for orders( like pending orders and not for opened positions). To close your position you need to use “35=D” again to close. So you will need to close your buy position with a corresponding sell position. So to close your position it should look something like this…i think: 

8=FIX.4.4|9=?|35=D|34=?|49=demo.ctrader.4136405|56=CSERVER|57=TRADE|50=TRADE|11=D|55=22312|54=2|60=?|38=1|40=1|721={id_of_your_buy_position}|10=?|

You can only close your buy position with a corresponding sell market order. You cannot use tag “35=F” here. Take note 54=2 (sell to close position). Hope it helps

Appreciate it my code worked perfectly now :)


@jan.schmid

ctid1980098
05 Mar 2024, 12:39

RE: RE: RE: Order ID Not found

jan.schmid said: 

ctid1980098 said: 

jan.schmid said: 

8=FIX.4.4|9=134|35=D|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:30:09|11=D|55=22312|54=1|60=20240304-07:30:09|38=1|40=1|10=178|

So this is my message to buy a position.

and this is my try so close the position

8=FIX.4.4|9=94|35=F|49=demo.ctrader.4136405|56=cServer|57=TRADE|50=TRADE|34=1|52=20240304-07:31:56|41=D|11=D|10=069|

Hi. You opened a position using “35=D” (buy position) and cannot close this position with “35=F” as 35=F is only for orders( like pending orders and not for opened positions). To close your position you need to use “35=D” again to close. So you will need to close your buy position with a corresponding sell position. So to close your position it should look something like this…i think: 

8=FIX.4.4|9=?|35=D|34=?|49=demo.ctrader.4136405|56=CSERVER|57=TRADE|50=TRADE|11=D|55=22312|54=2|60=?|38=1|40=1|721={id_of_your_buy_position}|10=?|

You can only close your buy position with a corresponding sell market order. You cannot use tag “35=F” here. Take note 54=2 (sell to close position). Hope it helps

Appreciate it my code worked perfectly now :)

Glad it worked. ;)


@ctid1980098