SanSan
SanSan 's avatar

Info

Username:sansand
Name:SanSan
Member since: 20 Jul 2022

About

None

Signature

None

Last Forum Posts

@ProtoHeartbeatEvent:  22 Sep 2022, 16:21


PanagiotisCharalampous said:

Hi sansand,

The server does not send any confirmations for heartbeats. If the connection is not dropped and you keep receiving heartbeats from the server, then it means tou are doing it right.

Best Regards,

Panagiotis 

Join us onTelegram andFacebook

Since the sample https://github.com/spotware/OpenApiPy/tree/main/samples/ConsoleSample does not send a ProtoHeartbeatEvent, do we really need to do it (server keeps sending a heartbeat every 30 sec)? How long until the server drops the connection, if we don't send a ProtoHeartbeatEvent?

@ProtoHeartbeatEvent:  22 Sep 2022, 15:54


Since I can't find anything in the samples, and there's no confirmation back from the server when I send a ProtoHeartbeatEvent, I don't know if I'm doing it right.

I would greatly appreciate an input from the developers or someone that has a working example, how it's supposed to be done.

@ProtoHeartbeatEvent:  20 Sep 2022, 09:31


PanagiotisCharalampous said:

Hi sansand,

I have no idea what is that about and what it is doing :)

Best Regards,

Panagiotis 

Join us onTelegram andFacebook

Ok. So what would be the best way to keep the connection alive by sending a ProtoHeartbeatEvent in 10 second intervals?

Forgot to say that I'm using OpenApiPy.

@ProtoHeartbeatEvent:  20 Sep 2022, 09:26


PanagiotisCharalampous said:

Hi sansand,

Yes server sends heartbeats every 30 seconds.

Best Regards,

Panagiotis 

Join us onTelegram andFacebook

So the " task.LoopingCall " I added is correct?

@ProtoHeartbeatEvent:  19 Sep 2022, 21:00


Point 6 in https://help.ctrader.com/open-api/connection/  "To keep your connections alive, keep sending a ProtoHeartbeatEvent in 10 seconds interval."

In " connected() " I added a twisted.task.LoopingCall

hb = task.LoopingCall(ProtoHeartbeatEvent)
hb.start(10.0)
 

I still only get a ProtoHeartbeatEvent back from the server every 30 seconds though. Is this the correct way to do it?

@How to setup stop loss when opening a Market order:  16 Sep 2022, 21:42


joel+ctrader said:

PanagiotisCharalampous said:

Hi there,

For Marker Orders you need to set the relativeStopLoss. stopPrice is not supported for Market orders.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Okay again thx for pointing me this out. But unfortunately it is not the solution.

I have try the below values, it accept the order, but the SL has not been set.

request.relativeStopLoss = 1000
request.trailingStopLoss = True

Below the output in json format. There you see also the relativeStopLoss has been set, but it is not activated:

{
    'ctidTraderAccountId': '*******',
    'executionType': 'ORDER_ACCEPTED',
    'position': {
        'positionId': '4084654',
        'tradeData': {
            'symbolId': '270',
            'volume': '0',
            'tradeSide': 'SELL',
            'guaranteedStopLoss': False,
            'comment': '*****'
        },
        'positionStatus': 'POSITION_STATUS_CREATED',
        'swap': '0',
        'price': 0.0,
        'commission': '0',
        'marginRate': 0.0,
        'mirroringCommission': '0',
        'guaranteedStopLoss': False,
        'usedMargin': '0',
        'moneyDigits': 2,
        'trailingStopLoss': True
    },
    'order': {
        'orderId': '*****',
        'tradeData': {
            'symbolId': '270',
            'volume': '100',
            'tradeSide': 'SELL',
            'openTimestamp': '1661952264351',
            'guaranteedStopLoss': False,
            'comment': '******'
        },
        'orderType': 'MARKET',
        'orderStatus': 'ORDER_STATUS_ACCEPTED',
        'executedVolume': '0',
        'utcLastUpdateTimestamp': '1661952264351',
        'closingOrder': False,
        'clientOrderId': 'log_id::ea2cff4b-4e57-4d40-8649-a0c7bbb40481',
        'timeInForce': 'IMMEDIATE_OR_CANCEL',
        'positionId': '******',
        'relativeStopLoss': '1000',
        'trailingStopLoss': True
    },
    'isServerEvent': False
}

Below you can see the SL and TSL are not activated.

What els do I have to send to enable the SL?

If you want a 10 point SL, set relativeStopLoss to 10 * 100000

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.