Exemplo n.º 1
0
 def __init__(self, dbinfo=ct.DB_INFO, redis_host=None):
     self.dbinfo = dbinfo
     self.logger = getLogger(__name__)
     self.index_objs = dict()
     self.stock_objs = dict()
     self.updating_date = None
     self.combination_objs = dict()
     self.cal_client = CCalendar(dbinfo, redis_host)
     self.index_info_client = IndexInfo()
     self.cvaluation_client = CValuation()
     self.reviewer = CReivew(dbinfo, redis_host)
     self.comb_info_client = CombinationInfo(dbinfo, redis_host)
     self.stock_info_client = CStockInfo(dbinfo, redis_host)
     self.rindex_stock_data_client = RIndexStock(dbinfo, redis_host)
     self.industry_info_client = IndustryInfo(dbinfo, redis_host)
     self.rindustry_info_client = RIndexIndustryInfo(dbinfo, redis_host)
     self.animation_client = CAnimation(dbinfo, redis_host)
     self.subscriber = Subscriber()
     self.quote_handler = StockQuoteHandler()
     self.ticker_handler = TickerHandler()
     self.connect_client = StockConnect(market_from=ct.SH_MARKET_SYMBOL,
                                        market_to=ct.HK_MARKET_SYMBOL,
                                        dbinfo=dbinfo,
                                        redis_host=redis_host)
     self.margin_client = Margin(dbinfo=dbinfo, redis_host=redis_host)
     self.emotion_client = Emotion(dbinfo=dbinfo, redis_host=redis_host)
     self.sh_exchange_client = StockExchange(ct.SH_MARKET_SYMBOL)
     self.sz_exchange_client = StockExchange(ct.SZ_MARKET_SYMBOL)
Exemplo n.º 2
0
 def __init__(self):
     self.logger = getLogger(__name__)
     self.cval_client = CValuation()
     self.stock_info_client = CStockInfo()
Exemplo n.º 3
0
tsource = ColumnDataSource(dict(code=list(), pday=list(), profit=list()))
source_code = """
    row = cb_obj.indices[0]
    text_row.value = String(source.data['code'][row]);
"""
callback = CustomJS(args=dict(source=tsource, text_row=code_text),
                    code=source_code)
tsource.selected.js_on_change('indices', callback)
columns = [
    TableColumn(field="code", title="代码"),
    TableColumn(field="pday", title="牛熊天数", sortable=True),
    TableColumn(field="profit", title="牛熊程度", sortable=True)
]
mtable = DataTable(source=tsource, columns=columns, width=1300, height=200)

val_client = CValuation()

roe_fig = figure()
dist_fig = figure()
stock_fig = figure()
profit_fig = figure()

val_source = ColumnDataSource()
dist_source = ColumnDataSource()
stock_source = ColumnDataSource()

#code = '600900'
#mdate = '2019-08-08'
#sobj = CStock(code)
#sdf = sobj.get_k_data()
#ddf = sobj.get_chip_distribution(mdate)
Exemplo n.º 4
0
                 tools="pan,box_zoom,wheel_zoom,reset,box_select,lasso_select",
                 toolbar_location="right",
                 background_fill_color="#fafafa")
    fig.y_range.start = 0
    fig.add_tools(
        HoverTool(tooltips=[("数量", "@top"), ("数值",
                                             "@left"), ("分位数",
                                                        "@percentile")]))
    fig.xaxis.axis_label = 'x'
    fig.yaxis.axis_label = 'Vol(x)'
    fig.grid.grid_line_color = "white"
    return fig


cdoc = curdoc()
cvaluation = CValuation()
stock_info_client = CStockInfo()
vsource = ColumnDataSource(
    dict(bottom=list(),
         top=list(),
         left=list(),
         right=list(),
         percentile=list()))

fig = make_plot()
fig.quad(top='top',
         bottom='bottom',
         left='left',
         right='right',
         fill_color="navy",
         line_color="white",
Exemplo n.º 5
0
    def bootstrap(self,
                  cdate=None,
                  exec_date=datetime.now().strftime('%Y-%m-%d'),
                  ndays=3):
        finished_step, exec_date = self.get_update_info(cdate, exec_date)
        self.logger.info("enter updating.%s" % finished_step)
        if finished_step < 1:
            if not self.cal_client.init():
                self.logger.error("cal client init failed")
                return False
            self.set_update_info(1, exec_date, cdate)

        if finished_step < 2:
            self.cvaluation_client = CValuation(needUpdate=True)
            self.set_update_info(2, exec_date, cdate)

        if finished_step < 3:
            if not self.index_info_client.update():
                self.logger.error("index info init failed")
                return False
            self.set_update_info(3, exec_date, cdate)

        if finished_step < 4:
            if not self.stock_info_client.update():
                self.logger.error("stock info init failed")
                return False
            self.set_update_info(4, exec_date, cdate)

        if finished_step < 5:
            if not self.comb_info_client.update():
                self.logger.error("comb info init failed")
                return False
            self.set_update_info(5, exec_date, cdate)

        if finished_step < 6:
            if not self.industry_info_client.update():
                self.logger.error("industry info init failed")
                return False
            self.set_update_info(6, exec_date, cdate)

        if finished_step < 7:
            if not self.init_tdx_index_info(cdate):
                self.logger.error("init tdx index info failed")
                return False
            self.set_update_info(7, exec_date, cdate)

        if finished_step < 8:
            if not self.sh_exchange_client.update(exec_date, num=ndays):
                self.logger.error("sh exchange update failed")
                return False
            self.set_update_info(8, exec_date, cdate)

        if finished_step < 9:
            if not self.sz_exchange_client.update(exec_date, num=ndays):
                self.logger.error("sz exchange update failed")
                return False
            self.set_update_info(9, exec_date, cdate)

        if finished_step < 10:
            if not self.init_index_components_info(exec_date):
                self.logger.error("init index components info failed")
                return False
            self.set_update_info(10, exec_date, cdate)

        if finished_step < 11:
            if not self.init_industry_info(cdate):
                self.logger.error("init industry info failed")
                return False
            self.set_update_info(11, exec_date, cdate)

        if finished_step < 12:
            if not self.rindustry_info_client.update(exec_date, num=ndays):
                self.logger.error("init %s rindustry info failed" % exec_date)
                return False
            self.set_update_info(12, exec_date, cdate)

        if finished_step < 13:
            if not self.init_yesterday_hk_info(exec_date, num=ndays):
                self.logger.error("init yesterday hk info failed")
                return False
            self.set_update_info(13, exec_date, cdate)

        if finished_step < 14:
            if not self.margin_client.update(exec_date, num=ndays):
                self.logger.error("init yesterday margin failed")
                return False
            self.set_update_info(14, exec_date, cdate)

        if finished_step < 15:
            if not self.init_stock_info(cdate):
                self.logger.error("init stock info set failed")
                return False
            self.set_update_info(15, exec_date, cdate)

        if finished_step < 16:
            if not self.init_base_float_profit():
                self.logger.error("init base float profit for all stock")
                return False
            self.set_update_info(16, exec_date, cdate)

        if finished_step < 17:
            if not self.init_valuation_info(cdate):
                self.logger.error("init stock valuation info failed")
                return False
            self.set_update_info(17, exec_date, cdate)

        if finished_step < 18:
            if not self.init_rvaluation_info(cdate):
                self.logger.error("init r stock valuation info failed")
                return False
            self.set_update_info(18, exec_date, cdate)

        if finished_step < 19:
            if not self.init_rindex_valuation_info(cdate):
                self.logger.error("init r index valuation info failed")
                return False
            self.set_update_info(19, exec_date, cdate)

        if finished_step < 20:
            if not self.rindex_stock_data_client.update(exec_date, num=ndays):
                self.logger.error("rstock data set failed")
                return False
            self.set_update_info(20, exec_date, cdate)

        if finished_step < 21:
            if not self.set_bull_stock_ratio(exec_date, num=ndays):
                self.logger.error("bull ratio set failed")
                return False
            self.set_update_info(21, exec_date, cdate)

        self.logger.info("updating succeed")
        return True