ProtoOASpotEvent().payloadType, and ProtoOASubscribeLiveTrendbarReq

Created at 11 Jul 2023, 20:05
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!
JO

jon.slater

Joined 26.01.2023

ProtoOASpotEvent().payloadType, and ProtoOASubscribeLiveTrendbarReq
11 Jul 2023, 20:05


Hello,

I use ProtoOAGetTrendbarsReq, and it works perfectly. I get all the candles. I use:

def transformTrendbar(trendbar):
    openTime = int(trendbar.utcTimestampInMinutes * 60 * 1000)
    # openTime = datetime.datetime.fromtimestamp(trendbar.utcTimestampInMinutes * 60, datetime.timezone.utc)
    openPrice = (trendbar.low + trendbar.deltaOpen) / 100000.0
    highPrice = (trendbar.low + trendbar.deltaHigh) / 100000.0
    lowPrice = trendbar.low / 100000.0
    closePrice = (trendbar.low + trendbar.deltaClose) / 100000.0
    return [openTime, openPrice, highPrice, lowPrice, closePrice, trendbar.volume]

 

Now, I use:

ProtoOASubscribeLiveTrendbarReq

but I'm still using 

transformTrendbar

.. and I see the candles are wrong.

The question is: how do I create the live candles correcty? I am also looking at:

ProtoOASpotEvent().payloadType:

I guess the question is: how do I create the live candles correcty with ProtoOASpotEvent and ProtoOASubscribeLiveTrendbarReq? 

.. transformTrendbar from ProtoOASubscribeLiveTrendbarReq data doesnt seem right


@jon.slater