HIST Average Responses

To be done …

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.
  • main - the main function of the script.
hist_data_tools_avg_responses.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_avg_responses.hist_function_header_print_plot(function_name: str, fx_pair: str, year: 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’).
Returns:

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

hist_data_tools_avg_responses.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_avg_responses.hist_save_data(function_name: str, data: Any, fx_pair: str, year: str, week: str) → None[source]

Saves computed data in pickle files.

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

Parameters:
  • function_name – name of the function that generates the data.
  • 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’).
  • week – string of the week to be analyzed (i.e ‘07’).
Returns:

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

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

Saves plot in png files.

Saves the plot generated in the functions of the hist_data_plot_avg_responses_physical 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
  • year – string of the year to be analyzed (i.e ‘2016’).
Returns:

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

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

Creates the initial folders to save the data and plots.

Parameters:years – list of string of the years to be analyzed (i.e [‘2016’, ‘2017’]).
Returns:None – The function creates folders and does not return a value.
hist_data_tools_avg_responses.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 average response function in trade and physical time scale from the Historic Rate Data from HIST Capital data in a year.

This script requires the following modules:
  • pickle
  • typing
  • numpy
  • pandas
  • hist_data_tools_avg_responses_physical
The module contains the following functions:
  • hist_tickers_spread_data - obtains the tickers and the spread for the classification.
  • hist_self_response_year_avg_responses_trade_data - computes the average self response for groups of tickers in a year in trade time scale.
  • hist_self_response_year_avg_responses_physical_data - computes the average self response for groups of tickers in a year in physical time scale.
  • main - the main function of the script.
hist_data_analysis_avg_responses.hist_fx_pair_spread_data(year: str) → List[List[str]][source]

Obtains the tickers and the spread range for the classification.

Parameters:year – string of the year to be analyzed (i.e. ‘2016’).
Returns:list – The function returns a list of lists with forex pairs.
hist_data_analysis_avg_responses.hist_fx_self_response_year_avg_responses_physical_data(fx_pairs: List[List[str]], year: str) → Tuple[numpy.ndarray, ...][source]

Computes the avg self-response for groups of tickers in a year.

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

tuple – The function returns a tuple with numpy arrays.

hist_data_analysis_avg_responses.hist_fx_self_response_year_avg_responses_trade_data(fx_pairs: List[List[str]], year: str) → Tuple[numpy.ndarray, ...][source]

Computes the avg self-response for groups of tickers in a year.

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

tuple – The function returns a tuple with numpy arrays.

hist_data_analysis_avg_responses.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_avg_responses module.

This script requires the following modules:
  • matplotlib
  • pickle
  • hist_data_tools_avg_responses
The module contains the following functions:
  • hist_fx_self_response_year_avg_responses_trade_plot - plots the self-response average for a year in trade time scale.
  • hist_fx_self_response_year_avg_responses_physical_plot - plots the self-response average for a year in physical time scale.
  • main - the main function of the script.
hist_data_plot_avg_responses.hist_fx_self_response_year_avg_responses_physical_plot(year: str) → None[source]

Plots the self-response average for a year.

Parameters:year – string of the year to be analyzed (i.e ‘2008’).
Returns:None – The function saves the plot in a file and does not return a value.
hist_data_plot_avg_responses.hist_fx_self_response_year_avg_responses_trade_plot(year: str) → None[source]

Plots the self-response average for a year.

Parameters:year – string of the year to be analyzed (i.e ‘2008’).
Returns:None – The function saves the plot in a file and does not return a value.
hist_data_plot_avg_responses.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 run the complete extraction, analysis and plot of the HIST data.

This script requires the following modules:
  • typing
  • hist_data_analysis_avg_responses
  • hist_data_plot_avg_responses
  • hist_data_tools_avg_responses
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_avg_responses.hist_data_plot_generator(years: List[str]) → None[source]

Generates all the analysis and plots from the HIST data.

Parameters:years – List of the strings 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_avg_responses.main() → None[source]

The main function of the script.

The main function extract, analyze and plot the data.

Returns:None.