forex_response_spread_year

Price response function and spread impact analysis in foreign exchange markets

https://github.com/juanhenao21/forex_response_spread_year

Science Score: 41.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org, zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

econophysics forex-data histdata market-analysis market-microstructure
Last synced: 11 months ago · JSON representation ·

Repository

Price response function and spread impact analysis in foreign exchange markets

Basic Info
  • Host: GitHub
  • Owner: juanhenao21
  • License: mit
  • Language: TeX
  • Default Branch: master
  • Homepage:
  • Size: 19.5 MB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
econophysics forex-data histdata market-analysis market-microstructure
Created over 6 years ago · Last pushed about 4 years ago
Metadata Files
Readme License Citation

README.md

Price response function and spread impact analysis in foreign exchange markets

made-with-python Documentation Status DOI

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 (histresponsestrade), physical time scale (histresponsesphysical) and the impact of the spread (histavgresponses) 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.

Getting Started

The main code is implemented in Python. We use tick data in generic ASCII format from HistData.com.

Prerequisites

For Python, all the packages needed to run the analysis are in the requirements.txt file.

Running the code

The first step is to clone the repository

bash $ 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

bash $ virtualenv -p python3 env $ source env/bin/activate $ pip install -r requirements.txt

Download forex data

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

```Python histdatatoolsdownload.histinitial_message()

Years you want to analyze

years: List[str] = ['2018', '2019']

Forex pairs you want to analyze

fxpairs: List[str] = ['eurusd', 'gbp_usd']

Basic folders

histdatatoolsdownload.histstartfolders(fxpairs, years)

Run analysis

Download data

histdownloadalldata(fxpairs, years) ```

In any case, you need to run the module. In Linux, using the terminal the command looks like

bash $ python3 hist_data_main_download.py

The program will download the data for the corresponding forex pairs.

Forex price responses functions

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.

Trade time scale

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.

Data extraction

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

```Python histdatatoolsextraction.histinitial_message()

Years you want to analyze

years: List[str] = ['2018', '2019']

Forex pairs you want to analyze

fxpairs: List[str] = ['eurusd', 'gbp_usd']

Basic folders

histdatatoolsextraction.histstartfolders(fxpairs, years)

Run analysis

histdataplotgenerator(fxpairs, years) ```

In any case, you need to run the module. In Linux, using the terminal the command looks like

bash $ python3 hist_data_main_extraction.py

The program will compute the values from the corresponding forex pairs.

Price response functions - trade time scale

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

```Python histdatatoolsresponsestrade.histinitialmessage()

Years you want to analyze

years: List[str] = ['2018', '2019']

Forex pairs you want to analyze

fxpairs: List[str] = ['eurusd', 'gbp_usd']

Basic folders

histdatatoolsresponsestrade.histstartfolders(fx_pairs, years)

Run analysis

histdataplotgenerator(fxpairs, years) ```

In any case, you need to run the module. In Linux, using the terminal the command looks like

bash $ python3 hist_data_main_responses_trade.py

The program will compute and plot the values from the corresponding forex pairs.

Physical time scale

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.

Physical basic data

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

```Python histdatatoolsphysicalbasicdata.histinitial_message()

Years you want to analyze

years: List[str] = ['2018', '2019']

Forex pairs you want to analyze

fxpairs: List[str] = ['eurusd', 'gbp_usd']

Basic folders

histdatatoolsphysicalbasicdata.histstartfolders(fxpairs, years)

Run analysis

histdataplotgenerator(fxpairs, years) ```

In any case, you need to run the module. In Linux, using the terminal the command looks like

bash $ python3 hist_data_main_physical_basic_data.py

The program will compute the values from the corresponding forex pairs.

Price response functions - physical time scale

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

```Python histdatatoolsresponsesphysical.histinitialmessage()

Years you want to analyze

years: List[str] = ['2018', '2019']

Forex pairs you want to analyze

fxpairs: List[str] = ['eurusd', 'gbp_usd']

Basic folders

histdatatoolsresponsesphysical.histstartfolders(fx_pairs, years)

Run analysis

histdataplotgenerator(fxpairs, years) ```

In any case, you need to run the module. In Linux, using the terminal the command looks like

bash $ python3 hist_data_main_responses_physical.py

The program will compute and plot the values from the corresponding forex pairs.

VOY AQUI EDITANDO

TAQ Spread Impact

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

bash $ 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

bash $ python3 taq_data_main_avg_responses_physical.py

Expected results

For the response functions, an increase to a maximum followed by a slowly decrease is expected.

Response functions

In the time shift analysis, a change in the relative position between returns and trade signs can vanish the response function signal.

Time shift

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.

Short long

Finally, the spread directly impact the strength of the price response functions. Liquid stocks have smaller price responses.

Spread impact

Authors

  • Juan Camilo Henao Londono - Initial work - Website

Acknowledgments

  • Research Group Guhr Website
  • DAAD Research Grants - Doctoral Programmes in Germany

Owner

  • Name: Juan Henao
  • Login: juanhenao21
  • Kind: user
  • Location: Duisburg
  • Company: auxmoney GmbH

Junior Risk Analyst

Citation (CITATION.md)

To reference the code, process or results in publications, please cite:

IN PROCESS TO START PUBLICATIONS

@article{,
    author =  {},
    title =   {},
    journal = {},
    month =   {},
    year =    {},
}

GitHub Events

Total
  • Pull request event: 1
  • Create event: 1
Last Year
  • Pull request event: 1
  • Create event: 1

Dependencies

requirements.txt pypi
  • histdata ==1.0
  • matplotlib ==3.1.1
  • numpy ==1.17.2
  • pandas ==0.25.3
  • pandocfilters ==1.4.2
  • tables ==3.6.1
  • virtualenv ==15.1.0