Training Stop loss
Training Stop loss
14 Aug 2024, 05:10
Hi ,Can I use trailing stop loss programmatically (Python preferably). If yes , can you please walk me through ,how?
Thanks in advance
Replies
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
PanagiotisCharalampous
19 Aug 2024, 12:09
RE: RE: Training Stop loss
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
@PanagiotisCharalampous
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
PanagiotisCharalampous
06 Sep 2024, 05:23
RE: RE: RE: RE: Training Stop loss
siddasaiganesh said:
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 using trailing stop loss using open API..even I'm setting true for trailing stop loss in a function to place order..it is by default setting to False. What to do? Isn't there a way to use trailing stop loss. I have also seen some online posts about open API that it has a bug for trailing stop loss which is set to by default False even we're assigning it to true.
Hi there,
Can you share the posts you are referring too?
Best regards,
Panagiotis
@PanagiotisCharalampous
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
PanagiotisCharalampous
14 Aug 2024, 10:17
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
@PanagiotisCharalampous