HIST Physical Basic Data

This module obtains the information from the data extracted with the module HIST Data Extraction. We obtain the time, best ask, best bid, midpoint price, spread and trade signs in physical time scale.

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

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:
  • matplotlib
  • os
  • pandas
  • pickle
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 - generates a tuple with the number of weeks in a year.
  • main - the main function of the script.
hist_data_tools_physical_basic_data.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_physical_basic_data.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_physical_basic_data.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_physical_basic_data.hist_save_data(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_extraction 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’).
  • 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_physical_basic_data.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_data_extraction 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_physical_basic_data.hist_start_folders(years: List[str]) → None[source]

Creates the initial folders to save the data and plots.

Parameters:year – string of the year to be analyzed (i.e ‘2016’).
Returns:None – The function creates folders and does not return a value.
hist_data_tools_physical_basic_data.hist_weeks() → Tuple[str, ...][source]
Generates a tuple with the numbers from 0 to 53 representing the weeks
in a year.
Returns:tuple.
hist_data_tools_physical_basic_data.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 obtain the midpoint price and the trade signs in physical time scale for HIST Capital in a year.

This script requires the following modules:
  • pickle
  • typing
  • datetime
  • numpy
  • pandas
  • hist_data_tools_physical_basic_data
The module contains the following functions:
  • hist_fx_physical_data - 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_physical_basic_data.hist_fx_physical_data(fx_pair: str, year: str, week: str) → None[source]

Extracts the midpoint price 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. ‘2019’).
  • week – string of the week to be analyzed (i.e. ‘01’).
Returns:

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

hist_data_analysis_physical_basic_data.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_physical_basic_data module.

This script requires the following modules:
  • gc
  • pickle
  • typing
  • matplotlib
  • pandas
  • hist_data_tools_data_extract
The module contains the following functions:
  • hist_fx_midpoint_year_plot - plots the forex quotes for a year.
  • main - the main function of the script.
hist_data_plot_physical_basic_data.hist_fx_midpoint_year_plot(fx_pair: str, year: str, weeks: Tuple[str, ...]) → None[source]

Plots the midpoint price 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’).
  • weeks – tuple of the strings of the weeks to be analyzed (i.e. [‘01’, ‘02’]).
Returns:

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

hist_data_plot_physical_basic_data.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 extract and plot the Historic Rate data from HIST Capital in a year.

This script requires the following modules:
  • itertools
  • multiprocessing
  • typing
  • hist_data_analysis_physical_basic_data
  • hist_data_plot_extraction
  • hist_data_tools_physical_basic_data
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_physical_basic_data.hist_data_plot_generator(fx_pairs: List[str], years: List[str], weeks: Tuple[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 strings of the year to be analyzed (i.e. [‘2016’, ‘2017’]).
  • weeks – tuple of the strings of the weeks to be analyzed (i.e. [‘01’, ‘02’]).
Returns:

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

hist_data_main_physical_basic_data.main() → None[source]

The main function of the script.

The main function extract, analyze and plot the data.

Returns:None.