def __init__(self, db_path=None, log_file=None): self.panels = {} self.symbols = [] self._last_symbols = None # Setup a logger, we might need it immediately below log_file = log_file or 'tickprocess_worker.log' self.logger = get_logger(name=str(self.__class__), log_file=log_file) # DB related try: self._db_meta = get_metadata(db_path) except Exception as e: self.logger.error(e) self._db_meta = None raise TickProcessWorkerExceptionDBInit("Failed to Init DB") self._profiling = False
import time import random from collections import namedtuple from datetime import datetime as dt import requests from tickerplot.nse.nse_utils import nse_get_all_stocks_list from tickerplot.utils.logger import get_logger from tickerplot.sql.sqlalchemy_wrapper import create_or_get_nse_corp_actions_hist_data from tickerplot.sql.sqlalchemy_wrapper import execute_many_insert from tickerplot.sql.sqlalchemy_wrapper import get_metadata module_logger = get_logger(os.path.basename(__file__)) #FIXME : Implement bonus/split processing from a specific date. # _CorpActionAll is a named tuple of following type #"Symbol","Company","Industry","Series","Face Value(Rs.)","Purpose", # "Ex-Date","Record Date","BC Start Date","BC End Date", # "No Delivery Start Date","No Delivery End Date" _CorpActionAll = namedtuple('_CorpActionAll', [ 'sym', 'name', 'industry', 'series', 'fv', 'purpose', 'ex_date', 'rec_date', 'bc_sdate', 'bc_edate', 'nd_sdate', 'nd_edate' ]) CorpAction = namedtuple('CorpAction', ['sym', 'ex_date', 'action', 'ratio', 'delta'])