Пример #1
0
def update_trader_details(interval, trader_index):
    if trader_index is not None:
        return get_account_stats_figure(account_stats_reader=account_readers[trader_index]), \
               [{'label': security_id, 'value': security_id} for security_id in
                get_order_securities(trader_name=trader_names[trader_index])], \
               traders[trader_index].start_timestamp, \
               traders[trader_index].end_timestamp
    raise dash.PreventUpdate()
Пример #2
0
def update_trader_details(trader_index, entity_type, entity_provider):
    if trader_index is not None:
        # change entity_type options
        entity_type = traders[trader_index].entity_type
        if not entity_type:
            entity_type = 'stock'
        entity_type_options = [{'label': entity_type, 'value': entity_type}]

        # account stats
        account_stats = get_account_stats_figure(
            account_stats_reader=account_readers[trader_index])

        providers = zvt_context.tradable_schema_map.get(entity_type).providers
        entity_provider_options = [{
            'label': name,
            'value': name
        } for name in providers]

        # entities
        entity_ids = get_order_securities(
            trader_name=trader_names[trader_index])
        df = get_entities(provider=entity_provider,
                          entity_type=entity_type,
                          entity_ids=entity_ids,
                          columns=['entity_id', 'code', 'name'],
                          index='entity_id')
        entity_options = [{
            'label': f'{entity_id}({entity["name"]})',
            'value': entity_id
        } for entity_id, entity in df.iterrows()]

        return account_stats, entity_type_options, entity_provider_options, entity_options
    else:
        entity_type_options = [{
            'label': name,
            'value': name
        } for name in zvt_context.tradable_schema_map.keys()]
        account_stats = None
        providers = zvt_context.tradable_schema_map.get(entity_type).providers
        entity_provider_options = [{
            'label': name,
            'value': name
        } for name in providers]
        df = get_entities(provider=entity_provider,
                          entity_type=entity_type,
                          columns=['entity_id', 'code', 'name'],
                          index='entity_id')
        entity_options = [{
            'label': f'{entity_id}({entity["name"]})',
            'value': entity_id
        } for entity_id, entity in df.iterrows()]
        return account_stats, entity_type_options, entity_provider_options, entity_options
Пример #3
0
def update_trader_details(region: Region, trader_index, entity_type):
    if trader_index is not None:
        # change entity_type options
        entity_type = traders[trader_index].entity_type
        if not entity_type:
            entity_type = EntityType.Stock
        entity_type_options = [{'label': entity_type, 'value': entity_type}]

        # account stats
        account_stats = get_account_stats_figure(
            account_stats_reader=account_readers[trader_index])

        # entities
        entity_ids = get_order_securities(
            trader_name=trader_names[trader_index])
        df = get_entities(region=region,
                          entity_type=entity_type,
                          entity_ids=entity_ids,
                          columns=['entity_id', 'code', 'name'],
                          index='entity_id')
        entity_options = [{
            'label': f'{entity_id}({entity["name"]})',
            'value': entity_id
        } for entity_id, entity in df.iterrows()]

        return account_stats, entity_type_options, entity_options
    else:
        entity_type_options = [{
            'label': name,
            'value': name
        } for name in zvt_context.entity_schema_map.keys()]
        account_stats = None
        df = get_entities(region=region,
                          entity_type=entity_type,
                          columns=['entity_id', 'code', 'name'],
                          index='entity_id')
        entity_options = [{
            'label': f'{entity_id}({entity["name"]})',
            'value': entity_id
        } for entity_id, entity in df.iterrows()]
        return account_stats, entity_type_options, entity_options