Jump to content
  • 0
Sign in to follow this  

Python programming help

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

 

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 0

Hi panja, I keep my code in this repository. You can see that there is an example of how I authenticate with Python.

https://github.com/oneangrytrader/brokerapiclients

I mainly use C# to send my trades, so you will see that library has more methods than the Python one.  But I am happy to add anything to the Python side if you need it. 

 

  • Great! 1

Share this post


Link to post
  • 0

Thx. Will have a look.

 

Share this post


Link to post
  • 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

Share this post


Link to post

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
You are posting as a guest. If you have an account, please sign in.
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×