In this repository, I analyzed the price response functions of the foreign exchange market data for different years,
I use the same methodology from my work in the project Price response function and spread impact analysis in correlated financial markets (paper) to compute all the analysis. From the data I obtain the midpoint prices, trade signs and self-responses for different foreign exchange pairs.
Based on these values, I analyze price response functions in trade time scale (hist_responses_trade), physical time scale (hist_responses_physical) and the impact of the spread (hist_avg_responses) in the strength of the response functions in trade and physical time scale.
All the results and figures obtained using the modules in the repository will
be saved in the folders forex_response_spread_year/project/hist_data
and
forex_response_spread_year/project/hist_plot
.
You can find here a detailed documentation of the code.
The main code is implemented in Python
. We use tick data in generic ASCII
format from
HistData.com.
For Python
, all the packages needed to run the analysis are in the
requirements.txt
file.
The first step is to clone the repository
$ git clone https://github.com/juanhenao21/forex_response_spread_year.git
To install all the needed Python
packages I recommend to create a virtual
environment and install them from the requirements.txt
file. To install the
packages from terminal, you can use
$ virtualenv -p python3 env
$ source env/bin/activate
$ pip install -r requirements.txt
To download the forex data, you need to move (cd) to the folder
forex_response_spread_year/project/hist_download_data/hist_algorithms/
.
If you want to get my results, you just need to run the module
hist_data_main_download.py
. If you want to select other years or forex pairs
you have to change all the contents of the main function and add the following
hist_data_tools_download.hist_initial_message()
# Years you want to analyze
years: List[str] = ['2018', '2019']
# Forex pairs you want to analyze
fx_pairs: List[str] = ['eur_usd', 'gbp_usd']
# Basic folders
hist_data_tools_download.hist_start_folders(fx_pairs, years)
# Run analysis
# Download data
hist_download_all_data(fx_pairs, years)
In any case, you need to run the module. In Linux, using the terminal the command looks like
$ python3 hist_data_main_download.py
The program will download the data for the corresponding forex pairs.
The forex price response functions can be obtained in two time scales: trade and physical time scale. In the following sections I describe in detail how to run both.
To obtain the price response functions in trade time scale you need to run the code in the Data extraction section and run the code in the Price response functions - trade time scale section.
To extract the midpoint price and the trade signs from the data, you need to
move (cd) to the folder
forex_response_spread_year/project/hist_data_extraction/hist_algorithms/
.
If you want to get my results, you just need to run the module
hist_data_main_extraction
. If you want to select other years or forex pairs
you have to change all the contents of the main function and add the following
hist_data_tools_extraction.hist_initial_message()
# Years you want to analyze
years: List[str] = ['2018', '2019']
# Forex pairs you want to analyze
fx_pairs: List[str] = ['eur_usd', 'gbp_usd']
# Basic folders
hist_data_tools_extraction.hist_start_folders(fx_pairs, years)
# Run analysis
hist_data_plot_generator(fx_pairs, years)
In any case, you need to run the module. In Linux, using the terminal the command looks like
$ python3 hist_data_main_extraction.py
The program will compute the values from the corresponding forex pairs.
To compute the price response functions from the data, you need to move (cd) to
the folder
forex_response_spread_year/project/hist_responses_trade/hist_algorithms/
.
If you want to get my results, you just need to run the module
hist_data_main_responses_trade
. If you want to select other years or forex
pairs you have to change all the contents of the main function and add the
following
hist_data_tools_responses_trade.hist_initial_message()
# Years you want to analyze
years: List[str] = ['2018', '2019']
# Forex pairs you want to analyze
fx_pairs: List[str] = ['eur_usd', 'gbp_usd']
# Basic folders
hist_data_tools_responses_trade.hist_start_folders(fx_pairs, years)
# Run analysis
hist_data_plot_generator(fx_pairs, years)
In any case, you need to run the module. In Linux, using the terminal the command looks like
$ python3 hist_data_main_responses_trade.py
The program will compute and plot the values from the corresponding forex pairs.
To obtain the price response functions in physical time scale you need to run first the code in the Data extraction section, and then run the code in the Physical basic data section and run the code in the Price response functions - physical time scale section.
To compute the midpoint price and the trade signs in physical time scale, you
need to move (cd) to the folder
forex_response_spread_year/project/hist_physical_basic_data/hist_algorithms/
.
If you want to get my results, you just need to run the module
hist_data_main_physical_basic_data
. If you want to select other years or
forex pairs you have to change all the contents of the main function and add
the following
hist_data_tools_physical_basic_data.hist_initial_message()
# Years you want to analyze
years: List[str] = ['2018', '2019']
# Forex pairs you want to analyze
fx_pairs: List[str] = ['eur_usd', 'gbp_usd']
# Basic folders
hist_data_tools_physical_basic_data.hist_start_folders(fx_pairs, years)
# Run analysis
hist_data_plot_generator(fx_pairs, years)
In any case, you need to run the module. In Linux, using the terminal the command looks like
$ python3 hist_data_main_physical_basic_data.py
The program will compute the values from the corresponding forex pairs.
To compute the price response functions from the data, you need to move (cd) to
the folder
forex_response_spread_year/project/hist_responses_physical/hist_algorithms/
.
If you want to get my results, you just need to run the module
hist_data_main_responses_physical
. If you want to select other years or forex
pairs you have to change all the contents of the main function and add the
following
hist_data_tools_responses_physical.hist_initial_message()
# Years you want to analyze
years: List[str] = ['2018', '2019']
# Forex pairs you want to analyze
fx_pairs: List[str] = ['eur_usd', 'gbp_usd']
# Basic folders
hist_data_tools_responses_physical.hist_start_folders(fx_pairs, years)
# Run analysis
hist_data_plot_generator(fx_pairs, years)
In any case, you need to run the module. In Linux, using the terminal the command looks like
$ python3 hist_data_main_responses_physical.py
The program will compute and plot the values from the corresponding forex pairs.
To run this part of the code, you need to move (cd) to the folder
financial_response_spread_year/project/taq_avg_spread/taq_algorithms/
and run the module taq_data_main_avg_spread.py
. In Linux,
using the terminal the command looks like
$ python3 taq_data_main_avg_spread.py
This analysis is recommended to be done with several stocks. The key point is that all the stocks used have to have already the self-response function analysis of the first part (TAQ Responses Physical).
After run the taq_data_main_avg_spread.py
module, you can move (cd) to the
folder
financial_response_spread_year/project/taq_avg_responses_physical/taq_algorithms/
and run the module taq_data_main_avg_responses_physical.py
. In Linux, using
the terminal the command looks like
$ python3 taq_data_main_avg_responses_physical.py
For the response functions, an increase to a maximum followed by a slowly decrease is expected.
In the time shift analysis, a change in the relative position between returns and trade signs can vanish the response function signal.
Dividing the time lag used in the returns, we obtain a short and long response function, where the short component has a large impact compared with the long component.
Finally, the spread directly impact the strength of the price response functions. Liquid stocks have smaller price responses.
- Juan Camilo Henao Londono - Initial work - Website
- Research Group Guhr Website
- DAAD Research Grants - Doctoral Programmes in Germany