Jump to content
  • 2

Rest calls intermittent forbidden responses


svb

Question

Hi,

C# : use combination of REST & streaming. Replicated using WPF example that you can download in labs.

This issue is specific to REST

Every 15 minutes I get 15 min prices for a range of epics. My allowance is fine with +6500 left. 

I keep getting random null responses with "forbidden" status code. Different epics. If I trap null response and then set rest call to execute again, it works. I continue and it carried on with rest of epics, or will do say 10 , return forbidden for 3 and then return fine for epics following that. if I step through each epic, its fine. So seems to be some timing glitch. Tried trapping and adding task.delays and retries, but still null. I have to actually break and step over. Given its not my allowance, are there any quirks with REST calls to cause this? This is example, does some, throws forbidden and then fine for AUDCAD again.

persist 15: 17/03/2021 22:15:01 - CS.D.CADJPY.TODAY.IP
persist 15: 17/03/2021 22:15:01 - CS.D.CADCHF.TODAY.IP
persist 15: 17/03/2021 22:15:01 - CS.D.EURAUD.TODAY.IP
response is null for CS.D.NZDJPY.TODAY.IP 15
response is null for CS.D.NZDUSD.TODAY.IP 15
response is null for CS.D.CHFJPY.TODAY.IP 15
response is null for CS.D.USCGC.TODAY.IP 15
response is null for CC.D.CL.USS.IP 15
persist 15: 17/03/2021 22:15:01 - CS.D.AUDCAD.TODAY.IP

I cannot replicate forbidden status response in REST companion for any epic either, just seems when run via rest client

Thanks

Edited by svb
add note about running in companion
  • Like 2
Link to comment

8 answers to this question

Recommended Posts

  • 0

improved it by making sure rest calls aren't async and also putting 2 second wait before each call (1 second is not enough and I get more forbidden responses). For what I'm doing this is ok-ish, but not great. Given this is the rest client returning this and not my code I'm not sure what's changed i.e account, service validation. If anyone has any ideas that would be much appreciated,

the wait I added,

 

    foreach (var market in MarketList)
                        {
                            try
                            {
                                Thread.Sleep(2000);

                                response = await igRestApiClient.priceSearchByNumV2(market, "HOUR", "2");

                                if (response != null)

and the results. only 2 had issues this time, even with 2 second wait. with 1 second I get a lot more.

time: 18/03/2021 11:58:01
time: 18/03/2021 11:59:01
time: 18/03/2021 12:00:01
persist 15: 18/03/2021 12:00:01 - CS.D.AUDUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURGBP.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.DOW.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.NASDAQ.CASH.IP
persist 15: 18/03/2021 12:00:01 - IX.D.SPTRD.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.DAX.DAILY.IP
persist 15: 18/03/2021 12:00:01 - IX.D.FTSE.DAILY.IP
persist 15: 18/03/2021 12:00:01 - CC.D.DX.USS.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USCSI.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDCHF.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPAUD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.EURCAD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USDMXN.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.GBPJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CADJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CADCHF.TODAY.IP
response is null for CS.D.EURAUD.TODAY.IP 15
persist 15: 18/03/2021 12:00:01 - CS.D.NZDJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.NZDUSD.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.CHFJPY.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CS.D.USCGC.TODAY.IP
persist 15: 18/03/2021 12:00:01 - CC.D.CL.USS.IP
persist 15: 18/03/2021 12:00:01 - CS.D.AUDCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURGBP.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.DOW.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.NASDAQ.CASH.IP
persist 60: 18/03/2021 12:00:01 - IX.D.SPTRD.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.DAX.DAILY.IP
persist 60: 18/03/2021 12:00:01 - IX.D.FTSE.DAILY.IP
persist 60: 18/03/2021 12:00:01 - CC.D.DX.USS.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USCSI.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPAUD.TODAY.IP
response is null for CS.D.GBPCAD.TODAY.IP 60
persist 60: 18/03/2021 12:00:01 - CS.D.EURCAD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USDMXN.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.GBPJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CADJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CADCHF.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.EURAUD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.NZDJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.NZDUSD.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.CHFJPY.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CS.D.USCGC.TODAY.IP
persist 60: 18/03/2021 12:00:01 - CC.D.CL.USS.IP
persist 60: 18/03/2021 12:00:01 - CS.D.AUDCAD.TODAY.IP
time: 18/03/2021 12:03:01

 

Link to comment
  • 0

Thanks for your response, svb. It looks like my problem is indeed an allowance problem but I have been seeing the same intermittent issues as you with various waits/pauses affecting it (I found I needed 2.5 seconds to make a consistent difference).

When I do historical price search from the API companion, all I get back is this: errorCode": "error.public-api.exceeded-account-historical-data-allowance. I can't see that meta data that you reference. Are you able to see this when you use the companion? Are you using a historical price request?

Thanks

Link to comment
  • 0

For what it's worth... I too get forbidden responses from the REST API and I too retry the Price request and then it usually works. In fact, I retry up to 10 times as sometimes it gives me forbidden repeatedly. It can happen getting Navigation Nodes as well as Prices. It isn't allowance and looks to me more like something server-side e.g. bandwidth throttling perhaps? I just retry failed requests in a loop and haven't figured out any proper fix but the retry loop works fine so not a big problem

Link to comment
  • 0

Hello everyone,
I add to the problem, until last week everything was working great. This week the api returns errorCode: null in any type of call. Not only with prices, also obtaining markets, and even opening the session. It seems to me a somewhat dirty solution to retry in all calls, and that increases the operation time of my algorithms, making it unsafe

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • Trading Strategies NASDAQ 100 (NDX), Apple (AAPL), Tesla (TSLA), Amazon (AMZN), Nvidia (NVDA), Microsoft (MSFT), Meta Platforms (META), Netflix (NFLX), Alphabet (GOOGL), Bitcoin (BTC). Elliott Wave Analysis of NDX Tech Stocks: Risk on with this week expecting higher price levels. Longer term Elliott wave counts for NVDA, GOOGL and MSFT. I also focus on how I fit stock and Indices into the same larger Elliott wave count, that is into Primary Wave 3) of cycle degree I. Last we started to enter long trades for stocks, some have triggered long, and some are still pending, and I make an adjustment on the entry for AMZN a lower entry price. In a nutshell there is no change in Elliott wave counts. Video Chapters 00:00 NASDAQ 100 (NDX) 03:34 Apple (AAPL) 05:02 Amazon (AMZN) 08:56 NVIDIA (NVDA) 15:33 Meta Platforms (META) 16:37 Netflix (NFLX)  17:32 Alphabet (GOOGL) 24:28 Microsoft MSFT 25:39 Tesla (TSLA) 26:52 Bitcoin 29:52 End Analyst Peter Mathers TradingLounge  
    • Gate io Referrl Code: used as “3930511”. It is the most used referrl code in the world, valid for life, with the highest discount rate. When registering, write “3930511” in the field where it says “Referrl ID”. The commission discount you will receive is 100%. You can also win welcome rewards worth up to $6,666.
    • Gate io Referns Kod u: “3930511” olarak kullanilir. Dünyada en çok kullanılan, ömür boyu geçerli, en yüksek indirim oranına sahip Gate io referns kod udur. Gate io kripto para borsasına kayıt olurken “Referns Kimliği” yazan yere “3930511” yazınız. Alacağınız işlem ücreti indirimi % 100'dür. Ayrıca 6666$ USDT komisyon iade bonusu alacaksınız. Kripto para borsası Gate io Referns Kod u: “3930511” ile vadeli işlem yani futures işlem ücreti indirimleri ve spot ve marjin işlem ücreti indirimleri kazanırsınız. Ayrıca bonuslar ve bir çok promosyon kazanırsınız. Teknoloji ve finans dünyasında yatırım ve ticaret yapmak için hemen Gate io borsasına: “3930511” referns kod u ile kayıt olun.
×
×
  • Create New...
us