Arbitrage

Submodules

arbitrage module

hardy.arbitrage.arbitrage.apply_tform(raw_df, tform_commands, rgb_col_number=6)[source]

Function that applies transformations

Parameters:
raw_df : pd.DataFrame of raw data from list_of_tuples

Un-Transformed data to apply transform to. This will be a call of list_of_tuples[#][1], because as defined elsewhere, each raw data has one tuple in list, contains (Filename, DataFrame, classifier)

tform_commands : List of Tform Commands

This will be a call of tform_command_dict [tform_command_list[#]], Thus it will contain a list of tform commands: (Index=0, transform, source), (Index=1, transform, source), (Index=2, transform, source), As explained elsewhere

Returns:
tform_df: pd.DataFrame

Each column is placed in “Index”, and gets its name from “source” (New name from SourceColumnName__tform__TformName) Each column’s data is ouput of the tform_1d1d function called and the remainder are passed as zero (with # as col name?)

hardy.arbitrage.arbitrage.import_tform_config(tform_config_path='./tform_config.yaml', raw_df=None)[source]

Function that imports the transformations from configuration

Parameters:
tform_config_path : Str, optional

Path of transform configuration file to apply to the data.

raw_df: pd.DataFrame

Dataframe of raw data to use for assrting that the configuration file is correctly calling on the data

Returns:
tform_command_list : list of str

Ordered list of transform commands to use. Differs from the dict.keys() because this is ordered!

tform_command_dict : dict of List-of-Transform-tuples

Each key will return a list of transforms to do on this data loop. Each “List of Transforms” as stated elsewhere contain:

(Index=0, transform, source), (Index=1, transform, source), (Index=2, transform, source),

where:

“Index” is the output column destination, “transform” is command in transform.list_1d1d, and “source” is the raw data column to be used in the tform

hardy.arbitrage.arbitrage.tform_tuples(list_of_tuples, tform_commands, rgb_format='RGBrgb')[source]

Wrapping function to apply a list of transform commands to each dataframe in the list_of_tuples, and replace it with a same-format list_of_tuples containing transformed data.

Parameters:
list_of_tuples : List of Tuples

Described in depth elsewhere. Standardized list for each raw file, tuple in format (filename_str, DataFrame, label)

tform_commands : List of List(3)

Described in depth elsewhere

rgb_format : str, optional

String of how we will parse the output files. Input here to get the output dataframe size. The default is “RGBrgb”.

Returns:
transformed_tuples : List of Tuples

Formatted the same as the input list, but each DataFrame is replaced with the Transformed DF.

transformations module

hardy.arbitrage.transformations.cumsum(raw_array)[source]

The function return the cumulative sum of input array

Parameters:
raw_array: Input numpy array
Returns:
cumsum _array: np.ndarray

cumulative sum of values in the input array

hardy.arbitrage.transformations.cwt_1d(raw_df, xy=0)[source]

Transform to execute a “Continuous Wavelet Transform” on a 1d data array pass it a raw XY data and tell it which column to use for the transform. See Documentaion on CWT transform: https://docs.scipy.org/doc/scipy/reference/generated/ scipy.signal.cwt.html#scipy.signal.cwt Note: I need to do testing to understand the in/outputs here… Plan is to simply hard-code a certain type of Wavelet to use… and Output Data may not be able to be square… In that case, we will discuss how to integrate this result with the compression of the data.

Parameters:
raw_df: pandas.DataFrame or 1D array (Mx2 or Mx1)

the raw data which is to be transformed.

xy: boolean, or string ‘x’, or ‘y’

information on which dataframe column to transform. ignored if an 1D array is passed instead.

w_method: string or boolean?

input instructions guiding how to choose wavelet sizes. default should be linear, with options for log- or exponential? (Will have to experiment with data to discover best option)

Returns:
cwt_matrix: np.ndarray (MxM)

Square M-by-M matrix of the wavelet transform data (Not yet compressed to plottable 0-1 data)

hardy.arbitrage.transformations.derivative_1d(raw_array, spacing=0)[source]

Function that outputs the gradient of 1-D array using numpy.gradient function

Parameters:
raw_array: numpy array
spacing: int representing the spacing between each datapoint
Returns:
derivative_array: np.ndarray

array representing gradient at each datapoint

hardy.arbitrage.transformations.derivative_2d(x, y, meta_data=None)[source]

Function that outputs the slope between x and y data

Parameters:
x: numpy.array

array representing values on x-axis

y: numpy.array

array representing values on y-axis

Returns:
slope_array: numpy.array

array representing the slope between x and y

hardy.arbitrage.transformations.exp(raw_array)[source]
hardy.arbitrage.transformations.log10(raw_array)[source]

The function that outputs the natural log of input array

Parameters:
raw_array: Input numpy array
Returns:
log_array: np.ndarray

natural log values of each element in the input array

hardy.arbitrage.transformations.nlog(raw_array)[source]

The function that outputs the natural log of input array

Parameters:
raw_array: Input numpy array
Returns:
log_array: np.ndarray

natural log values of each element in the input array

hardy.arbitrage.transformations.power(x, y='None', meta_data=None)[source]

Function that multiplies two arrays x^m & y^n, element by element. If y is None, it return x*x

Parameters:
x: numpy.array

numpy array representing the one array to be multiplied

y: numpy.array

numpy array representing the second array to be multiplied if None it the module will square the x array

Returns:
multi_array: numpy.array

numpy array representing the one to one multiplication of two arrays

hardy.arbitrage.transformations.raw(raw_array)[source]

Function that provides returns data as it is

Parameters:
raw_array: numpy.array

array representing data values

Returns:
raw_array: numpy.array

array representing data values

hardy.arbitrage.transformations.reciprocal(raw_array)[source]

The function the outputs the reciprocal of input array

Parameters:
raw_array: Input numpy array
Returns:
reciprocal_array: np.ndarray

reciprocal values of each element in the input array

Module contents