Jump to content
  • 0

Python programming help


panja

Question

EPIC = 'IX.D.FTSE.DAILY.IP'
PRICE_RESOLUTION = 'D'
NUM_POINTS = 20

ig_service = IGService(IG_USERNAME, IG_PASSWORD, IG_API_KEY, IG_ACCT_TYPE)
ig_service.create_session()

response = ig_service.fetch_historical_prices_by_epic_and_num_points(EPIC, PRICE_RESOLUTION, NUM_POINTS)
df_ask = response['prices']['ask']

This is the basic code a friend gave m. I am unable to build on this. My query is, is this type of code antiquated? Is there a new python example code?

If this code is ok, how do I change parameters? What are the other calls that can be used to get data in python?

thanks in advance,

Prakash

 

Link to comment

5 answers to this question

Recommended Posts

  • 0

@panja I added a method to retrieve prices within the IgClient class at

https://github.com/oneangrytrader/brokerapiclients/blob/master/IG.Python.Api.Client/client/IgClient.py

Input parameters are: Epic, Resolution, DateFrom and DateTo. 

Resolution is an enum also part of the repository., check the possible values there.

An example url retrieving prices for the FTSE100 from the 20th to the 21st of July with a daily resolution would retrieve two candles, one per day.

Quote

/gateway/deal/prices/IX.D.FTSE.DAILY.IP?resolution=DAY&from=2020-07-20T00%3A00%3A00&to=2020-07-21T00%3A00%3A00

Producing the result of:

result:[
    {
        "closePrice": {
            "ask": 6269.3,
            "bid": 6265.3,
            "lastTraded": null
        },
        "highPrice": {
            "ask": 6314.3,
            "bid": 6310.3,
            "lastTraded": null
        },
        "lastTradedVolume": 75212,
        "lowPrice": {
            "ask": 6220.1,
            "bid": 6219.1,
            "lastTraded": null
        },
        "openPrice": {
            "ask": 6308.8,
            "bid": 6304.8,
            "lastTraded": null
        },
        "snapshotTime": "2020/07/20 00:00:00",
        "snapshotTimeUTC": "2020-07-19T23:00:00"
    },
    {
        "closePrice": {
            "ask": 6264.5,
            "bid": 6260.5,
            "lastTraded": null
        },
        "highPrice": {
            "ask": 6317.0,
            "bid": 6316.0,
            "lastTraded": null
        },
        "lastTradedVolume": 74772,
        "lowPrice": {
            "ask": 6237.9,
            "bid": 6235.9,
            "lastTraded": null
        },
        "openPrice": {
            "ask": 6268.9,
            "bid": 6264.9,
            "lastTraded": null
        },
        "snapshotTime": "2020/07/21 00:00:00",
        "snapshotTimeUTC": "2020-07-20T23:00:00"
    }
]
 

  • Great! 1
Link to comment
  • 0
On 26/07/2020 at 20:34, jlz said:

@panja I added a method to retrieve prices within the IgClient class at

https://github.com/oneangrytrader/brokerapiclients/blob/master/IG.Python.Api.Client/client/IgClient.py

Input parameters are: Epic, Resolution, DateFrom and DateTo. 

Resolution is an enum also part of the repository., check the possible values there.

An example url retrieving prices for the FTSE100 from the 20th to the 21st of July with a daily resolution would retrieve two candles, one per day.

Producing the result of:

result:[
    {
        "closePrice": {
            "ask": 6269.3,
            "bid": 6265.3,
            "lastTraded": null
        },
        "highPrice": {
            "ask": 6314.3,
            "bid": 6310.3,
            "lastTraded": null
        },
        "lastTradedVolume": 75212,
        "lowPrice": {
            "ask": 6220.1,
            "bid": 6219.1,
            "lastTraded": null
        },
        "openPrice": {
            "ask": 6308.8,
            "bid": 6304.8,
            "lastTraded": null
        },
        "snapshotTime": "2020/07/20 00:00:00",
        "snapshotTimeUTC": "2020-07-19T23:00:00"
    },
    {
        "closePrice": {
            "ask": 6264.5,
            "bid": 6260.5,
            "lastTraded": null
        },
        "highPrice": {
            "ask": 6317.0,
            "bid": 6316.0,
            "lastTraded": null
        },
        "lastTradedVolume": 74772,
        "lowPrice": {
            "ask": 6237.9,
            "bid": 6235.9,
            "lastTraded": null
        },
        "openPrice": {
            "ask": 6268.9,
            "bid": 6264.9,
            "lastTraded": null
        },
        "snapshotTime": "2020/07/21 00:00:00",
        "snapshotTimeUTC": "2020-07-20T23:00:00"
    }
]
 

 

Repo seems gone!?

I've also started a python project on Ig Api, when I saw your post I was def hoping on gaining some more knowledge or collaboration.

Here's my repo. https://github.com/nickcamel/IgApi

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • General Statistics

    • Total Topics
      22,089
    • Total Posts
      92,938
    • Total Members
      42,475
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    IPS Temp Admin
    Joined 06/10/22 15:40
  • Posts

    • 🔸Hello traders, let's review the 4 hour chart for AUDUSD today. Recently price was locked inside distribution trading range and subsequently it broke down below key s/r level near 6600 and hit 6500. Following the normal distribution pattern. 🔸Short-term expecting throwback to re-test mid of the distribution range and then expecting new wave of short-selling once we trigger 6700. Bears still maintain strategic control. 🔸Recommended strategy for AUDUSD bears: wait for the short-term bounce to complete near 6700 and then re-enter on SELL SIDE. TP1 bears +200 pips TP2 bears final +400 pips at 6350. Keep in mind this is a swing trade setup so will take more time to complete. good luck! 🎁Please hit the like button and 🎁Leave a comment to support our team! RISK DISCLAIMER: Trading Futures , Forex, CFDs and Stocks involves a risk of loss. Please consider carefully if such trading is appropriate for you. Past performance is not indicative of future results. Always limit your leverage and use tight stop loss.  
    • Analog Devices Inc., Elliott Wave Technical Analysis Analog Devices Inc., (ADI:NASDAQ): Daily Chart, 31 May 23, ADI Stock Market Analysis: We reacted higher off equality of C vs. A as expected and we seem to be wanting to continue higher.   ADI Elliott Wave Count: Wave C of (2). ADI Technical Indicators: Above 200EMA. ADI Trading Strategy: Looking for further upside into wave 1 to resume upside, we will have additional confirmation once we break the top of wave B. TradingLounge Analyst: Alessio Barretta Source : Tradinglounge.com get trial here!       Analog Devices Inc., ADI: 1-hour Chart, 31 May 23, Analog Devices Inc., Elliott Wave Technical Analysis ADI Stock Market Analysis: Looking for a potential five wave move off the lows, e are now expecting a three wave move into wave (ii) to then look for potential longs. ADI Elliott Wave count:  Wave  (i) of {i}. ADI Technical Indicators: 20EMA as support.   ADI Trading Strategy: Looking for a three wave move pullback in wave (ii) before resuming higher.
    • Elliott Wave Analysis TradingLounge Daily Chart, 31 May 23,   Bitcoin/U.S.dollar(BTCUSD) BTCUSD Elliott Wave Technical Analysis Function: Reactionary(Counter Trend) Mode: Corrective Structure: Zigzag Position: Wave(C) Direction Next higher Degrees: wave ((2)) of Motive Details: Wave ((2)) is likely to end at the level of 25874.30. A five-wave rise will confirm this idea. Wave Cancel invalid level: 25874.30 Bitcoin/U.S. dollar (BTCUSD)Trading Strategy: Bitcoin has recovered well from the 25874.30 level and can still hold above the MA200 line, leading us to expect Wave 2 to end at 25874.30, the price is returning to an upward trend, and a five-wave rise will support this idea. Bitcoin/U.S.dollar(BTCUSD)Technical Indicators: The price is above the MA200 indicating an Uptrend MACD and RSI are bullish momentum. TradingLounge Analyst: Kittiampon Somboonsod, CEWA Source : Tradinglounge.com get trial here!       Elliott Wave Analysis TradingLounge 4H Chart, 31 May 23,   Bitcoin/U.S.dollar(BTCUSD) BTCUSD Elliott Wave Technical Analysis Function: Follow Trend Mode: Motive Structure: Impulse Position: Wave 5 Direction Next higher Degrees: wave (C) of Zigzag Details: Wave (C) is likely to end at the level of 25874.30. A five-wave rise will confirm this idea. Wave Cancel invalid level: 25874.30 Bitcoin/U.S. dollar (BTCUSD)Trading Strategy: Bitcoin has recovered well from the 25874.30 level and can still hold above the MA200 line, leading us to expect Wave 2 to end at 25874.30, the price is returning to an upward trend, and a five-wave rise will support this idea. Bitcoin/U.S.dollar(BTCUSD)Technical Indicators: The price is above the MA200 indicating an Uptrend MACD and RSI are bullish momentum.
×
×
  • Create New...