def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.dbname = self.get_dbname() self.table_name = self.get_tablename() self.redis = create_redis_obj() if redis_host is None else create_redis_obj(host = redis_host) self.mysql_client = CMySQL(dbinfo, self.dbname, iredis = self.redis) if not self.mysql_client.create_db(self.dbname): raise Exception("create plate database failed") if not self.create_table(self.table_name): raise Exception("create valuation table failed")
def __init__(self, dbinfo): self.redis = create_redis_obj() self.mysql_client = CMySQL(dbinfo) self.table = ct.ANIMATION_INFO self.trigger = ct.SYNC_ANIMATION_2_REDIS if not self.create(): raise Exception("create animation table %s table failed" % self.table) if not self.register(): raise Exception("create animation trigger %s failed" % self.trigger)
def __init__(self, market=ct.SH_MARKET_SYMBOL, dbinfo=ct.DB_INFO, redis_host=None): self.market = market self.dbinfo = dbinfo self.balcklist = ['2006-07-10' ] if market == ct.SH_MARKET_SYMBOL else list() self.logger = getLogger(__name__) self.dbname = self.get_dbname(market) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host) self.header = { "Host": "query.sse.com.cn", "Referer": "http://www.sse.com.cn/market/stockdata/overview/day/", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" } self.mysql_client = CMySQL(self.dbinfo, dbname=self.dbname, iredis=self.redis) if not self.mysql_client.create_db(self.dbname): raise Exception("create %s failed" % self.dbname)
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.redis = create_redis_obj() if redis_host is None else create_redis_obj(host = redis_host) self.dbname = self.get_dbname() self.redis_host = redis_host self.logger = getLogger(__name__) self.mysql_client = CMySQL(dbinfo, self.dbname, iredis = self.redis) if not self.mysql_client.create_db(self.get_dbname()): raise Exception("init rstock database failed")
def __init__(self, dbinfo): self.mysql_client = CMySQL(dbinfo) self.cal_client = ccalendar.CCalendar(without_init=True) with open(ct.USER_FILE) as f: infos = json.load(f) self.trader = Trader(infos[0]["account"], infos[0]["passwd_encrypted"], infos[0]["secuids_sh"], infos[0]["secuids_sz"]) self.bnew_succeed_date = ""
def __init__(self, dbinfo, fpath = ct.USER_FILE): self.mysql_client = CMySQL(dbinfo) self.cal_client = ccalendar.CCalendar(without_init = True) with open(fpath) as f: infos = json.load(f) self.traders = list() for info in infos: self.traders.append(Trader(info["account"], info["passwd_encrypted"], info["secuids_sh"], info["secuids_sz"])) self.buy_succeed_date = ""
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.dbinfo = dbinfo self.emotion_table = ct.EMOTION_TABLE self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(self.dbinfo, iredis = self.redis) self.rstock_client = RIndexStock(dbinfo, redis_host) self.logger = getLogger(__name__) if not self.create(): raise Exception("create emotion table failed")
def __init__(self, code, dbname, dbinfo, redis_host): self.code = code self._dbname = dbname self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo=dbinfo, dbname=dbname, iredis=self.redis)
def __init__(self, dbinfo, table): self.table = table self.redis = create_redis_obj() self.mysql_client = CMySQL(dbinfo) self.trigger = ct.SYNC_HALTED_2_REDIS if not self.create(): raise Exception("create chalted table failed") if not self.init(True): raise Exception("init chalted table failed") if not self.register(): raise Exception("create chalted trigger failed")
def __init__(self, dbinfo): self.table = ct.DELISTED_INFO_TABLE self.trigger = ct.SYNC_DELISTED_2_REDIS self.mysql_client = CMySQL(dbinfo) self.redis = create_redis_obj() if not self.create(): raise Exception("create delisted table failed") if not self.init(True): raise Exception("init delisted table failed") if not self.register(): raise Exception("create delisted trigger failed")
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.table = self.get_table_name() self.logger = getLogger(__name__) self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo, iredis = self.redis) self.header = {"Host": "home.flashdata2.jrj.com.cn", "Referer": "http://stock.jrj.com.cn/tzzs/zdtwdj/zdforce.shtml", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"} if not self.create(): raise Exception("create stock %s failed" % self.table)
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): for (market_from, market_to) in [(ct.SH_MARKET_SYMBOL, ct.HK_MARKET_SYMBOL), (ct.HK_MARKET_SYMBOL, ct.SH_MARKET_SYMBOL), (ct.SZ_MARKET_SYMBOL, ct.HK_MARKET_SYMBOL), (ct.HK_MARKET_SYMBOL, ct.SZ_MARKET_SYMBOL)]: dbname = self.get_dbname(market_from, market_to) self.mysql_client = CMySQL(dbinfo, dbname) if not self.mysql_client.create_db(dbname): raise Exception("init hkex crawler database failed") #self.mysql_client.delete(self.get_topten_table(dbname)) if not self.create_topten_table(dbname): raise Exception("init hkex crawler topten table failed") #self.mysql_client.delete(self.get_capital_table(dbname)) if not self.create_capital_table(dbname): raise Exception("init hkex crawler capital table failed failed")
def __init__(self, code, dbinfo, redis_host): self.code = code self.logger = getLogger(__name__) self.dbname = self.get_dbname(code) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo, dbname=self.dbname, iredis=self.redis)
def __init__(self, dbinfo, code): self.code = code self.dbname = self.get_dbname(code) self.redis = create_redis_obj() self.name = self.get('name') self.data_type_dict = {9: "day"} self.influx_client = CInflux(ct.IN_DB_INFO, self.dbname) self.mysql_client = CMySQL(dbinfo, self.dbname) if not self.create(): raise Exception("create stock %s table failed" % self.code)
def __init__(self, index_code, dbinfo = ct.DB_INFO, redis_host = None): self.dbinfo = dbinfo self.index_code = index_code self.index_obj = CIndex(index_code, dbinfo = self.dbinfo, redis_host = redis_host) self.db_name = self.index_obj.get_dbname(index_code) self.logger = getLogger(__name__) self.ris = RIndexStock(dbinfo, redis_host) self.bull_stock_ratio_table = self.get_table_name() self.redis = create_redis_obj() if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(self.dbinfo, dbname = self.db_name, iredis = self.redis) if not self.create(): raise Exception("create emotion table failed")
def set_market(self, market_from, market_to): self.market_from = market_from self.market_to = market_to self.balcklist = [ "2018-10-17", "2018-09-25", "2018-07-02", "2018-05-22", "2018-04-02", "2018-03-30" ] if market_from in [ct.SH_MARKET_SYMBOL, ct.SZ_MARKET_SYMBOL ] else list() self.dbname = self.get_dbname(market_from, market_to) self.crawler = MCrawl(market_from) self.mysql_client = CMySQL(self.dbinfo, self.dbname, iredis=self.redis) return False if not self.mysql_client.create_db(self.dbname) else True
def __init__(self, dbinfo): self.dbinfo = dbinfo self.sdir = '/data/docs/blog/hellobiek.github.io/source/_posts' self.doc = CDoc(self.sdir) self.stock_objs = dict() self.redis = create_redis_obj() self.mysql_client = CMySQL(self.dbinfo, iredis=self.redis) self.cal_client = ccalendar.CCalendar(without_init=True) self.animating = False self.emotion_table = ct.EMOTION_TABLE if not self.create_emotion(): raise Exception("create emotion table failed")
def __init__(self, dbinfo=ct.DB_INFO, redis_host=None): self.dbinfo = dbinfo self.logger = getLogger(__name__) self.tu_client = get_tushare_client() self.doc = CDoc() self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(redis_host) self.mysql_client = CMySQL(dbinfo, iredis=self.redis) self.margin_client = Margin(dbinfo=dbinfo, redis_host=redis_host) self.rstock_client = RIndexStock(dbinfo=dbinfo, redis_host=redis_host) self.sh_market_client = StockExchange(ct.SH_MARKET_SYMBOL) self.sz_market_client = StockExchange(ct.SZ_MARKET_SYMBOL) self.emotion_client = Emotion()
def __init__(self, dbinfo): self.sdir = '/data/docs/blog/hellobiek.github.io/source/_posts' self.doc = CDoc(self.sdir) self.redis = create_redis_obj() self.mysql_client = CMySQL(dbinfo) self.cal_client = ccalendar.CCalendar(without_init=True) self.trading_info = None self.animating = False self.emotion_table = ct.EMOTION_TABLE self.industry_table = ct.INDUSTRY_TABLE if not self.create_industry(): raise Exception("create industry table failed") if not self.create_emotion(): raise Exception("create emotion table failed")
def __init__(self, market_from=ct.SH_MARKET_SYMBOL, market_to=ct.HK_MARKET_SYMBOL, dbinfo=ct.DB_INFO, redis_host=None): self.market_from = market_from self.market_to = market_to self.balcklist = None self.crawler = None self.mysql_client = None self.dbinfo = dbinfo self.logger = getLogger(__name__) self.dbname = self.get_dbname(market_from, market_to) self.redis = create_redis_obj( ) if redis_host is None else create_redis_obj(host=redis_host) self.mysql_client = CMySQL(self.dbinfo, self.dbname, iredis=self.redis)
#coding=utf-8 import json import const as ct import pandas as pd import tushare as ts from common import create_redis_obj from cmysql import CMySQL from cstock import CStock if __name__ == "__main__": #redis = create_redis_obj() #redis.delete('ALL_TABLES') cmy = CMySQL(ct.DB_INFO) all_dbs = cmy.get_all_databases() for dbname in all_dbs: _dbname = dbname[1:] if _dbname.isnumeric(): res = cmy.delete_db(dbname) print("delete %s, result:%s" % (dbname, res)) #with open('/tmp/a', 'r') as f: # slist = json.load(f) #old_stock = CStock(ct.OLD_DB_INFO, '000695') #for code in slist: # #with open("/tmp/a", 'w') as f: # # json.dump(slist, f) # old_stock.mysql_client.delete("%s_D" % code) # old_stock.mysql_client.delete("%s_realtime" % code) # old_stock.mysql_client.delete("%s_ticket" % code) # print(code) # #slist.append(code)
def __init__(self, dbinfo = ct.DB_INFO, redis_host = None): self.dbname = self.get_dbname() self.table = self.get_table_name() self.redis = create_redis_obj() if redis_host is None else create_redis_obj(host = redis_host) self.mysql_client = CMySQL(dbinfo, self.dbname, iredis = self.redis)