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
      23,569
    • Total Posts
      96,877
    • Total Members
      44,143
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    crh_55
    Joined 29/11/23 20:23
  • Posts

    • Investing in crypto could be challenging especially the Fear of Missing out Lambo. This mostly affect traders trading strategy and ideology. Predicting the right time to buy is always cumbersome and that is why many analyst advise DCA because it curtails FOMO and gives you a long-term crypto trading mentality. In crypto Dollar Cost Averaging involves investing the same amount of money in a target token at regular intervals over a certain period of time, regardless of price. This will help to control volatility on your portfolios and minimize FOMO For example when you decide to invest $100 on a token and invest $10 daily or weekly or monthly till you fulfilled you $100 target investment on the token irrespective of the price of the token. This strategy helps a crypto trader to build his portfolio over the long term thereby he/she is not bothered by short-term volatility in the broader markets. This strategy mostly favours low-budget traders in building a strong portfolio but the problem most normally encounter is exchange minimum trading amount. One analyst advised on how to mitigate this was to accumulate on exchange that has lower trading fees and later send to where you desire to hold. He also noted that some of this exchanges are good in listing good projects for you to be among the early birds. Do you think DCA is the best method to accumulate token and which exchange offers the lowest tradeable balance and trading fees?
    • DXY   now wait for confirmation or rejection 
    • Messi has written his name in the sands of time. I dare say he is immortal, he has challenged and excelled all limits to the point he is now the new limit. This partnership is GOATED cos it has brought more exposure for the exchange considering MESSI's popularity.    
×
×
  • Create New...
us