Jump to content

wki

Community Member
  • Posts

    26
  • Joined

  • Last visited

Everything posted by wki

  1. Hi, thanks, but there is no "Consumer Goods" FTSE350 tradeable epic though?
  2. Any idea what shares make up each FTSE 350 "epic" sector?
  3. I'm trying to find a list of shares that behind each FTSE350 epic, e.g. KB.D.DRINKS.DAILY.IP (Beverages) I was pointed to this IG website but the index names don't correspond exactly with the epics on IG Trading: https://www.ig.com/uk/markets-stock-screener For example, it says that Compass Group PLC is in Hotels & Entertainment Services but there is no Hotels & Entertainment Services FTSE350 index...? Thanks...
  4. Thats a very useful resource, but this page and the available FTSE350 indices don't quite line up. For example, it says that Compass Group PLC is in Hotels & Entertainment Services but there is no Hotels & Entertainment Services FTSE350 index...? Would be good to know for example what shares are behind the various epics, e.g. KB.D.DRINKS.DAILY.IP (Beverages) - any idea if this is available somewhere?
  5. There was this great request to be able to interact with Alerts via the REST API: https://labs.ig.com/comment/1138 I cannot seem to comment on this but it would be great if this can be added to the API suite (i.e. CREATE/EDIT/DELETE Alerts). I agree that there are numerous use cases for this approach, the most compelling being able to use this endpoint where streaming data is not available (ie streamingPricesAvailable = false which is the case for all stocks? 😪). So programmatically create a new alert if e.g. HSBC reaches X, programmatically watch my inbox and then programmatically do something if alert is triggered. Yes/no/maybe?
  6. Hi, I am struggling to figure out why IG Rest API is asking for a stop_level when I am trying to update the trailing stop. This is the python code I am trying to run: response = ig_service.update_open_position(deal_id='XXXXX',limit_level=None, stop_level=None, trailing_stop=True, trailing_stop_distance=25, trailing_stop_increment=1) print(response) output: IGException: {"errorCode":"validation.not-null-conditional-set-value.request"} If I change stop_level to: latest price - (the trailing_stop_distance + trailing_stop_increment) then it updates ok, but why do I need to specify the stop_level if its a trailing stop? The stop_level will change as the price goes up and it shouldn't make a difference what I provide as stop_level surely, as long is the trailing_stop_distance meets the rules? Am I missing something? When I created the trade via the create_open_position endpoint, I had stop_level = None and a stop_distance and it went through ok.
  7. ok I think I have figured out how to extract the value from lightstreamer and then do something with it. I pass the streaming item through a function that extracts the appropriate value from the item, adds this value to a list, looks at the last item of that list and does something based on that value. Seems to work ok... lst = [] def add2list(item): val = float(item['values']['OFFER']) lst.append(val) if lst[-1] < 58000: return print('below',lst[-1]) else: return print('above',lst[-1]) 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: add2list(item))
  8. Hi, I am trying to update the stops for an existing order using the streaming API. Working / fledgling code so far: 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']) print(subscription.addlistener(lambda item: print(item['values']['OFFER']))) #####thisone session.subscribe(subscription) time.sleep(10) session.log_out() This successfully prints out the latest offer prices for 10 seconds. However, I am struggling to figure out how to take the real time offer values from the streaming data and check against my current order stopLevel and change the stopLevel if the streaming offer price goes below my threshold. For the #####thisone line above, I am needing something like this (58000 is my threshold): if subscription.addlistener(lambda item: item['values']['OFFER']) < 58000: ig_service.update_open_position(limit_level = None, stop_level = 58100, deal_id = dealId) Massive gap in my streaming api knowledge I accept but any help would be appreciated. There does not seem to be much out there that uses streaming data and "does stuff" with the outputs, apart from displaying in an html of course.
  9. Thanks @jlz. Most of that is over my head but I will, as always, chip away.
  10. Ok great, so I can use the streaming api for this. Assuming I can do this over multiple forex pairs? I have the streaming api working in that I have been able to print to screen in Python but have hit a bit of a block going beyond that, wasn't sure if it was possible. Any resources you can recommend on how to do this? I'll look myself but if you have anything at your fingertips, that would be 👍 Thanks!
  11. sorry meant "update the stops when a level is reached'. Here is a link to my fleshed out question:
  12. That allows me to do a simple update of a position but not "update a position when a level is reached' ...?
  13. Through the rest api, the ability to add additional stops and/or limits to existing orders if a level is hit. For example, I have a current sell order in place with a stop at 10,050. If the price moves down to say 9,950, I would like to move the stop quite close to say 9,960. I could achieve this if I could create another instruction on the platform that specifies the level and the stop, linked to the same order id. Also the ability to edit this additional instruction via the rest api. The original stop of 10,050 would still be in place but would be redundant as the 9,960 stop will be hit first. This would make my day.
  14. Hi. I have a trading strategy that I would like to execute but it involves moving the stop once when the price drops below a set threshold. Example: Current EURUSD price is at 10,000 (easy numbers) I put down a sell working order with the level set at 9,980 and a stop set at 9,990. The price drops to below 9,980 and the order is placed. As soon as the price drops further to 9,960 or below, the stop is moved close to the current price, i.e. it is moved from 9,990 to 9,965 Note this is a once-off move and a trailing stop won't (I don't think) give me what I need I monitor the price further and tap out if it reaches a lower profit taking level I am achieving this currently through another rest api process that watches the price every 1 minute and moves the stop when the threshold is hit, but I would like something more automated / on the platform itself as I often miss the intra-minute movements. I have considered a streaming approach but this can't be set up for limit setting right? Also considered using alerts but this is not (currently) part of the rest api. Can I achieve the above using the current IG rest api tools or even 3rd party tools? Thanks!
  15. I have a complex trading strategy and I could use alerts if this was included in the rest api. Pretty please?
  16. That's great feedback, cheers. Will struggle to find the time to move over from Python to C# but will keep that in mind, especially if the wheels keep coming off with the Python libraries.
  17. I got it! It was a pesky little VERSION= 2 instead of VERSION = "2" under the """Updates an OTC working order""". I'll log a bug. Seems to be working now, thanks!
  18. I can see why you do that 😉. Thanks for your help. Here is the repo for the trading_ig api: https://github.com/ig-python/ig-markets-api-python-library/blob/master/trading_ig/rest.py
  19. Thanks again for your help @jlzbut still struggling. I reverted back to the basic create_open_position to test the connection, and start again from there, etc. So this works: response = ig_service.create_open_position( currency_code='GBP', direction='BUY', epic='CS.D.BITCOIN.TODAY.IP', expiry='DFB', force_open=True, guaranteed_stop=False, level=None, limit_distance='150', limit_level=None, order_type='MARKET', quote_id=None, size='1', stop_distance='150', stop_level=None, trailing_stop=False, trailing_stop_increment=None) But this does not (same InvalidHeader error as original post): response = ig_service.create_working_order( currency_code='GBP', direction='BUY', epic='CS.D.BITCOIN.TODAY.IP', expiry='DFB', force_open=True, time_in_force = 'GOOD_TILL_CANCELLED', good_till_date=None, guaranteed_stop=False, level='10800', limit_distance='150', limit_level=None, order_type='LIMIT', deal_reference=None, size='1', stop_distance='150', stop_level=None)
  20. Hi, trying to create a new working order with a trigger level going through the Python trading_ig API. currencyCode = 'GBP' direction = 'BUY' epic = 'CS.D.BITCOIN.TODAY.IP' expiry = 'DFB' forceOpen = True guaranteedStop = True level = str(11450) limitDistance = str(150) timeInForce='GOOD_TILL_CANCELLED' limitLevel = None orderType = 'LIMIT' quoteId = None size = str(1) stopDistance = str(150) stopLevel = None goodTillDate = str(datetime(year = 2020, month = 9, day = 3, hour = 18, minute = 0)) response = ig_service.create_working_order(currencyCode, direction, epic, expiry, guaranteedStop, level, size, timeInForce, orderType, limitDistance, limitLevel, stopDistance, stopLevel, goodTillDate, quoteId, forceOpen, None) However, getting a "InvalidHeader: Value for header {VERSION: 2} must be of type str or bytes, not <class 'int'>" error. Tried various permutations on the string values, have a feeling that the problem lies elsewhere (pebkac most likely 😉 ).
  21. Thank you so much! I would have been completely lost without your help. I was clearly on the wrong track, all sorted and working now.
  22. Hi, thanks again for your response and top tip. I am indeed getting the "LIMIT_ORDER_WRONG_SIDE_OF_MARKET" error. I have realised that I am looking to do a resting order as opposed to an immediate order as explained here: https://labs.ig.com/apiorders Can you get the API Companion working for a limit resting order with a level, the same as what is possible through the main UI dashboard (see attached)? Thanks again for your help!
  23. Hi, thanks @jlzfor your reply but I can't see anything in your C# code that indicates where I have gone wrong. As mentioned, I can't even get this working via the API Companion, let alone through Python. I'll contact IG directly. 👍
  24. Hi, I am trying to do a trade through the API (either Python or the API Companion). I can do a MARKET trade successfully but now I want to do a LIMIT trade, where the trade is executed when a specific price point is reached but I cannot get this to work. I can place the limit order with the level through the IG Trading Dashboard though. Through the API, the LEVEL seems to be completely ignored and so it bypasses the limit and goes straight to market. Here is my Python script for GBPUSD: epic = "CS.D.GBPUSD.TODAY.IP" direction = "BUY" stopDistance = 15 limitDistance = 15 size = 0.5 level = 13130 #(current price is 13125) expiry="DBF" orderType="LIMIT" guaranteedStop=False stopLevel=None trailingStopIncrement=None trailingStop=False forceOpen=True limitLevel=None quoteId=None currencyCode="GBP" response = ig_service.create_open_position(currencyCode, direction, epic, expiry, forceOpen, guaranteedStop, level, limitDistance, limitLevel, orderType, quoteId, size, stopDistance, stopLevel, trailingStop, trailingStopIncrement, None)
×
×
  • Create New...
us