Topics
01 Mar 2024, 09:18
 424
 9
Replies

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

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

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

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

jan.schmid
01 Mar 2024, 09:33 ( Updated at: 01 Mar 2024, 11:58 )

Fixed it

The problem was that i used the password from the account and not the password from the actual trading account. Where you can change there


@jan.schmid