ExchangeStockSummaryRecorder

class zvt.recorders.exchange.exchange_stock_summary_recorder.ExchangeStockSummaryRecorder(force_update=False, sleeping_time=5, exchanges=None, entity_id=None, entity_ids=None, code=None, day_data=False, entity_filters=None, ignore_failed=True, real_time=False, fix_duplicate_way='add', start_timestamp=None, end_timestamp=None)

Bases: zvt.contract.recorder.TimestampsDataRecorder

__init__(force_update=False, sleeping_time=5, exchanges=None, entity_id=None, entity_ids=None, code=None, day_data=False, entity_filters=None, ignore_failed=True, real_time=False, fix_duplicate_way='add', start_timestamp=None, end_timestamp=None) None
Parameters
  • code

  • ignore_failed

  • entity_filters

  • exchanges

  • entity_id – for record single entity

  • entity_ids – set entity_ids or (entity_type,exchanges,codes)

  • codes

  • day_data – one record per day,set to True if you want skip recording it when data of today exist

  • force_update

  • sleeping_time

entity_schema

alias of zvt.domain.meta.index_meta.Index

data_schema

alias of zvt.domain.misc.overall.StockSummary

record(entity, start, end, size, timestamps)

implement the recording logic in this method, should return json or domain list

Parameters
  • entity

  • start

  • end

  • size

  • timestamps

get_data_map()

{‘original_field’:(‘domain_field’,transform_func)}

clear_state_data(entity_id=None)

clear state of the entity

Parameters

entity_id – entity id

decode_state(state: str)

decode state

Parameters

state

Returns

encode_state(state: object)

encode state

Parameters

state

Returns

generate_domain(entity, original_data)

generate the data_schema instance using entity and original_data,the original_data is from record result

Parameters
  • entity

  • original_data

generate_domain_id(entity, original_data, time_fmt='YYYY-MM-DD')

generate domain id from the entity and original data,the default id meaning:entity + event happen time

Parameters
  • entity

  • original_data

  • time_fmt

Returns

Return type

get_evaluated_time_field()

the timestamp field for evaluating time range of recorder,used in get_latest_saved_record

init_entities()

init the entities which we would record data for

persist(entity, domain_list)

persist the domain list to db

Parameters
  • entity

  • domain_list

state_schema

alias of zvt.contract.zvt_info.RecorderState

exchanges

setup the entities you want to record

entity_ids

set entity_ids or (entity_type,exchanges,codes)

session

using to do db operations