Skip to content

Front_end Module

Collection of front-end utilities, for rendering Custom Analytics jobs results in the KYOS Analytical Platform.

Changelog

Version Description
3.4.16 Method PlatformGraphs.save2disk() updated. Optional input arguments for the legend settings
3.4.12 Class PlatformGraphs added.
2.1.0 function make_bar_column_chart and make_basic_line_chart added.
1.4.6 Module front_end added.

Documentation

PlatformGraphs()

Bases: object

Handle the mapping of plotly graphs to a format which can be displayed by the KYOS platform. There can be at most one instance of this class (singleton design pattern).

save2disk(fig, filename, xanchor='left', yanchor='bottom', orientation='h', x=0.1, y=-0.075)

Save a plotly graph object in a json format and in a proper location on the KYOS servers.

Parameters:

Name Type Description Default
fig graph_objects

a fully built plotly figure

required
filename str

under what filename should the graph be saved on the server's hard-disk. Note that the filename plays a role in the order of displaying graphs in the fornt end.

required
xanchor str)

(Optional) One of ( "auto" | "left" | "center" | "right" ) Sets the title's horizontal alignment with respect to its x position. "left" means that the title starts at x. Default:"left"

'left'
yanchor str)

(Optional) One of ( "auto" | "top" | "middle" | "bottom" ) Sets the title's vertical alignment with respect to its y position. "top" means that the title's cap line is at y. Default:"bottom"

'bottom'
orientation str)

(Optional) one of ( "v" | "h" ). Sets the orientation of the legend. Default:"h"

'h'
x float

(Optional) number between or equal to -2 and 3 Sets the x position (in normalized coordinates) of the legend. KYOS Platform Defaults to 0.1

0.1
y float

(Optional) number between or equal to -2 and 3 Sets the y position (in normalized coordinates) of the legend. KYOS Platform Defaults to -0.075

-0.075

Examples:

>>> graph_object = PlatformGraphs()
>>> fig = px.histogram()
>>> graph_object.save2disk(fig, filename="001_option_value")

A class to handle the mapping of plotly graphs to a format which can be displayed by the KYOS platform

make_platform_histogram()

Build a histogram based on one or more value series. The histogram will be displayed dynamically in the Kyos Analytical Platform.

Parameters:

Name Type Description Default
values ndarray

a histogram is built for each value series. The min/max of the histogram buckets is based on the smallest/biggest element of all series. [shape = (n_rows, n_series)]

required
values_names list

a list of string names for each series. [len = n_series]

required
n_bins int

how many bins should be used in the histogram.

'auto'
title string

title of the histogram

' '
output_filename string

beginning of the name of the output json file. It can be used to order how graphs are displayed in the platform. Graph with start of the name "001_" will be displayed first.

'name'
Note

The histogram graph is build using the "Highcharts" package. For more info refer to HighCharts

Examples:

>>> make_platform_histogram(values=values, values_names=['Value'],
>>>                         title='Total Option Value (EUR)',
>>>                         n_bins=20, output_filename='001_option_value')

A dynamic histogram is created as an output. It is rendered in the Graphs tab of a Custom Analytics job:

Histogram

make_platform_table()

Function which outputs a pandas dataframe in a format which can be displayed in the KYOS platform.

Parameters:

Name Type Description Default
df Dataframe

A single row index is allowed. Multiple column indexes are allowed.

required
bold_row_name bool

Display the row name in bold font when showing it in the platform front-end

True
bold_column_name bool

Display the column name in bold font when showing it in the platform front-end

True
columns_names None | list

None: use the column names of the dataframe | list of list: user defined columns names (should include name for the row index as well)

None
Notes

The data in the dataframe saved in a csv file in the desired format.

Examples:

>>> make_platform_table(data_df, '001_Option_Value', bold_column_name=True)

A well formatted table is created as an output. It is rendered in the Table tab of a Custom Analytics job:

Table

make_bar_column_chart()

Build a bar column chart based on one or more value series. The chart will be displayed dynamically in the Kyos Analytical Platform.

Parameters:

Name Type Description Default
values ndarray

y axis values [shape = (n_rows, n_series)]

required
values_names list

a list of string names for each series. [len = n_series]

required
is_stacked bool

indicator for chart type. basic column and stacked column chart supported False: Basic column chart True: Stacked column chart

False
x_axis None | list

list of x-axis values None: integer values will be used [1,2,3 .......] list: user defined x axis names (e.g. dates)

None
title string

title of the chart

' '
y_axis_title string

title of the y-axis

'values'
output_filename string

beginning of the name of the output json file. It can be used to order how graphs are displayed in the platform. Graph with start of the name "001_" will be displayed first.

'name'
unit_name string

unit name of the values

'unit'
Note

The histogram graph is build using the "Highcharts" package. For more info refer to HighCharts

Examples:

>>> make_bar_column_chart(values=np.zeros((2,2)), values_names=['series_1', 'series_2'],is_stacked=True,
>>> x_axis=['2019-01-01', '2019-01-02'], title='Daily Positions', y_axis_title='Positions',
>>> output_filename='001_option_value', unit_name='Lots')

A dynamic column chart is created as an output. It is rendered in the Graphs tab of a Custom Analytics job:

Chart

make_basic_line_chart()

Build a bar column chart based on one or more value series. The chart will be displayed dynamically in the Kyos Analytical Platform.

Parameters:

Name Type Description Default
values ndarray

y axis values [shape = (n_rows, n_series)]

required
values_names list

a list of string names for each series. [len = n_series]

required
x_axis None | list

list of x-axis values None: integer values will be used [1,2,3 .......] list: user defined x axis names (e.g. dates)

None
title string

title of the chart

' '
y_axis_title string

title of the y-axis

'values'
output_filename string

beginning of the name of the output json file. It can be used to order how graphs are displayed in the platform. Graph with start of the name "001_" will be displayed first.

'name'
unit_name string

unit name of the values

'unit'
Note

The histogram graph is build using the "Highcharts" package. For more info refer to HighCharts

Examples:

>>> make_basic_line_chart(values=np.zeros((2,2)), values_names=['series_1', 'series_2'],
>>> x_axis=['2019-01-01', '2019-01-02'], title='Daily Positions', y_axis_title=' ',
>>> output_filename='001_option_value', unit_name='Lots')

A dynamic line chart is created as an output. It is rendered in the Graphs tab of a Custom Analytics job:

Chart