Skip to main content

IG streaming API client

Project description

IG streaming API client

Small Python library to connect to IG streaming API (more information and API reference is available on IG Labs website).

Installation

To use most recent release:

pip install ig-streaming-client

To use current master branch:

pip install git+https://github.com/wjszlachta/ig-streaming-client.git

Usage

For demo account:

import time

from ig_streaming_client import IgStreamingSession
from lightstreamer_client import LightstreamerSubscription

api_key = '...'
account_id = '...'
rest_api_username = '...'
rest_api_password = '...'

session = IgStreamingSession(api_key, account_id, rest_api_username, rest_api_password)

subscription = LightstreamerSubscription('MERGE',
                                         ['MARKET:CS.D.BITCOIN.TODAY.IP'],
                                         ['UPDATE_TIME', 'BID', 'OFFER'])
subscription.addlistener(lambda item: print(item))
session.subscribe(subscription)

time.sleep(30)

session.log_out()

For live account:

import time

from ig_rest_client import IG_REST_TRADING_API_LIVE_URL
from ig_streaming_client import IgStreamingSession
from lightstreamer_client import LightstreamerSubscription

api_key = '...'
account_id = '...'
rest_api_username = '...'
rest_api_password = '...'

session = IgStreamingSession(api_key, account_id, rest_api_username, rest_api_password, rest_api_url=IG_REST_TRADING_API_LIVE_URL)

subscription = LightstreamerSubscription('MERGE',
                                         ['MARKET:CS.D.BITCOIN.TODAY.IP'],
                                         ['UPDATE_TIME', 'BID', 'OFFER'])
subscription.addlistener(lambda item: print(item))
session.subscribe(subscription)

time.sleep(30)

session.log_out()

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ig-streaming-client-0.1.tar.gz (3.0 kB view hashes)

Uploaded source

Built Distribution

ig_streaming_client-0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page