def load(dt, skip_ydata, skip_uni=False): global loading, _market_codes, _last_date, _request_stop, _current_spawn, _skip_ydata, _LOGGER _LOGGER = trade_logger.get_logger() _LOGGER.info('Load Data') _skip_ydata = skip_ydata dt = dt if dt.__class__.__name__ == 'date' else dt.date() if (_last_date is not None and _last_date == dt): _LOGGER.info('already loaded preload data') return if loading: if _current_spawn is not None: print('Stop Current Loading') _request_stop = True gevent.joinall([_current_spawn]) _current_spawn = None _request_stop = False else: _LOGGER.info('Spawn is none but still loading') return loading = True _last_date = dt _current_spawn = gevent.spawn(start_preload, dt, skip_ydata, skip_uni)
import sys sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), *(['..' + os.sep] * 2)))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), *(['..' + os.sep] * 1)))) from datetime import timedelta from google.protobuf.empty_pb2 import Empty from stock_service import preload from stock_service.plugins import markettime from stock_service.plugins import simulstatus from stock_service import stock_provider_pb2 from stock_service import stock_provider_pb2_grpc from utils import trade_logger _LOGGER = trade_logger.get_logger() stub = None REFRESH_SEC = 120 LIST_COUNT = 20 _amount_ratio_list = {} _amount_momentum_list = {} _amount_top_list = {} _last_push_time = None def clear_all(): global _last_push_time _last_push_time = None _amount_top_list.clear()