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

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.

Files for ig-streaming-client, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size ig_streaming_client-0.1-py3-none-any.whl (3.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size ig-streaming-client-0.1.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page