comdirect_status_report.py¶
Automation script to present the data collected from Comdirect. The data used are the Excel files stored in the export folder. To keep compatibility with older data stored, historical data stored in a CSV file, in the same folder and named History_Aggregated.csv, will also be parsed and used. For the former part, only the files matching the pattern Export_Comdirect_ are evaluated, so any other files in the folder will be ignored.
The script has an approach of parsing the data supplied and aggregate them, forming longer and multiple dataframes.
The end goal is to summarize the data in the dashboard by using charts or tables, to best present the information. The elements composing the page are:
Chart with the complete aggregated from the account.
Chart with split current values for all the depots.
Chart with relative gains/loses for each depot, based on a starting point in time, to which the value is zeroed and calculated relative to it. For this chart, a dropdown menu is available, so the user can select the timespam for analysis.
Table with the complete aggregated from the account.
Table with split current values for all the depots for the current day.
Table with split current values for all the depots.
This script is based on Dash and Plotly, and the execution will result into a server which can be accessed by the addressed informed on the console, for example: http://127.0.0.1:8050/
- automation.comdirect_status_report.convert_hex_to_rgba(color_sequence: list, opacity: float)¶
Converts a list of Hex based values to a RGBA equivalent list. The alpha channel component is provenient from the
opacity
input.
- automation.comdirect_status_report.create_chart_account_aggregated_values()¶
Create a chart with all the account aggregated values. If the dataframe for the historical data is available (different from
None
) it will also be plotted, otherwise it is not included.- Parameters
None – This method uses data available from the script, created outside the method.
- Returns
figure – Resulting graph with data and configuration.
- Return type
Plotly Graph Object
- automation.comdirect_status_report.create_combined_dataframes(folder: pathlib.Path, date_today: str)¶
- automation.comdirect_status_report.create_filtered_depots_dataframe(timespam: str)¶
Creates the percentual incremental dataframe. This dataframe will start each signal from 0 value (gain/loss) and then produce incremental steps based on the daily gain or loss.
This method is used a callback since it needs to be called for the dropdown menu in the Dash dashboard.
The operation takes a few steps:
Copy of the Depot dataframe
Cut-off (filter out) data before a desidered target. This step is important, since the data will be displayed in reference to the new start.
Add a new row to cover for cases when the first invesrtiment comes after the cut-off date, otherwise they will have an offset in the operation due to losing the first entry.
Builds up the list of changes to add to the dataframe.
- automation.comdirect_status_report.create_historical_aggregated_dataframe(folder: pathlib.Path)¶
- automation.comdirect_status_report.create_line_chart(dataframe: pandas.core.frame.DataFrame, group_by: str, x_column: str, y_column: str, color_lines: list, color_fills: list, opacity_lines: float, opacity_fills: float, line_width: float, x_label: str, y_label: str, stack_group: Optional[str] = None)¶
Create a line chart.
- Parameters
dataframe (Pandas Dataframe) – Dataframe with the data to be plotted.
group_by (str) – Name of the column in the Dataframe to be used a grouper.
x_column (str) – Name of the column in the Dataframe to be used as X data.
y_column (str) – Name of the column in the Dataframe to be used as Y data.
color_lines (List of str) – List of strings with the hex values represening the colors to be used in sequence for the lines. Each color need to represented by a hash symbol (#) followed by 3 pairs of characters, to represent the RGB information.
color_fills (List of str) – List of strings with the hex values represening the colors to be used in sequence for the fills. Each color need to represented by a hash symbol (#) followed by 3 pairs of characters, to represent the RGB information.
opacity_lines (float) – Value between 0 and 1 to define the opacity of the colors for the lines. This is the alpha channel. A value of 0 means full transparency, while the value 1 means full opaque.
opacity_fills (float) – Value between 0 and 1 to define the opacity of the colors for the fills. This is the alpha channel. A value of 0 means full transparency, while the value 1 means full opaque.
line_width (float) – Width of the lines in plot.
x_label (str) – String with the name of label to be used as the title for the X axis.
y_label (str) – String with the name of label to be used as the title for the Y axis.
stack_group (str, optional) – Name of the group to stack the plots. If no stacking is desired, value
`None
need to be assigned.
- Returns
figure – Resulting graph with data and configuration.
- Return type
Plotly Graph Object
- automation.comdirect_status_report.define_timespam(timespam: str)¶
Converts a string input with a timespam and returns the start date from today.
- automation.comdirect_status_report.update_output(value)¶