Jump to content
  • 0

Decimal diplacement in IG API fetched historical data


Question

Hi! It is possible that the IG API is returning weird prices (comma misplacement) for example for EURUSD when historical prices are fetched.

Data looks like this:

                     ask_Open  ask_High  ...  bid_Close  last_Volume
DateTime                                 ...                        
2024-05-01 00:00:00   10667.9   10668.1  ...    10665.6          516
2024-05-01 01:00:00   10666.7   10667.7  ...    10661.4          859
2024-05-01 02:00:00   10662.1   10663.6  ...    10660.4          571
2024-05-01 03:00:00   10660.9   10660.9  ...    10658.6          440
 

Code snippet:

fetched_data = self.ig_service.fetch_historical_prices_by_epic_and_date_range(epic, granularity, start_date=start_datetime, end_date=end_datetime)
if fetched_data:  # Assuming fetched_data is a dictionary containing 'prices'


    fetched_df = pd.DataFrame(fetched_data['prices'])
    print(f"Fetched {len(fetched_df)} rows of data in granularity {granularity} from IG server")

    # Flatten the columns using a list comprehension
    fetched_df.columns = ['_'.join(col).strip() for col in fetched_df.columns.values]
    keep_cols = ["ask_Open", "ask_High", "ask_Low", "ask_Close", "bid_Open", "bid_High",
                 "bid_Low", "bid_Close","last_Volume"]

    fetched_df = fetched_df[keep_cols]

    print("fetched new data from IG server")

    print(fetched_df)

 

Link to comment

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

That's without a doubt your interpretation and implementation of it. the API returns prices as JSON, so just parse it accordingly. The commas would be on your client side not coming from the server side. Why not use Pandas Dataframes natively, they are amazing at processing this kind of stuff. 

Edited by TheGuru12
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

    • Bit Starz, a leading online casino known for its extensive selection of slots and table games, is offering an exciting promotion in 2024. By using the promo code “hella”, players can receive a generous 240 free spins, providing ample opportunities to win big on popular slot games. Overview of Bit Starz: Bit Starz is renowned for its wide variety of high-quality casino games, including slots, table games, and live dealer options. The platform is praised for its user-friendly interface, fast withdrawal times, and excellent customer support. Bit Starz accepts multiple currencies, including cryptocurrencies, making it a versatile choice for players worldwide. Promo Code and Bonus: Promo Code: hella Bonus: 240 free spins How to Use the Promo Code: Visit Bit Starz: Open your web browser and go to the Bit Starz website. Sign Up or Log In: If you are a new user, click on the “Sign Up” button to create a new account. You will need to provide your email, create a username, and set a password. If you already have an account, click on the “Log In” button and enter your credentials to access your account. Navigate to the Promotions Section: Once logged in, go to the promotions or bonuses section of your account. Enter the Promo Code: In the promo code field, type “hella” and click on the “Submit” or “Redeem” button. Claim Your Free Spins: After entering the code, you will instantly receive 240 free spins. These spins can be used on selected slot games available on Bit Starz. Benefits of the Promotion: The 240 free spins offer a significant advantage to both new and existing players. Free spins allow players to try out various slot games without risking their own money. This bonus can lead to substantial winnings, enhancing the overall gaming experience. Tips for Maximizing Your Bonus: Explore Different Games: Use your free spins to try different slot games on the platform. This helps in discovering which games you enjoy the most and where you have the best chances of winning. Check Game Contributions: Some games contribute more to wagering requirements than others. Make sure to play games that count significantly towards fulfilling these requirements. Stay Informed: Regularly check the promotions page for additional offers that can further boost your balance or provide extra rewards. By following these steps and using the promo code “hella”, you can maximize your gaming experience on Bit Starz. Enjoy the excitement and potential winnings with this generous 240 free spins bonus in 2024.
    • Unlock $0.15 in free coins on Bandit.camp in 2024 with the promo code “hellagood”. Bandit.camp is a popular gambling platform for CSGO players, offering various betting games and case openings. By using the code “hellagood”, players can start playing without any initial deposit, giving them a chance to explore the platform and potentially win big. How to Claim: Log In or Sign Up: Visit the Bandit.camp website and log in or create a new account. Access Promo Area: Navigate to the promo code section. Enter Code: Use “hellagood” in the designated field. Claim Free Coins: Receive $0.15 in free coins to use on the platform. This promotion is perfect for both new and existing players looking to explore Bandit.camp and enjoy their favorite games with extra funds. Take advantage of this offer to enhance your gaming experience and increase your chances of winning in 2024.
    • Get 30 free coins on CSGOLuck in 2024 by using the promo code “HELLAGOOD”. CSGOLuck is a well-known platform for CSGO betting games and case openings. By using the code “HELLAGOOD”, players can receive 30 free coins to enhance their gaming experience and increase their chances of winning. How to Claim: Sign Up or Log In: Visit the CSGOLuck website and create an account or log in to your existing one. Access Promo Section: Navigate to the promo code area. Input Code: Enter “HELLAGOOD” in the designated field. Claim Free Coins: Receive 30 free coins to use on the platform. This promotion is ideal for both new and existing players looking to maximize their gaming opportunities on CSGOLuck. Take advantage of this exclusive offer to enjoy free coins and enhance your chances of winning big.
×
×
  • Create New...
us