How to use the zvt.drawer.drawer.Drawer function in zvt

To help you get started, we’ve selected a few zvt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zvtvz / zvt / zvt / trader / trader.py View on Github external
def on_finish(self):
        # show the result
        import plotly.io as pio
        pio.renderers.default = "browser"
        reader = AccountReader(trader_names=[self.trader_name])
        drawer = Drawer(main_data=NormalData(reader.data_df.copy()[['trader_name', 'timestamp', 'all_value']],
                                             category_field='trader_name'))
        drawer.draw_line()
github zvtvz / zvt / zvt / factors / target_selector.py View on Github external
width=None,
             height=None,
             title=None,
             keep_ui_state=True,
             annotation_df=None,
             target_type: TargetType = TargetType.open_long):

        if target_type == TargetType.open_long:
            df = self.open_long_df.copy()
        elif target_type == TargetType.open_short:
            df = self.open_short_df.copy()

        df['target_type'] = target_type.value

        if pd_is_not_null(df):
            drawer = Drawer(
                NormalData(df=df, annotation_df=annotation_df, time_field='timestamp', is_timeseries=True))

            drawer.draw_table(render=render, file_name=file_name, width=width, height=height, title=title,
                              keep_ui_state=keep_ui_state)
github zvtvz / zvt / zvt / factors / factor.py View on Github external
def result_drawer(self) -> Drawer:
        return Drawer(NormalData(df=self.result_df))
github zvtvz / zvt / zvt / apps / data_app.py View on Github external
# if sort_by:
        #     dff = dff.sort_values(
        #         [col['entity_id'] for col in sort_by],
        #         ascending=[
        #             col['direction'] == 'asc'
        #             for col in sort_by
        #         ],
        #         inplace=False
        #     )

        if intent in (IntentType.compare_self.value, IntentType.compare_to_other.value):
            graph_data, graph_layout = Drawer(NormalData(dff)).draw_compare(chart=chart, property_map=property_map,
                                                                            render=None, keep_ui_state=False)
        else:
            graph_data, graph_layout = Drawer(NormalData(dff)).draw(chart=chart, property_map=property_map, render=None,
                                                                    keep_ui_state=False)

        table_data = dff.iloc[page_current * page_size: (page_current + 1) * page_size
                     ].to_dict('records')

        return table_data, \
               dcc.Graph(
                   id='chart-content',
                   figure={
                       'data': graph_data,
                       'layout': graph_layout
                   }
               )

    raise dash.exceptions.PreventUpdate()
github zvtvz / zvt / zvt / drawer / drawer.py View on Github external
ay=-30,
                        bordercolor='#c7c7c7',
                        borderwidth=1,
                        bgcolor=color,
                        opacity=0.8
                    ))

    return annotations


if __name__ == '__main__':
    df = get_data(data_schema=Stock1dKdata, provider='joinquant', entity_ids=['stock_sz_000001', 'stock_sz_000002'])
    df1 = get_data(data_schema=Stock1dMaStateStats, provider='zvt', entity_ids=['stock_sz_000001', 'stock_sz_000002'],
                   columns=['current_count'])

    drawer = Drawer(df, df1[['current_count']])
    drawer.draw_kline()
github zvtvz / zvt / zvt / apps / data_app.py View on Github external
end_date=end_date)
        if readers:
            data_df = readers[0].data_df
            for reader in readers[1:]:
                if df_is_not_null(reader.data_df):
                    data_df = data_df.join(reader.data_df, how='outer')

            global current_df
            current_df = data_df

            if not df_is_not_null(current_df):
                return 'no data,please reselect!', [], '', [
                    {'label': 'compare_self', 'value': 'compare_self'}], 'compare_self'

            normal_data = NormalData(current_df)
            data_table = Drawer(data=normal_data).draw_data_table(id='data-table-content')

            # generate col setting table
            properties = normal_data.data_df.columns.to_list()

            df = pd.DataFrame(OrderedDict([
                ('property', properties),
                ('y_axis', ['y1'] * len(properties)),
                ('chart', ['line'] * len(properties))
            ]))

            # generate intents
            intents = normal_data.get_intents()

            intent_options = [
                {'label': intent.value, 'value': intent.value} for intent in intents
            ]
github zvtvz / zvt / zvt / factors / factor.py View on Github external
def pipe_drawer(self) -> Drawer:
        drawer = Drawer(NormalData(df=self.pipe_df))
        return drawer
github zvtvz / zvt / zvt / apps / data_app.py View on Github external
# this is a simplification of the front-end filtering logic,
                    # only works with complete fields in standard format
                    dff = dff.loc[dff[col_name].str.startswith(filter_value)]

        # if sort_by:
        #     dff = dff.sort_values(
        #         [col['entity_id'] for col in sort_by],
        #         ascending=[
        #             col['direction'] == 'asc'
        #             for col in sort_by
        #         ],
        #         inplace=False
        #     )

        if intent in (IntentType.compare_self.value, IntentType.compare_to_other.value):
            graph_data, graph_layout = Drawer(NormalData(dff)).draw_compare(chart=chart, property_map=property_map,
                                                                            render=None, keep_ui_state=False)
        else:
            graph_data, graph_layout = Drawer(NormalData(dff)).draw(chart=chart, property_map=property_map, render=None,
                                                                    keep_ui_state=False)

        table_data = dff.iloc[page_current * page_size: (page_current + 1) * page_size
                     ].to_dict('records')

        return table_data, \
               dcc.Graph(
                   id='chart-content',
                   figure={
                       'data': graph_data,
                       'layout': graph_layout
                   }
               )