HIST Responses Physical

This module computes the price response functions in physical time scale.

To run this part of the code is necessary to have the results from the module HIST Physical Basic Data.

Modules

The code is divided in four parts:
  • Tools: some functions for repetitive actions.
  • Analysis: code to analyze the data.
  • Plot: code to plot the data.
  • Main: code to run the implementation.

Tools

HIST data tools module.

The functions in the module do small repetitive tasks, that are used along the whole implementation. These tools improve the way the tasks are standardized in the modules that use them.

This script requires the following modules:
  • os
  • pickle
  • typing
  • matplotlib
The module contains the following functions:
  • hist_save_data - saves computed data.
  • hist_save_plot - saves figures.
  • hist_function_header_print_data - prints info about the function running.
  • hist_function_header_print_plot - prints info about the plot.
  • hist_start_folders - creates folders to save data and plots.
  • hist_initial_message - prints the initial message with basic information.
  • hist_weeks - tuple with the numbers from 1 to 53 representing the weeks.
  • main - the main function of the script.
hist_data_tools_responses_physical.hist_function_header_print_data(function_name: str, fx_pair: str, year: str, week: str) → None[source]

Prints a header of a function that generates data when it is running.

Parameters:
  • function_name – name of the function that generates the data.
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e ‘2016’).
  • week – string of the week to be analyzed (i.e ‘07’).
Returns:

None – The function prints a message and does not return a value.

hist_data_tools_responses_physical.hist_function_header_print_plot(function_name: str, fx_pair: str, year: str, month: str) → None[source]

Prints a header of a function that generates a plot when it is running.

Parameters:
  • function_name – name of the function that generates the plot.
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e ‘2016’).
  • month – string of the month to be analyzed (i.e ‘07’).
Returns:

None – The function prints a message and does not return a value.

hist_data_tools_responses_physical.hist_initial_message() → None[source]

Prints the initial message with basic information.

Returns:None – The function prints a message and does not return a value.
hist_data_tools_responses_physical.hist_save_data(data: Any, fx_pair: str, year: str) → None[source]

Saves computed data in pickle files.

Saves the data generated in the functions of the hist_data_analysis_responses_physical module in pickle files.

Parameters:
  • data – data to be saved. The data can be of different types.
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e ‘2016’).
Returns:

None – The function saves the data in a file and does not return a value.

hist_data_tools_responses_physical.hist_save_plot(function_name: str, figure: matplotlib.figure.Figure, fx_pair: str, year: str, month: str) → None[source]

Saves plot in png files.

Saves the plot generated in the functions of the hist_data_plot_responses_trade module in png files.

Parameters:
  • function_name – name of the function that generates the plot.
  • figure – figure object that is going to be save.
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e ‘2016’).
  • month – string of the month to be analyzed (i.e ‘07’).
Returns:

None – The function save the plot in a file and does not return a value.

hist_data_tools_responses_physical.hist_start_folders(years: List[str]) → None[source]

Creates the initial folders to save the data and plots.

Parameters:years – List of the strings of the year to be analyzed (i.e [‘2016’, ‘2017’]).
Returns:None – The function creates folders and does not return a value.
hist_data_tools_responses_physical.hist_weeks() → Tuple[str, ...][source]
Generates a tuple with the numbers from 1 to 53 representing the weeks
in a year.
Returns:tuple.
hist_data_tools_responses_physical.main() → None[source]

The main function of the script.

The main function is used to test the functions in the script.

Returns:None.

Analysis

HIST data analysis module.

The functions in the module compute the response function in trade time scale from the Historic Rate Data from HIST Capital data in a year.

This script requires the following modules:
  • itertools
  • multiprocessing
  • os
  • pickle
  • typing
  • numpy
  • pandas
The module contains the following functions:
  • hist_fx_self_response_week_responses_physical - extracts the midpoint price for a week.
  • hist_fx_self_response_year_responses_physical - extracts the midpoint price for a year.
  • main - the main function of the script.

..moduleauthor:: Juan Camilo Henao Londono <www.github.com/juanhenao21>

hist_data_analysis_responses_physical.hist_fx_self_response_week_responses_physical_data(fx_pair: str, year: str, week: str) → Tuple[numpy.ndarray, ...][source]

Computes the self-response of a year.

Using the midpoint price and the trade signs of a ticker computes the self-response during different time lags (\(\tau\)) for a year.

Parameters:
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e. ‘2016’).
  • week – string of the week to be analyzed (i.e. ‘01’).
Returns:

tuple – The function returns a tuple with numpy arrays.

hist_data_analysis_responses_physical.hist_fx_self_response_year_responses_physical_data(fx_pair: str, year: str) → Tuple[numpy.ndarray, ...][source]

Computes the self-response of a year.

Using the hist_self_response_year_responses_physical_data function computes the self-response function for a year.

Parameters:
  • ticker – string of the abbreviation of stock to be analyzed (i.e. ‘AAPL’).
  • year – string of the year to be analyzed (i.e ‘2016’).
Returns:

tuple – The function returns a tuple with numpy arrays.

hist_data_analysis_responses_physical.main() → None[source]

The main function of the script.

The main function is used to test the functions in the script.

Returns:None.

Plot

HIST data plot module.

The functions in the module plot the data obtained in the hist_data_analysis_responses_physical module.

This script requires the following modules:
  • gc
  • pickle
  • typing
  • matplotlib
  • hist_data_tools_data_extract
The module contains the following functions:
  • hist_fx_self_response_year_avg_responses_physical_plot - plots the self-response average for a year.
  • main - the main function of the script.
hist_data_plot_responses_physical.hist_fx_self_response_year_avg_responses_physical_plot(fx_pair: str, year: str) → None[source]

Plots the self-response average for a year.

Parameters:
  • fx_pair – string of the abbreviation of the forex pair to be analyzed (i.e. ‘eur_usd’).
  • year – string of the year to be analyzed (i.e. ‘2016’).
Returns:

None – The function saves the plot in a file and does not return a value.

hist_data_plot_responses_physical.main() → None[source]

The main function of the script.

The main function is used to test the functions in the script.

Returns:None.

Main

HIST data main module.

The functions in the module compute the responses of the Historic Rate data from HIST Capital in a year.

This script requires the following modules:
  • itertools
  • multiprocessing
  • typing
  • hist_data_analysis_responses_physical
  • hist_data_plot_responses_physical
  • hist_data_tools_responses_physical
The module contains the following functions:
  • hist_data_plot_generator - generates all the analysis and plots from the HIST data.
  • main - the main function of the script.
hist_data_main_responses_physical.hist_data_plot_generator(fx_pairs: List[str], years: List[str]) → None[source]

Generates all the analysis and plots from the HIST data.

Parameters:
  • fx_pairs – list of the string abbreviation of the forex pairs to be analyzed (i.e. [‘eur_usd’, ‘gbp_usd’]).
  • years – list of the string of the year to be analyzed (i.e. [‘2016’, ‘2017’]).
Returns:

None – The function saves the data in a file and does not return a value.

hist_data_main_responses_physical.main() → None[source]

The main function of the script.

The main function extract, analyze and plot the data.

Returns:None.