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  

  • Member Statistics

    • Total Topics
      13,065
    • Total Posts
      66,531
    • Total Members
      88,755
    Newest Member
    Marluca
    Joined 23/11/20 16:52
  • Posts

    • Good article (new) on strategy planning and testing from Steve Burns. https://www.newtraderu.com/2020/10/25/how-to-create-backtest-and-optimize-a-trading-strategy/ "A trading strategy is the process used to enter and exit positions in a market based on quantified signals on when to buy and sell. A trading strategy will have trading plan to express a methodology that defines a trader’s return goals, risk tolerance, and time frame. A successful strategy should have an edge expressed in how trades are entered and managed to maximize gains and minimize losses."
    • (not the cost of Covid-19 but the cost of the govt's disastrous response to a virus that's no more deadly than the common flu) The REAL cost of Covid-19: RUTH SUNDERLAND's terrifying dossier exploring the full economic damage will make you ask... can we afford to keep the brakes on Britain? National debt more than £2 trillion, equivalent of year’s output by entire country  Borrowing from April to October was £170 billion higher than period in 2019  Bank of England believes unemployment rate will to peak at around 7.75 per cent https://www.dailymail.co.uk/news/article-8975765/The-true-cost-Covid-19-Read-RUTH-SUNDERLANDs-terrifying-dossier-economic-damage.html?ito=amp_twitter_share-top
    • Dax and Dow M15;
×
×