Announcement

Collapse
No announcement yet.

Getting % change value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting % change value

    Hi,
    I'm looking to get the % change value compared to the close of the previous day. I'm primarily using candle data based on a 5 minute bar request. Does anyone know what options are provided in the API to get at this % change data?

    Btw, I'm aware that I can make a historic request for the previous day and get the close value for reference, but I wanted to know about other potential solutions to this.

    Thanks,
    Burt

  • #2
    The percent change field is not supported directly by the Desktop API. You will need to calculate it based on the current Last price and previous close.

    Comment


    • #3
      Getting Previous close

      I'm fine with calculating the % change compared to the previous. My only issue right now is getting back the previous day's close. Here is an example of a test I'm trying to use:

      RequestHistory("MSFT","D", btDAYS, 1, -1, -1);

      The documentation isn't completely clear on this, so should I expect the previous day's close to be available in the event handler for the OnBarsReceived event?

      Btw, right now I only seem to get the close of the current day. Currently I'm testing this out in the evening after the market has closed, but I've not been able to receive the proper previous day's close while the exchange is open either.

      Any help is greatly appreciated.

      Comment


      • #4
        You can increase the numDay filter to retrieve closing price for a few more days backward.

        RequestHistory("MSFT","D", btDAYS, 2, -1, -1);

        And yes, since you are calling the RequestHistory method, you can expect resulting data from OnBarsReceived events.

        Comment


        • #5
          I've tried various combinations of the interval parameter, which I should have mentioned. So you are saying that the following should work to return the previous day's close:

          RequestHistory("MSFT","D", btDAYS, 2, -1, -1);

          I have tried this and capturing it in the OnBarsReceived event's event handler, but I will take another look at it.

          Are there any code samples in some of the docs or whatever that specifically shows gathering the previous close?

          Comment


          • #6
            The RequestHistory method is already documented in the Desktop API documentation. That is the way to retrieve intraday and interday historical data. Another variation of it is to further increase the numDay argument and also take advantage of the bartype parameter:

            RequestHistory("MSFT","D", btBARS, 5, -1, -1);

            Comment


            • #7
              Thanks for the response. I did figure the issue out. The main problem was the that index value was using an unsigned int, which itself isn't odd. The only thing was knowing how to reference the historic intervals. For example, I didn't expect to reference a 4 interval request with indices 0, -1, -2, and -3. A little odd to me, but I got it working fine. It would be nice if the documentation discussed this. Maybe I just didn't see it, but looked over it several times.

              Comment

              Working...
              X