#011 | Retrieve & store historical FX rates : Discover

Overview The requirements for the MVP's foreign exchange rate ("FX rate") data provider are: Free access Monthly historical data from at least 2018 onwards FX rates for these currency pairs: USDMYR, SGDMYR, HKDMYR, GBPMYR and JPYMYR Data can be easily retrieved Given the plethora of financial market data providers, I asked ChatGPT for some options based on the MVP's requirements. Selecting an FX rate provider ChatGPT's suggestions were as follows: I decided to prioritise trying Alpha Vantage and Yahoo Finance (via yfinance), as I have heard of these platforms before. Alpha Vantage is backed by Y Combinator and delivers real-time and historical financial market data via Application Programming Interfaces ("API"). yfinance is a free Python library that can be installed via pip. The library scrapes data from Yahoo Finance's extensive, publicly-available financial database and returns it as a dataframe. Option 1: Alpha Vantage This platform offers a lifetime, free usage tier where API consumers can make up to 25 API calls per day. This membership tier is good enough for building MVPs. The API lets users specify whether to return the results in Comma Separated Value ("CSV") or JSON format. I used Postman to a test API call: I also did further tests that confirmed the currency pairs relevant to the MVP's needs could be met. However, one thing I noted is the API does not support customised start and end dates. This potentially makes the API response quite large, and requires additional data transformation handling. Option 2: yfinance I used yfinance’s download() function to retrieve a sample of historical month-end FX rates for the USDMYR. The data is returned as a dataframe, making it quite easy to apply data transformation logic. download() accepts many optional parameters that make it quite easy for users to filter for FX rate data relevant to their needs. For example, the start and end dates can be customised using the start and end parameters. This flexibility is not supported by the Alpha Vantage API. I did further tests that confirmed the currency pairs relevant to the MVP's needs could be met. Next Steps I decided to get FX rate data from yfinance as it meets the MVP's requirements. Although I am not using Alpha Vantage, it can be a good backup in the event any issues arise with yfinance. The next step is to write a script in the MVP's Flask Python backend that: Extracts FX rate data from yfinance Transforms the data Loads the data in a Xano database --Ends

Jan 24, 2025 - 09:56
 0
#011 | Retrieve & store historical FX rates : Discover

Overview

The requirements for the MVP's foreign exchange rate ("FX rate") data provider are:

  1. Free access
  2. Monthly historical data from at least 2018 onwards
  3. FX rates for these currency pairs: USDMYR, SGDMYR, HKDMYR, GBPMYR and JPYMYR
  4. Data can be easily retrieved

Given the plethora of financial market data providers, I asked ChatGPT for some options based on the MVP's requirements.

Selecting an FX rate provider

ChatGPT's suggestions were as follows:

Option

I decided to prioritise trying Alpha Vantage and Yahoo Finance (via yfinance), as I have heard of these platforms before.

Alpha Vantage is backed by Y Combinator and delivers real-time and historical financial market data via Application Programming Interfaces ("API").

yfinance is a free Python library that can be installed via pip. The library scrapes data from Yahoo Finance's extensive, publicly-available financial database and returns it as a dataframe.

Option 1: Alpha Vantage

This platform offers a lifetime, free usage tier where API consumers can make up to 25 API calls per day. This membership tier is good enough for building MVPs.

The API lets users specify whether to return the results in Comma Separated Value ("CSV") or JSON format. I used Postman to a test API call:

alpha vantage api

I also did further tests that confirmed the currency pairs relevant to the MVP's needs could be met.

However, one thing I noted is the API does not support customised start and end dates. This potentially makes the API response quite large, and requires additional data transformation handling.

Option 2: yfinance

I used yfinance’s download() function to retrieve a sample of historical month-end FX rates for the USDMYR. The data is returned as a dataframe, making it quite easy to apply data transformation logic.

script

download() accepts many optional parameters that make it quite easy for users to filter for FX rate data relevant to their needs.

yfinance parameters

For example, the start and end dates can be customised using the start and end parameters. This flexibility is not supported by the Alpha Vantage API.

I did further tests that confirmed the currency pairs relevant to the MVP's needs could be met.

Next Steps

I decided to get FX rate data from yfinance as it meets the MVP's requirements. Although I am not using Alpha Vantage, it can be a good backup in the event any issues arise with yfinance.

The next step is to write a script in the MVP's Flask Python backend that:

  1. Extracts FX rate data from yfinance
  2. Transforms the data
  3. Loads the data in a Xano database

--Ends

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow