def import_from_csv_filedates(self) -> str: file: str = FileUtils.get_file(AppConsts.INCOME_STMT_FILE) records: List[Dict] = CsvUtils.parse_as_dict(file) for record in records: if not self.__is_valid_intrinio_record_for_filedates(record): continue symbol: str = record.get(AppConsts.INTRINIO_KEY_INC_STMT_TICKER) fiscal_period: str = record.get( AppConsts.INTRINIO_KEY_INC_STMT_FISC_PD) year: int = NumberUtils.to_int( record.get(AppConsts.INTRINIO_KEY_INC_STMT_FISC_YR)) quarter: int = self.__get_quarter(fiscal_period) file_date: date = DateUtils.get_date( record.get(AppConsts.INTRINIO_KEY_INC_STMT_FILE_DTE), AppConsts.INTRINIO_FILE_DTE_FMT) if not file_date or quarter == 4: continue org_symbol: SM = self.__stock_service.get_symbol( symbol, AppConsts.INSTRUMENT_STOCK) if not org_symbol: continue org_fn: FN = self.__stock_service.get_financial( org_symbol.id, year, quarter) if not org_fn: continue org_fn.file_date = file_date BaseService._update() return "1"
def import_from_csv_balancesheets(self) -> str: file: str = FileUtils.get_file(AppConsts.BALANCE_SHEET_FILE) records: List[Dict] = CsvUtils.parse_as_dict(file) for record in records: if not self.__is_valid_intrinio_record(record): continue symbol: str = record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_TICKER) fiscal_period: str = record.get( AppConsts.INTRINIO_KEY_BLNC_SHEET_FISC_PD) year: int = NumberUtils.to_int( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_FISC_YR)) quarter: int = self.__get_quarter(fiscal_period) org_symbol: SM = self.__stock_service.get_symbol( symbol, AppConsts.INSTRUMENT_STOCK) if not org_symbol: continue org_fn: FN = self.__stock_service.get_financial( org_symbol.id, year, quarter) if not org_fn: continue org_fn.current_assets = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_CURR_ASSETS)) org_fn.ttl_assets = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_ASSETS)) org_fn.current_liabilities = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_CURR_LIABS)) org_fn.ttl_liabilities = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_LIABS)) org_fn.ttl_equity = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_BLNC_SHEET_EQUITY)) BaseService._update() return "1"
def import_from_csv_calculations(self) -> str: file: str = FileUtils.get_file(AppConsts.FINANCIAL_CALCS_FILE) records: List[Dict] = CsvUtils.parse_as_dict(file) for record in records: if not self.__is_valid_intrinio_record(record): continue symbol: str = record.get(AppConsts.INTRINIO_KEY_CALCS_TICKER) fiscal_period: str = record.get( AppConsts.INTRINIO_KEY_CALCS_FISC_PD) year: int = NumberUtils.to_int( record.get(AppConsts.INTRINIO_KEY_CALCS_FISC_YR)) quarter: int = self.__get_quarter(fiscal_period) org_symbol: SM = self.__stock_service.get_symbol( symbol, AppConsts.INSTRUMENT_STOCK) if not org_symbol: continue org_fn: FN = self.__stock_service.get_financial( org_symbol.id, year, quarter) if not org_fn: continue org_fn.market_cap = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_MARK_CAP)) org_fn.revenue_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_REV_GRTH)) org_fn.revenue_qq_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_REV_QQ_GRTH)) org_fn.nopat_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_NOPAT_GRTH)) org_fn.nopat_qq_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_NOTPAT_QQ_GRTH)) org_fn.net_income_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_INCM_GRTH)) org_fn.net_income_qq_growth = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_INCM_QQ_GRTH)) org_fn.free_cash_flow = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_CSH_FLOW)) org_fn.current_ratio = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_CURR_RATIO)) org_fn.debt_to_equity_ratio = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_DE_RATIO)) org_fn.pe_ratio = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_PE_RATIO)) org_fn.pb_ratio = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_PB_RATIO)) org_fn.div_payout_ratio = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_DIV_PAYOUT_RATIO)) org_fn.roe = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_ROE)) org_fn.roa = NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_CALCS_ROA)) BaseService._update() return "1"
def import_from_csv_companynames(self) -> str: file: str = FileUtils.get_file(AppConsts.INCOME_STMT_FILE) records: List[Dict] = CsvUtils.parse_as_dict(file) curr_symbol: str = '' for record in records: symbol: str = record.get(AppConsts.INTRINIO_KEY_INC_STMT_TICKER) company_name: str = record.get( AppConsts.INTRINIO_KEY_INC_STMT_NAME) if symbol == curr_symbol or StringUtils.isNullOrWhitespace( company_name): continue curr_symbol = symbol org_symbol: SM = self.__stock_service.get_symbol( curr_symbol, AppConsts.INSTRUMENT_STOCK) if not org_symbol: continue LogUtils.debug('Updating {0}.'.format(company_name)) org_symbol.name = company_name BaseService._update() return "1"
def import_from_csv_incomestatements(self) -> str: BaseService._truncate(FN) file: str = FileUtils.get_file(AppConsts.INCOME_STMT_FILE) records: List[Dict] = CsvUtils.parse_as_dict(file) models: List[Any] = [] for record in records: if not self.__is_valid_intrinio_record(record): continue symbol: str = record.get(AppConsts.INTRINIO_KEY_INC_STMT_TICKER) fiscal_period: str = record.get( AppConsts.INTRINIO_KEY_INC_STMT_FISC_PD) org_symbol: SM = self.__stock_service.get_symbol( symbol, AppConsts.INSTRUMENT_STOCK) if not org_symbol: continue quarter_end_dte: date = DateUtils.get_date( record.get(AppConsts.INTRINIO_KEY_INC_STMT_END_DTE), AppConsts.INTRINIO_END_DTE_FMT) file_date: date = DateUtils.get_date( record.get(AppConsts.INTRINIO_KEY_INC_STMT_FILE_DTE), AppConsts.INTRINIO_FILE_DTE_FMT) models.append( (org_symbol.id, record.get(AppConsts.INTRINIO_KEY_INC_STMT_FISC_YR), self.__get_quarter(fiscal_period), quarter_end_dte, file_date, None, NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_INC_STMT_TTLREV)), NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_INC_STMT_TTLPROF)), NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_INC_STMT_TTLOPINC)), NumberUtils.to_float( record.get(AppConsts.INTRINIO_KEY_INC_STMT_NETINC)), None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None)) BaseService._insert_bulk(FN, models) return "1"