Jump to content

JulianG

Community Member
  • Posts

    24
  • Joined

  • Last visited

Posts posted by JulianG

  1. I am using the REST API call '/accounts' to get the balance of my demo accounts. Sometimes, this returns a 200 response code (i.e. success) but the balance is zero. If I try again, it sometimes works, but not always. I've seen this in the API companion too.

    I have amended my app to try 10 times at 2-second intervals, but sometimes even this does not work. Does anyone have a reliable way to get the account balance?

    Thanks,

    Julian

  2. My app establishes more than one session using the REST interface. The code that does this has a retry with progressively increasing waits. I have noticed that it always seems to take a few goes before it makes the connection, although it gets there in the end. I know the interface has limits on the number of transactions per second etc, but I am nowhere near breaching those. Is there a limit such as you need to wait a number of seconds between establishing sessions?

    Julian

  3. I have a program that uses the REST API. It has a main routine and two threads (written in Python). The main routine and each of the two threads establish their own session using the API (POST /session), then set the account (PUT /session).

    This has worked fine for months, but for the last few weeks there has been a problem. The first creation of a session and setting the account works as before. However, when the threads come to set their accounts, I get error 401 and message 'error.security.account-token-invalid'. This program goes straight from creating the session to setting the account and it uses the CST and X-SECURITY-TOKEN returned by the session creation when it sets the account. Creating the session itself returns code 200, which indicates success.

    Nothing has changed in my program to cause this. The problem is intermittent and I can improve things by retrying after a few seconds, when it will sometimes work.

    Does anyone know of any changes at the IG end that might be causing this? Are there any obvious workarounds. One reason for having the separate sessions for the threads was to avoid any possibility of interference between them. I don't know how necessary this is. However, the program worked before and, even if I have to change it, I'd like to know what is happening.

    Thanks for any help or suggestions.

    Julian

     

  4. Answering my own question ...

    I had misunderstood how this is meant to work. I assumed that when data was available for a new timestamp, that meant the candle was complete. However, this is not how it works and, of course, not how it works with the online charts.

    When one candle is complete, price data is immediately available for the next candle even if it is still in progress. Therefore, what I was seeing was a snapshot at a number of seconds into a new candle. Naturally, this data would not be complete and correct until the next candle had started.

    Julian

    • Great! 1
  5. In my Python app I submit a /markets GET request for the Epic code. This returns the bid and offer prices, along with lot_size and margin requirement.

    I am assuming by "spend exactly 1000" you mean commit that much margin (I am mainly familiar with spread betting and CFDs).

    I calculate my order size by:

        cash / price / margin / lot_size

    So, if I have £1,000 available for margin on a CFD, the price is 7,500, the margin 5% and the lot size £2 per point, that means I need to open a position for £1.33 per point.

    Of course, the price may have changed marginally in the fraction of a second between fetching the price, doing the calculation and opening the position, but it's close enough for me.

    Julian

    • Like 1
  6. I am fetching 1min prices with an app every minute. I noticed that sometimes, my saved prices didn't match the online chart. Investigating further, it seems if you get the latest 1min price, and then get it again a few minutes later, it's slightly different. It is the same from the online API Companion.

    Here is a price retrieved from the Companion at 14:19 today, followed by the same data retrieved a few minutes later. You can see that the closing and high prices are different, and also the volume. (This is Epic: IX.D.FTSE.IFM.IP)

    Is this a predictable behaviour? How long do I need to wait before the price settles down to its final value?

    Thanks, Julian

    {
            "snapshotTime": "2020/05/07 14:19:00",
            "snapshotTimeUTC": "2020-05-07T13:19:00",
            "openPrice": {
                "bid": 5911.3,
                "ask": 5912.3,
                "lastTraded": null
            },
            "closePrice": {
                "bid": 5912.3,
                "ask": 5913.3,
                "lastTraded": null
            },
            "highPrice": {
                "bid": 5912.3,
                "ask": 5913.3,
                "lastTraded": null
            },
            "lowPrice": {
                "bid": 5911.3,
                "ask": 5912.3,
                "lastTraded": null
            },
            "lastTradedVolume": 10
        }]
    }

    Retrieved at 14:30.

    {
            "snapshotTime": "2020/05/07 14:19:00",
            "snapshotTimeUTC": "2020-05-07T13:19:00",
            "openPrice": {
                "bid": 5911.3,
                "ask": 5912.3,
                "lastTraded": null
            },
            "closePrice": {
                "bid": 5911.8,
                "ask": 5912.8,
                "lastTraded": null
            },
            "highPrice": {
                "bid": 5913.3,
                "ask": 5914.3,
                "lastTraded": null
            },
            "lowPrice": {
                "bid": 5911.3,
                "ask": 5912.3,
                "lastTraded": null
            },
            "lastTradedVolume": 45
        }
  7. I am using the web interface. I have been investigating Heikin-Ashi candlesticks, which look great. However, it appears that indicators like CCI, MACD, RSI and Stochastics change when you switch from standard candlesticks to H-A. Surely the indicators have their definitions which are based on actual OHLC, and shouldn't be calculated based on H-A OHLC? H-A is a smoothing mechanism, not a different way to define prices.

    Julian

  8. I have a share on the web platform that is in a market not currently open (LDL - Lydall). It shows Sell 2027, Buy 2033. I can create an order at price level 2033 with a stop one point away (at 2032).

    However, in the app when I create the order, it can be a limit order at 2032, or a stop order at 2034. It will not allow me to place an order at 2033 like the web platform.

    Why the difference?

    Thanks,

    Julian

×
×
  • Create New...
us