Example #1
0
 def clear_state_data(self, entity_id=None):
     super().clear_state_data(entity_id=entity_id)
     if entity_id:
         del_data(self.factor_schema,
                  filters=[self.factor_schema.entity_id == entity_id],
                  provider="zvt")
     else:
         del_data(self.factor_schema, provider="zvt")
Example #2
0
    def clear_state_data(self, entity_id=None):
        """
        clear state of the entity

        :param entity_id: entity id
        """
        filters = [self.state_schema.state_name == self.name]
        if entity_id:
            filters = filters + [self.state_schema.entity_id == entity_id]
        del_data(self.state_schema, filters=filters)
Example #3
0
def init_main_index(provider='exchange'):
    from zvt.utils.time_utils import to_pd_timestamp
    import pandas as pd
    from zvt.contract.api import df_to_db
    from zvt.domain import Index

    for item in CHINA_STOCK_MAIN_INDEX:
        item['timestamp'] = to_pd_timestamp(item['timestamp'])
    df = pd.DataFrame(CHINA_STOCK_MAIN_INDEX)
    # print(df)
    df_to_db(df=df, data_schema=Index, provider=provider, force_update=False)
    # delete dirty data
    del_data(data_schema=Index,
             provider=provider,
             filters=[Index.exchange == 'cn'])
Example #4
0
File: factor.py Project: niuguy/zvt
 def clear_state_data(self, entity_id=None):
     if entity_id:
         del_data(FactorState,
                  filters=[FactorState.factor_name == self.factor_name, FactorState.entity_id == entity_id],
                  provider='zvt')
         del_data(self.factor_schema, filters=[self.factor_schema.entity_id == entity_id], provider='zvt')
     else:
         del_data(FactorState, filters=[FactorState.factor_name == self.factor_name], provider='zvt')
         del_data(self.factor_schema, provider='zvt')
Example #5
0
 def clear_state_data(self, region: Region, entity_id=None):
     if entity_id:
         del_data(region,
                  FactorState,
                  filters=[
                      FactorState.factor_name == self.factor_name,
                      FactorState.entity_id == entity_id
                  ],
                  provider=Provider.ZVT)
         del_data(region,
                  self.factor_schema,
                  filters=[self.factor_schema.entity_id == entity_id],
                  provider=Provider.ZVT)
     else:
         del_data(region,
                  FactorState,
                  filters=[FactorState.factor_name == self.factor_name],
                  provider=Provider.ZVT)
         del_data(region, self.factor_schema, provider=Provider.ZVT)
Example #6
0
 def clear_state_data(self):
     del_data(self.state_schema,
              filters=[
                  self.state_schema.entity_id == self.get_state_entity_id()
              ])
Example #7
0
import time

from zvt import init_log
from zvt.contract.api import get_entities, del_data
from zvt_coin import *

from zvt_coin.domain import *
from zvt_tm.informer.discord_informer import DiscordInformer

logger = logging.getLogger(__name__)

if __name__ == '__main__':
    init_log('crypto_data_runner.log')
    try:
        COIN_EXCHANGES = ["binance"]
        del_data(data_schema=Coin, provider='ccxt')
        Coin.record_data(exchanges=COIN_EXCHANGES)
        items = get_entities(entity_type='coin',
                             provider='ccxt',
                             exchanges=COIN_EXCHANGES)
        entity_ids = items[items['entity_id'].str.contains(
            "USDT")]['entity_id'].tolist()
        Coin1dKdata.record_data(provider='ccxt',
                                exchanges=COIN_EXCHANGES,
                                entity_ids=entity_ids,
                                sleeping_time=0.5)

    except Exception as e:
        logger.exception(e)
        time.sleep(60)
Example #8
0
 def clear_state_data(self):
     del_data(FactorState, filters=[FactorState.factor_name == self.factor_name], provider='zvt')
     del_data(self.factor_schema, provider='zvt')