Topics
14 Aug 2024, 05:10
 200
 1
14 Aug 2024, 05:10
 261
 6
Replies

siddasaiganesh
08 Sep 2024, 00:59 ( Updated at: 08 Sep 2024, 05:10 )

RE: RE: RE: RE: Training Stop loss

Sorry it's working fine

 


@siddasaiganesh

siddasaiganesh
05 Sep 2024, 22:37 ( Updated at: 07 Sep 2024, 14:24 )

RE: RE: RE: Training Stop loss

PanagiotisCharalampous said: 

siddasaiganesh said: 

PanagiotisCharalampous said: 

Hi there, 

You cannot set a trailing stop loss using FIX API. If you need to set a trailing stop loss, you should use Open API instead.

Best regards,

Panagiotis

Hi Can I get any samples of code having trailing stop loss using this Open API.

You can find Python samples of Open API in the link below

https://github.com/spotware/OpenApiPy

Trailing stop loss is set in ProtoOANewOrderReq.trailingStopLoss property

I tried  trailing stop loss using open API..even I'm setting true for trailing stop loss in a function to place order..it is set to false by default . What to do? Isn't there a way to use trailing stop loss. Is it  a bug for trailing stop loss which is set to by default False even we're assigning it to true or am i not using the same.
This is my implementation part of code where trailingstoploss is used ..Please check..

def sendProtoOANewOrderReq(self, symbolId, orderType, tradeSide, volume, price=None,stopLoss =None, trailingStopLoss=True, clientMsgId=None):
    request = ProtoOANewOrderReq()
    request.ctidTraderAccountId = self.currentAccountId
    request.symbolId = int(symbolId)
    request.orderType = ProtoOAOrderType.Value(orderType.upper())
    request.tradeSide = ProtoOATradeSide.Value(tradeSide.upper())
    request.volume = int(volume) * 100

    if orderType.upper() == "LIMIT":
        request.limitPrice = float(price)
    elif orderType.upper() == "STOP":
        request.stopPrice = float(price)

    if stopLoss:
        request.stopLoss = int(stopLoss)

    #if trailingStopLoss:
       # request.trailingStopLoss = int(trailingStopLoss)

    deferred = self.client.send(request, clientMsgId=clientMsgId)
    deferred.addErrback(self.onError)

def sendNewMarketOrder(self, symbolId, tradeSide, volume,price=None ,stopLoss=None, trailingStopLoss=None, clientMsgId=None):
    self.sendProtoOANewOrderReq(symbolId, "LIMIT", tradeSide, volume,price=price, stopLoss=stopLoss, trailingStopLoss=True, clientMsgId=clientMsgId)
 

def placeOrder(self):
    eurusd_symbol_id = self.symbolIdMap.get("EUR/USD")
    if eurusd_symbol_id:
        #self.sendNewMarketOrder(symbolId=eurusd_symbol_id, tradeSide="BUY", volume=1000)
        self.sendNewMarketOrder(symbolId=eurusd_symbol_id, tradeSide="BUY", volume=1000,price=1.1060,stopLoss=1.1050,trailingStopLoss=True)
    else:
        print("Symbol ID for EUR/USD not found.")

 


@siddasaiganesh

siddasaiganesh
19 Aug 2024, 06:07 ( Updated at: 19 Aug 2024, 07:08 )

RE: Training Stop loss

PanagiotisCharalampous said: 

Hi there, 

You cannot set a trailing stop loss using FIX API. If you need to set a trailing stop loss, you should use Open API instead.

Best regards,

Panagiotis

Hi Can I get any samples of code having trailing stop loss using this Open API.


@siddasaiganesh