How to Get last symbol price?

Created at 02 Mar 2021, 19:35
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!
BU

budda_dan2020

Joined 10.09.2020

How to Get last symbol price?
02 Mar 2021, 19:35


Hi,

I am very impressed by professional and quick answer.

How can I get the last price of the symbol?

E.g. I want to get EURJPY price for now. If the market is closed now, I want to get the last value available.

I did it through from TrendbarResponse for last 5 days M1. But it took a long time to receive the response.

Is there any better method or API call?


@budda_dan2020
Replies

vasile.peste
08 Jul 2021, 00:05 ( Updated at: 08 Jul 2021, 00:06 )

Hi, a way (not tested) for retrieving the last price of a symbol is requesting the latest ticks of the symbol.

Steps:

  1. Send a ProtoOAGetTickDataReq request (https://spotware.github.io/open-api-docs/messages/#protooagettickdatareq) setting "toTimestamp" to the actual date, and "fromTimestamp" to some time before the actual date (maybe 3-4 days before is a good choice to avoid getting zero ticks because of weekends).
  2. Get the latest tick by timestamp and then get its price. This should be the last symbol BID/ASK price (depending on which quotation type you requested in step 1).

@vasile.peste