To add a new type of entity (e.g., a Country), create a class that inherits from TradableEntity and a SQLAlchemy declarative_base. Use the @register_entity decorator with an entity_type to identify the entity. Finally, call register_schema to link the entity to specific providers and a database name.
An entity is uniquely identified by its entity_type, exchange, and code (e.g., entity_type='country', exchange='galaxy', code='CN').
from sqlalchemy import Column, String, Float
from sqlalchemy.orm import declarative_base
from zvt.contract.schema import TradableEntity
from zvt.contract.register import register_schema, register_entity
CountryMetaBase = declarative_base()
@register_entity(entity_type="country")
class Country(CountryMetaBase, TradableEntity):
__tablename__ = "country"
region = Column(String(length=128))
capital_city = Column(String(length=128))
income_level = Column(String(length=64))
lending_type = Column(String(length=64))
longitude = Column(Float)
latitude = Column(Float)
register_schema(providers=["wb"], db_name="country_meta", schema_base=CountryMetaBase)