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
  • image.png

  • Posts

    • This analysis provides insights into the Elliott Wave patterns observed in major NASDAQ stocks, including the NASDAQ 100, S&P 500, and key companies like Apple (AAPL), Tesla (TSLA), Amazon (AMZN), Nvidia (NVDA), Microsoft (MSFT), Meta Platforms (META), Netflix (NFLX), and Alphabet (GOOGL). Currently, we assess that the Wave (4) low may have been established across these indices, signaling a potential shift to a "Risk On" stance. This scenario suggests that building long positions in most technology stocks could be increasingly viable. However, the inherent risk lies in the possibility that Wave (4) may not yet be fully in place. As a precaution, we continue to manage existing risks carefully. Should the market conditions confirm the placement of Wave (4), we will be better positioned to safely escalate our long trading positions in anticipation of the next upward movement. Video Chapters 00:00 NASDAQ 100 (NDX)  SP500 (SPX) 01:43 Apple (AAPL) 03:26 Amazon (AMZN) 04:18 NVIDIA (NVDA) 05:13 Meta Platforms (META) 05:54 Netflix (NFLX)  06:31 Alphabet (GOOGL) 07:20 Microsoft MSFT 08:00 Tesla (TSLA) 09:20 End Analyst Peter Mathers TradingLounge™ Australian Financial Services Licence - AFSL 317817 Source: tradinglounge com       
    • Would love to grab the gem at a little lower...
×
×
  • Create New...
us