Models

Price Resolution Settings

enum pygindex.models.IGPriceResolution(value)

Set of values defining available resolution settings when requesting historical price data.

Resolution means that the returned price values are going to be aggregates for the time period specified by the resolution value.

For example, selecting IGPriceResolution.WEEK will return max/min open/close values for each week, whereas IGPriceResolution.HOUR_3 will return max/min open/close values for every 3 hour period.

Valid values are as follows:

SECOND = <IGPriceResolution.SECOND: 'SECOND'>

1 second

HOUR = <IGPriceResolution.HOUR: 'HOUR'>

1 hour

HOUR_2 = <IGPriceResolution.HOUR_2: 'HOUR_2'>

2 hours

HOUR_3 = <IGPriceResolution.HOUR_3: 'HOUR_3'>

3 hours

HOUR_4 = <IGPriceResolution.HOUR_4: 'HOUR_4'>

4 hours

DAY = <IGPriceResolution.DAY: 'DAY'>

1 day

WEEK = <IGPriceResolution.WEEK: 'WEEK'>

1 week

MONTH = <IGPriceResolution.MONTH: 'MONTH'>

1 month

MINUTE = <IGPriceResolution.MINUTE: 'MINUTE'>

1 minute

MINUTE_2 = <IGPriceResolution.MINUTE_2: 'MINUTE_2'>

2 minutes

MINUTE_3 = <IGPriceResolution.MINUTE_3: 'MINUTE_3'>

3 minutes

MINUTE_5 = <IGPriceResolution.MINUTE_5: 'MINUTE_5'>

5 minutes

MINUTE_10 = <IGPriceResolution.MINUTE_10: 'MINUTE_10'>

10 minutes

MINUTE_15 = <IGPriceResolution.MINUTE_15: 'MINUTE_15'>

15 minutes

MINUTE_30 = <IGPriceResolution.MINUTE_30: 'MINUTE_30'>

30 minutes

User Authentication Data Object

class pygindex.models.IGUserAuth(api_key: str, username: str, password: str)

Dataclass to hold User Authentication data

Configuration can be provided during initialisation, alternatively the following environment variables will be looked up if no arguments were provided: IG_{UPPERCASE_PARAM_NAME}, for example: IG_API_KEY

Parameters
  • api_key (str) – API key

  • username (str) – Username

  • password (str) – Password

property auth_req_data

Construct Authentication data

Constructs authentication data that will be used to obtain authentication key from IG Index API

Returns

Dictionary containing authentication details

Return type

dict

property auth_req_headers

Construct authentication headers

These headers need to be sent with every request made to IG Index API

Returns

Dictionary containing required authentication headers

Return type

dict

IG API Configuration Data Object

class pygindex.models.IGAPIConfig(platform: str = None)

Dataclass for API configuration

Configuration is provided during initialisation, otherwise, if no value is specified we will try to look up environment variable called IG_PLATFORM.

Parameters
  • platform (str) – Specify what platform to use. Available options are live - to access live trading platform, or demo - to access demo trading platform

  • base_url (str) – The value is resolved based on the platform value.

property accounts_url

Return IG Index API Accounts URL

Returns

Accounts API URL

Return type

str

property markets_url

Returns IG Index API Markets URL

This endpoint is used for multiple purposes:

  • Lookup details of a selection of epics

  • Lookup details of individual epic

  • Search for epics

Returns

Markets API URL

Return type

str

property positions_url

Returns IG Index API Positions URL

Returns

Positions API URL

Return type

str

property prices_url

Returns IG Index Prices URL

Returns

Prices API URL

Return type

str

property session_url

Return IG Index API Session URL

Returns

Session API URL

Return type

str

Session Data Object

class pygindex.models.IGSession(cst: str = None, security_token: str = None, expires: int = 0)

Dataclass to hold Session data

All values are retrieved after making an authentication call to IG Index API

Parameters
  • cst (str) – CST

  • security_token (str) – Security token

  • expires (int) – Expiration timestamp

Response Data Object

class pygindex.models.IGResponse(data: Dict, headers: Dict)

Dataclass to hold request Response data

Parameters
  • data (dict) – Response data

  • headers (dict) – Response headers

Instrument Data Object

class pygindex.models.IGInstrument(dealing_rules: dict, instrument: dict, snapshot: dict)

Dataclass to hold IG Index Instrument data

IG Instrument is a financial instrument based on some underlying financial market instrument. IG Instruments do not represent real world identifiers and are used exclusively on IG Index platform.

More information about the IG Index terms can be found on their Glossary page.

Parameters
  • dealing_rules (dict) – Data structure defining instrument dealing rules

  • instrument (dict) – Instrument definition

  • snapshot (dict) – Snapshot data

Instrument Historical Price Data Object

class pygindex.models.IGInstrumentPrices(instrument: pygindex.models.IGInstrument, instrument_type: str, metadata: dict, prices: list)

Dataclass to hold price data structure