Jump to content
  • 0

Error message : Exception: unauthorised.access.to.equity.exception


Majoka

Question

Hi, I have an API key and it seems to be working. For example, I can run the following command on my Python console and get a result. 

results = ig_service.search_markets("bhp")
results

But when I try to run this, it gives me an exception error: unauthorised.access.to.equity.exception

from trading_ig import IGService
from trading_ig.config import config
 
class config(object😞
    username = "xx"
    password = "xx"
    api_key = "xx"
    acc_type = "xx"
    acc_number = "xx"
 
ig_service = IGService(config.username, config.password, config.api_key, config.acc_type)
ig_service.create_session()
 
# Fetch close prices for BHP from IG Markets
epic_id = "AA.D.BHP.CASH.IP"
resolution = "D"
num_points = 10
 
response = ig_service.fetch_historical_prices_by_epic_and_num_points(epic_id, resolution, num_points)
close_prices = [float(price["closePrice"]["bid"]) for price in response["prices"]]
 
print(close_prices)
 
open_positions = ig_service.fetch_open_positions()
print("open_positions:\n%s" % open_positions)
 
Can you please help?
Link to comment

6 answers to this question

Recommended Posts

  • 0
On 14/06/2023 at 14:02, bug-or-feature said:

Your Epic is wrong, it should be "AA.D.BHP.DAILY.IP".

If you are new to the Python library, or to the IG REST API, it would be a good idea to use the IG API companion at first. It is much harder to make mistakes with the companion

Have you tried "AA.D.BHP.DAILY.IP" on the companion? I've got the same error message.

 

I remember there was very old thread saying IG does not support equity history price over APIs. Looks still the case now.

Edited by calabashsis
Link to comment
  • 0
On 15/07/2023 at 23:49, calabashsis said:

Have you tried "AA.D.BHP.DAILY.IP" on the companion? I've got the same error message.

 

I remember there was very old thread saying IG does not support equity history price over APIs. Looks still the case now.

Yes, and it works fine for both the market info and historic price endpoints:

https://demo-api.ig.com/gateway/deal/markets/AA.D.BHP.DAILY.IP

https://demo-api.ig.com/gateway/deal/prices/AA.D.BHP.DAILY.IP?resolution=DAY&max=10

 

Link to comment
  • 0
11 hours ago, bug-or-feature said:

Hi, 

  Thanks for the reply. But this is really weird:

  • market info DOES work, on the IG API companion page (the endpoints string displayed at the top of the page, under 'URL' section).
  • However, if I try "Historic Price Search" from the left pane of the page, I've got the same error code as below:
    • "errorCode": "unauthorised.access.to.equity.exception"
  •   Again, I've got identical endpoints as yours, showing at the top 'URL' field :

  

   I've tried Python version of IG REST API too (trading-ig). Exactly same behaviour.

 

  I really don't think IG offer access to Equities via the APIs  (including historic data) - however, anywhere we can confirm this???

 

 

Edited by calabashsis
Link to comment
  • 0
Quote

I really don't think IG offer access to Equities via the APIs  (including historic data) - however, anywhere we can confirm this???

You cannot use the APIs with share dealing, ISA or SIPP accounts. The APIs only work with spread betting and CFD accounts.

You can use the APIs to trade equities (and view historic prices) with spread betting or CFD accounts.

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

    • I'm currently bullish on AI project tokens, especially on Bitget, and I'm excited about their symbiotic relationship with blockchain technology, which is driving financial inclusion and innovation. Projects like SORA, SingularityNET's AGIX, The Graph (GRT), and Nebula AI's NMT are leading the way in transformative advancements across various sectors.
    • I trade leveraged futures on Binance so I'm going to miss them, not that much though cos I also use Bitget exchange, and they have high liquidity and low fees, So I will just move my funds there and continue leveraged trading.
    • If you've tried using Ethereum, you know it can get slow and expensive. Think of Starknet as a helper that makes everything faster and cheaper. It does this by taking a bunch of transactions, squishing them into one, and then processing that one. This means more transactions can happen at once without clogging up the system. For people making apps on the blockchain (they call these dApps), Starknet is like a dream come true because it lets their apps handle a lot more users without slowing down. It also gives them the freedom to make their apps work just how they want, making things better for users. When it comes to making money, Starknet charges fees to use its network and lets people 'stake' their coins – that's like putting your money in a savings account that helps the network run, and you get a little reward for that. So, what do you think about Starknet? It's all about helping Ethereum handle more action without any hassle. Could be a big deal for how we use digital money, right?
×
×
  • Create New...
us