def create_stock_comment(f, j, xd, ts, pgDB=None, lang="cn", mp3YN=True, ctky="stock", debugTF=False): """ ctky: category key among [macro|rate|currency|indicator|stock] """ tkLst = [] ticker = xd["ticker"] ky = "mkt{}".format(j) f[ky + "Ticker"] = ticker f[ky + "Label"] = label_masking(xd["label"], lang) f[ky + "XChg"] = xd["prc_chg"] f[ky + "NChg"] = xd["prc_fcs"] / xd["prc_cur"] - 1 dx = pd.DataFrame([xd]) xcmt = convert_data_comment_fcst(ticker, ctky, dx, pgDB=pgDB, lang=lang, mp3YN=mp3YN, ts=ts) xcmt = label_masking(xcmt, lang) tkLst.append(ticker) if debugTF is True: print(str(xcmt), file=sys.stderr) return (xcmt, tkLst)
def create_macro_comment(f, j, xd, ts, flgAddi, pgDB=None, lang="cn", mp3YN=True): tkLst = [] ticker = xd["ticker"] ky = "{}{}".format(xd['category'].split()[-1], j) f[ky + "Ticker"] = ticker f[ky + "Label"] = xd['label'].replace('-Y', ' Year') f[ky + "XChg"] = xd['prc_chg'] f[ky + "NChg"] = xd['prc_fcs'] / xd['prc_cur'] - 1 if 'vntdate' in xd: f[ky + "Vntdate"] = xd['vntdate'] f[ky + "Mfreq"] = xd['mfreq'] flgAddi += 1 dx = pd.DataFrame([xd]) xcmt = convert_data_comment_fcst(ticker, ky, dx, pgDB=pgDB, lang=lang, mp3YN=mp3YN, ts=ts) xcmt = xcmt.replace('-Y', ' Year') print >> sys.stderr, str(xcmt) tkLst.append(ticker) return (xcmt, flgAddi, tkLst)