Topics
Replies
antonioritucci336
13 Jul 2023, 11:57
( Updated at: 21 Dec 2023, 09:23 )
Debugging
Everything seems right in python code:
def trendbarsResponseCallback(self, result):
# print("\nTrendbars received")
trendbars = Protobuf.extract(result)
print(f"Trendabars received: {trendbars}")
barsData = list(map(self.transformTrendbar, trendbars.trendbar))
#barsData = list(map(self.transformTrendbar, result))
barsData = {"bars": barsData}
return json.dumps(barsData)
def sendProtoOAGetTrendbarsReq(self,
currentAccountId: int,
symbolId: int,
timeframe: str,
since_ms: int,
until_ms: int):
request = ProtoOAGetTrendbarsReq()
request.symbolId = symbolId
request.ctidTraderAccountId = currentAccountId
request.period = self.timeframe_to_proto_period(timeframe)
request.fromTimestamp = since_ms
request.toTimestamp = until_ms
request.count = 3
print(f"Requesting trendbars symbolId: {request.symbolId}")
print(f"Requesting trendbars period: {request.period}")
print(f"Requesting trendbars fromTimestamp: {request.fromTimestamp}")
print(f"Requesting trendbars toTimestamp: {request.toTimestamp}")
print(f"Requesting trendbars count: {request.count}")
deferred = self.client.send(request)
deferred.addCallbacks(self.trendbarsResponseCallback, onError)
return deferred
this is are logs showed
sending with toTimestamp 1689237969000 that is actually 10:46am
the last bar received is at 28153920 minutes that is 1689235200 that is 10.00am
@antonioritucci336
antonioritucci336
12 Jul 2023, 11:10
RE:
PanagiotisChar said:
Hi there,
Indeed. Does this happen on all symbols? How can we reproduce it? Symbol? Broker?
It happens on all symbols, using cTrader Pepperstone. If necessary I'll extract a snippet from the code. Basically to reproduce I do the ProtoOAGetTrendbarsReq with toTimestamp = int(calendar.timegm(datetime.datetime.utcnow().utctimetuple())) * 1000
Thanks
@antonioritucci336
antonioritucci336
12 Jul 2023, 10:38
RE:
PanagiotisChar said:
Hi there,
ProtoOAGetTrendbarsReq returns only historical data. Use ProtoOASubscribeLiveTrendbarReq to get the current live trendbar.
Need help? Join us on Telegram
Sorry for continue asking, but for example, when is 10.02AM on timeframe 30 minutes, I thought 9.30AM-10.00AM was an historic bar and 10.00AM-10.02AM is the live bar. Isn't it correct?
@antonioritucci336
antonioritucci336
13 Jul 2023, 12:13
Found out my fault
Now I found out! Everything is fine, just the timestamp is the starting and not the ending timestamp of the bar so i received the 10.00am bar that is actually the last from 10.00am to 10.30am! I apologize, it is mentioned in the documentation here
Thank you for your kind support!
Antonio
@antonioritucci336