Пример #1
0
    def get(self):
        code = self.get_argument("code", default=None, strip=False)
        logging.info(code)
        # self.uri_ = ("self.request.url:", self.request.uri)
        # print self.uri_
        comp_list = []

        try:
            date_now = datetime.datetime.now()
            date_end = date_now.strftime("%Y-%m-%d")
            date_start = (date_now +
                          datetime.timedelta(days=-300)).strftime("%Y-%m-%d")
            print(code, date_start, date_end)

            # open, high, close, low, volume, price_change, p_change, ma5, ma10, ma20, v_ma5, v_ma10, v_ma20, turnover
            # 使用缓存方法。加快计算速度。
            stock = common.get_hist_data_cache(code, date_start, date_end)
            logging.info(stock.head(1))

            # print(stock) [186 rows x 14 columns]
            # 初始化统计类
            # stockStat = stockstats.StockDataFrame.retype(pd.read_csv("002032.csv"))
            stockStat = stockstats.StockDataFrame.retype(stock)
            batch_add(comp_list, stockStat)

        except Exception as e:
            logging.info("error :", e)
        logging.info(
            "#################### GetStockHtmlHandlerEnd ####################")

        self.render("stock_indicators.html",
                    comp_list=comp_list,
                    leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #2
0
    def get(self):
        name = self.get_argument("table_name", default=None, strip=False)
        stockWeb = stock_web_dic.STOCK_WEB_DATA_MAP[name]
        # self.uri_ = ("self.request.url:", self.request.uri)
        # print self.uri_
        date_now = datetime.datetime.now()
        date_now_str = date_now.strftime("%Y%m%d")
        # 每天的 16 点前显示昨天数据。
        if date_now.hour < 16:
            date_now_str = (date_now +
                            datetime.timedelta(days=-1)).strftime("%Y%m%d")

        try:
            # 增加columns 字段中的【查看股票 东方财富】
            logging.info(eastmoney_name in stockWeb.column_names)
            if eastmoney_name in stockWeb.column_names:
                tmp_idx = stockWeb.column_names.index(eastmoney_name)
                logging.info(tmp_idx)
                try:
                    # 防止重复插入数据。可能会报错。
                    stockWeb.columns.remove("eastmoney_url")
                except Exception as e:
                    print("error :", e)
                stockWeb.columns.insert(tmp_idx, "eastmoney_url")
        except Exception as e:
            print("error :", e)
        logging.info("####################GetStockHtmlHandlerEnd")
        self.render("stock_web.html",
                    stockWeb=stockWeb,
                    date_now=date_now_str,
                    leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #3
0
 def get(self):
     name = self.get_argument("table_name", default=None, strip=False)
     #stockWeb = stock_web_dic.STOCK_WEB_DATA_MAP[name]
     # self.uri_ = ("self.request.url:", self.request.uri)
     # print self.uri_
     logging.info("chart...")
     self.render("stock_chart.html", entries="", leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #4
0
 def get(self):
     name = self.get_argument("table_name", default=None, strip=False)
     stockWeb = stock_web_dic.STOCK_WEB_DATA_MAP[name]
     # self.uri_ = ("self.request.url:", self.request.uri)
     # print self.uri_
     self.render("data_editor.html",
                 stockWeb=stockWeb,
                 leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #5
0
 def get(self):
     code = self.get_argument("code", default=None, strip=False)
     print(code)
     # self.uri_ = ("self.request.url:", self.request.uri)
     # print self.uri_
     try:
         print("#######")
     except Exception as e:
         print("error :", e)
     logging.info("####################GetStockHtmlHandlerEnd")
     self.render("stock_indicators.html",
                 leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #6
0
 def get(self):
     print("################## index.html ##################")
     pandasVersion = pd.__version__
     numpyVersion = np.__version__
     akshareVersion = ak.__version__
     bokehVersion = bh.__version__
     #stockstatsVersion = ss.__version__ # 没有这个函数,但是好久不更新了
     # https://github.com/jealous/stockstats
     self.render("index.html",
                 pandasVersion=pandasVersion,
                 numpyVersion=numpyVersion,
                 akshareVersion=akshareVersion,
                 bokehVersion=bokehVersion,
                 stockstatsVersion="0.3.2",
                 pythonStockVersion=common.__version__,
                 leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #7
0
 def get(self):
     name = self.get_argument("table_name", default=None, strip=False)
     stockWeb = stock_web_dic.STOCK_WEB_DATA_MAP[name]
     # self.uri_ = ("self.request.url:", self.request.uri)
     # print self.uri_
     try:
         # 增加columns 字段中的【东方财富】
         tmp_idx = stockWeb.column_names.index("东方财富")
         logging.info(tmp_idx)
         try:
             # 防止重复插入数据。可能会报错。
             stockWeb.columns.remove("eastmoney_url")
         except Exception as e:
             print("error :", e)
         stockWeb.columns.insert(tmp_idx, "eastmoney_url")
     except Exception as e:
         print("error :", e)
     logging.info("####################GetStockHtmlHandlerEnd")
     self.render("stock_web.html",
                 stockWeb=stockWeb,
                 leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #8
0
 def get(self):
     self.render("index.html",
                 entries="hello",
                 leftMenu=webBase.GetLeftMenu(self.request.uri))
Пример #9
0
 def get(self):
     self.render("test2.html",
                 entries="hello",
                 pythonStockVersion=common.__version__,
                 leftMenu=webBase.GetLeftMenu(self.request.uri))