Skip to content

Commit

Permalink
Merge pull request #307 from bug-or-feature/ig-kyc
Browse files Browse the repository at this point in the history
log message if login fails because a KYC check is required
  • Loading branch information
bug-or-feature authored Nov 12, 2023
2 parents 56b664b + 417b2a6 commit 7a0d71f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions trading_ig/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class IGException(Exception):
pass


class KycRequiredException(Exception):
"""Raised when IG needs the user to confirm or re-confirm their KYC status"""

pass


class IGSessionCRUD(object):
"""Session with CRUD operation"""

Expand Down Expand Up @@ -91,6 +97,11 @@ def create(self, endpoint, params, session, version):
if response.status_code in [401, 403]:
if "exceeded-api-key-allowance" in response.text:
raise ApiExceededException()
if "error.public-api.failure.kyc.required" in response.text:
raise KycRequiredException(
"KYC issue: you need to login manually to the web interface and "
"complete IGs occasional Know Your Customer checks"
)
else:
raise IGException(f"HTTP error: {response.status_code} {response.text}")

Expand Down

0 comments on commit 7a0d71f

Please sign in to comment.