Having issues with the Streaming API Sample.py #292
LordNadimi
started this conversation in
General
Replies: 1 comment
-
I solved this myself. I don't know how to delete. But the solution is that your sample is wrong because IG changed something on their side. In the sample, it needs to be added "MARKET" Like this subscription_prices = Subscription( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been trying to work with this and trying different ways to get to the goal but it doesn't seem to be working. Even when I only use the sample provided it doesn't work as intended. The account updates, when fexample I add funds to the account, that updates as intended. but the streaming of prices does not even show.
the below code
gives this:
D:\Python\envs\Project_Allspark\python.exe D:\Project_Allspark\streamingapi.py
INFO:root:Creating new v2 session for user 'myusername' at 'https://demo-api.ig.com/gateway/deal'
INFO:root:POST '/session', resp 200
INFO:trading_ig.stream:Starting connection with https://demo-apd.marketdatasystems.com
----------HIT CR TO UNSUBSCRIBE AND DISCONNECT FROM LIGHTSTREAMER-----------
balance: {'pos': 1, 'name': 'ACCOUNT:Whatever', 'values': {'AVAILABLE_CASH': '5161570.52'}}
#!/usr/bin/env
python-- coding:utf-8 --
"""
IG Markets Stream API sample with Python
2015 FemtoTrader
"""
import logging
from trading_ig import IGService, IGStreamService
from trading_ig.config import config
from trading_ig.lightstreamer import Subscription
A simple function acting as a Subscription listener
def handle_update(epic, fields, value):
if fields == "BID":
print("The latest bid price for " + epic + " is:", value)
elif fields == "OFFER":
print("The latest ask price for " + epic + " is:", value)
def on_prices_update(item_update):
# print("price: %s " % item_update)
print(
"{stock_name:<19}: Time {UPDATE_TIME:<8} - "
"Bid {BID:>5} - Ask {OFFER:>5}".format(
stock_name=item_update["name"], **item_update["values"]
)
)
def on_account_update(balance_update):
print("balance: %s " % balance_update)
def main():
logging.basicConfig(level=logging.INFO)
# logging.basicConfig(level=logging.DEBUG)
if name == "main":
main()
`
Beta Was this translation helpful? Give feedback.
All reactions