当前位置: 首页>>代码示例>>Python>>正文


Python tushare.get_realtime_quotes方法代码示例

本文整理汇总了Python中tushare.get_realtime_quotes方法的典型用法代码示例。如果您正苦于以下问题:Python tushare.get_realtime_quotes方法的具体用法?Python tushare.get_realtime_quotes怎么用?Python tushare.get_realtime_quotes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tushare的用法示例。


在下文中一共展示了tushare.get_realtime_quotes方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: repo

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def repo(self):
        try:
            security = '131810'
            quote_df = ts.get_realtime_quotes(security)
            order = {
                'action': 'SELL',
                'symbol': security,
                'type': 'LIMIT',
                'price': float(quote_df['bid'][0]),
                'amountProportion': 'ALL'
            }
            for trader in self._traders.values():
                try:
                    trader.execute(**order)
                except:
                    self._logger.exception('[%s] 逆回购失败', trader.id)
        except:
            self._logger.exception('逆回购失败') 
开发者ID:sinall,项目名称:StrategyEase-Python-SDK,代码行数:20,代码来源:base_manager.py

示例2: get_order

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_order(self, strategy_id, all=True):
        """获取订单列表
            :param all:True返回当日所有订单,False返回上次下单后新产生的订单。
        """

        s = self.session
        orders = s.get(order_url%strategy_id).json()
        
        percent = self.percent

        if all:
            return orders
        else:
            tmp_orders = []
            for order in orders:
                price = float(ts.get_realtime_quotes(order['ticker']).price)
                order['price'] = round(price*(order['side']=='BUY' and 1.+percent or 1.-percent), 2)
                tmp_orders.append(order)
            return tmp_orders 
开发者ID:musequant,项目名称:uqtrader,代码行数:21,代码来源:uqer.py

示例3: get_push

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_push(all_list = []):
    stock_symbol_list, price_low_list, price_high_list = handle(all_list)
    localtime = datetime.datetime.now()    # 获取当前时间
    now = localtime.strftime('%H:%M:%S')
    data = ts.get_realtime_quotes(stock_symbol_list)    # 获取股票信息
    price_list = data['price']
    itchat.send(now, toUserName='filehelper')
    print(now)

    for i in range(int(len(all_list) / 3)):
        content = stock_symbol_list[i] + ' 当前价格为 ' + price_list[i] + '\n'
        if float(price_list[i]) <=  float(price_low_list[i]):
            itchat.send(content + '低于最低预警价格', toUserName='filehelper')
            print(content + '低于最低预警价格')
        elif float(price_list[i]) >=  float(price_high_list[i]):
            itchat.send(content + '高于最高预警价格', toUserName='filehelper')
            print(content + '高于最高预警价格')
        else:
            itchat.send(content + '价格正常', toUserName='filehelper')
            print(content + '价格正常')
    itchat.send('***** end *****', toUserName='filehelper')
    print('***** end *****\n') 
开发者ID:onshek,项目名称:Stock_WeChat,代码行数:24,代码来源:sw.py

示例4: get_remind

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_remind(all_list = []):
    stock_symbol_list, price_low_list, price_high_list = handle(all_list)
    localtime = datetime.datetime.now()    # 获取当前时间
    now = localtime.strftime('%H:%M:%S')
    data = ts.get_realtime_quotes(stock_symbol_list)    # 获取股票信息
    price_list = data['price']
    itchat.send(now, toUserName='filehelper')
    print(now)

    for i in range(int(len(all_list) / 3)):
        content = stock_symbol_list[i] + ' 当前价格为 ' + price_list[i] + '\n'
        if float(price_list[i]) <=  float(price_low_list[i]):
            itchat.send(content + '低于最低预警价格', toUserName='filehelper')
            print(content + '低于最低预警价格')
        elif float(price_list[i]) >=  float(price_high_list[i]):
            itchat.send(content + '高于最高预警价格', toUserName='filehelper')
            print(content + '高于最高预警价格')
        else:
            print(content + '价格正常')
    itchat.send('***** end *****', toUserName='filehelper')
    print('***** end *****\n') 
开发者ID:onshek,项目名称:Stock_WeChat,代码行数:23,代码来源:sw.py

示例5: getAllChinaStock2

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def getAllChinaStock2():
    df_list = pd.read_csv(cm.DownloadDir + cm.TABLE_STOCKS_BASIC + '.csv')
    stockList = df_list['code'].values;
    stockList_group = util.group_list(stockList, 20)
    print len(stockList_group)
    print stockList_group[1]
    stockList = []
    for group in stockList_group:
        df = ts.get_realtime_quotes(group)
    
        for se in df.get_values():
            stock = st.Stock('')
            stock.code = se[0]
            stock.name = se[1]
            stock.current = se[3]
            stock.open = se[4]
            stock.high = se[5]
            stock.low = se[6]
            stock.close = se[7]
            stock.dealAmount = se[8]/100
            stock.time = time.localtime(time.time()) #时间
            #print stock
            stockList.append(stock)
    return stockList 
开发者ID:cbbing,项目名称:stock,代码行数:26,代码来源:online_data.py

示例6: get_realtime_quotes

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_realtime_quotes(code_list, open_only=False):
    import tushare as ts

    max_len = 800
    loop_cnt = int(math.ceil(float(len(code_list)) / max_len))

    total_df = reduce(lambda df1, df2: df1.append(df2),
                      [ts.get_realtime_quotes([code for code in code_list[i::loop_cnt]])
                       for i in range(loop_cnt)])
    total_df["is_index"] = False

    index_symbol = ["sh", "sz", "hs300", "sz50", "zxb", "cyb"]
    index_df = ts.get_realtime_quotes(index_symbol)
    index_df["code"] = index_symbol
    index_df["is_index"] = True
    total_df = total_df.append(index_df)
    total_df = total_df.set_index("code").sort_index()

    columns = set(total_df.columns) - set(["name", "time", "date"])
    # columns = filter(lambda x: "_v" not in x, columns)
    for label in columns:
        total_df[label] = total_df[label].map(lambda x: 0 if str(x).strip() == "" else x)
        total_df[label] = total_df[label].astype(float)

    total_df["chg"] = total_df["price"] / total_df["pre_close"] - 1

    total_df["order_book_id"] = total_df.index
    total_df["order_book_id"] = total_df["order_book_id"].apply(tushare_code_2_order_book_id)

    total_df["datetime"] = total_df["date"] + " " + total_df["time"]
    total_df["datetime"] = total_df["datetime"].apply(lambda x: convert_dt_to_int(datetime.datetime.strptime(x, "%Y-%m-%d %H:%M:%S")))

    total_df["close"] = total_df["price"]

    if open_only:
        total_df = total_df[total_df.open > 0]

    return total_df 
开发者ID:Raytone-D,项目名称:puppet,代码行数:40,代码来源:utils.py

示例7: __call__

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def __call__(self):
        df = ts.get_realtime_quotes(self._symbol)
        order = {
            'action': 'SELL',
            'symbol': self._symbol,
            'type': 'LIMIT',
            'price': float(df['bid'][0]),
            'amountProportion': 'ALL'
        }
        for client_alias in self._client_aliases:
            try:
                client = self._client_aliases[client_alias]
                self._client.execute(client, **order)
            except:
                self._logger.exception('客户端[%s]逆回购失败', client_alias) 
开发者ID:sinall,项目名称:StrategyEase-Python-SDK,代码行数:17,代码来源:repo.py

示例8: order_place

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def order_place(self):
        table = self.tableWidget

        count = table.rowCount()
        orders = []
        for x in xrange(count):

            ticker = unicode(table.item(x, 0).text())
            side   = unicode(table.item(x, 2).text())
            
            amount = unicode(table.item(x, 3).text())

            price = float(ts.get_realtime_quotes(ticker).price)
            percent = self.percent
            price = round(price*(side==u'买' and 1.+percent or 0.99-percent), 2)
            amount = int(round((int(amount)/100)*100, -2))

            orders.append((side, ticker, str(amount), str(price)))

        message = '\r\n'.join([u'%s %s: %s@%s'%order for order in orders])

        reply = QtGui.QMessageBox.question(self, u'下单确认', 
                     message, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)

        if reply != QtGui.QMessageBox.Yes:
            return

        for side, ticker, amount, price in orders:

            if side == u'买':
                self.account_instance.buy(ticker, price, amount)
            else:
                self.account_instance.sell(ticker, price, amount) 
开发者ID:musequant,项目名称:uqtrader,代码行数:35,代码来源:trader.py

示例9: get_stock_name

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_stock_name(stock_code):
    real_time_data = ts.get_realtime_quotes(stock_code).to_dict('record')
    stock_name = real_time_data[0]['name']
    return stock_name 
开发者ID:LinLidi,项目名称:StockSensation,代码行数:6,代码来源:views.py

示例10: get_stock_name

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_stock_name(stocknumber):
    realtimeData = ts.get_realtime_quotes(stocknumber)
    realtimeData = realtimeData.to_dict('record')
    stock_name = realtimeData[0]['name']
    return stock_name

# 获取分词List 
开发者ID:LinLidi,项目名称:StockSensation,代码行数:9,代码来源:views.py

示例11: get_stock_name

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_stock_name(stocknumber):
    realtimeData = ts.get_realtime_quotes(stocknumber)
    realtimeData = realtimeData.to_dict('record')
    stock_name = realtimeData[0]['name']
    return stock_name


# 获取分词List 
开发者ID:Rockyzsu,项目名称:StockPredict,代码行数:10,代码来源:views.py

示例12: getAllChinaStock

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def getAllChinaStock():

    stockList = []
    try:
        df = get_real_price_dataframe()
        for se in df.get_values():
            stock = st.Stock('')
            stock.code = se[0]
            stock.name = se[1]
            stock.current = se[3]
            stock.open = se[4]
            stock.high = se[5]
            stock.low = se[6]
            stock.close = se[7]
            stock.dealAmount = se[8]/100
            stock.time = time.localtime(time.time()) #时间
            #print stock

            stockList.append(stock)
    except:
        print 'get real price timeout'

    return stockList

# 获取A股所有股票的实时股价
# 通过get_realtime_quotes接口获取 
开发者ID:cbbing,项目名称:stock,代码行数:28,代码来源:online_data.py

示例13: get_realtime_quotes

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_realtime_quotes(code_list, open_only=False):
    import tushare as ts

    max_len = 800
    loop_cnt = int(math.ceil(float(len(code_list)) / max_len))

    total_df = reduce(lambda df1, df2: df1.append(df2),
                      [ts.get_realtime_quotes([code for code in code_list[i::loop_cnt]])
                       for i in range(loop_cnt)])
    total_df["is_index"] = False

    index_symbol = ["sh", "sz", "hs300", "sz50", "zxb", "cyb"]
    index_df = ts.get_realtime_quotes(index_symbol)
    index_df["code"] = index_symbol
    index_df["is_index"] = True
    total_df = total_df.append(index_df)

    columns = set(total_df.columns) - set(["name", "time", "date", "code"])
    # columns = filter(lambda x: "_v" not in x, columns)
    for label in columns:
        total_df[label] = total_df[label].map(lambda x: 0 if str(x).strip() == "" else x)
        total_df[label] = total_df[label].astype(float)

    total_df["chg"] = total_df["price"] / total_df["pre_close"] - 1

    total_df["order_book_id"] = total_df["code"]
    total_df["order_book_id"] = total_df["order_book_id"].apply(tushare_code_2_order_book_id)

    total_df = total_df.set_index("order_book_id").sort_index()

    total_df["datetime"] = total_df["date"] + " " + total_df["time"]
    total_df["datetime"] = total_df["datetime"].apply(lambda x: convert_dt_to_int(datetime.datetime.strptime(x, "%Y-%m-%d %H:%M:%S")))

    total_df["close"] = total_df["price"]
    total_df["last"] = total_df["price"]

    total_df["limit_up"] = total_df.apply(lambda row: row.pre_close * (1.1 if "ST" not in row["name"] else 1.05), axis=1).round(2)
    total_df["limit_down"] = total_df.apply(lambda row: row.pre_close * (0.9 if "ST" not in row["name"] else 0.95), axis=1).round(2)

    if open_only:
        total_df = total_df[total_df.open > 0]

    return total_df 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:45,代码来源:utils.py

示例14: get_realtime_quotes

# 需要导入模块: import tushare [as 别名]
# 或者: from tushare import get_realtime_quotes [as 别名]
def get_realtime_quotes(order_book_id_list, open_only=False, include_limit=False):
    import tushare as ts

    code_list = [order_book_id_2_tushare_code(code) for code in order_book_id_list]

    max_len = 800
    loop_cnt = int(math.ceil(float(len(code_list)) / max_len))

    total_df = reduce(lambda df1, df2: df1.append(df2),
                      [ts.get_realtime_quotes([code for code in code_list[i::loop_cnt]])
                       for i in range(loop_cnt)])
    total_df["is_index"] = False

    index_symbol = ["sh", "sz", "hs300", "sz50", "zxb", "cyb"]
    index_df = ts.get_realtime_quotes(index_symbol)
    index_df["code"] = index_symbol
    index_df["is_index"] = True
    total_df = total_df.append(index_df)

    columns = set(total_df.columns) - set(["name", "time", "date", "code"])
    # columns = filter(lambda x: "_v" not in x, columns)
    for label in columns:
        total_df[label] = total_df[label].map(lambda x: 0 if str(x).strip() == "" else x)
        total_df[label] = total_df[label].astype(float)

    total_df["chg"] = total_df["price"] / total_df["pre_close"] - 1

    total_df["order_book_id"] = total_df["code"]
    total_df["order_book_id"] = total_df["order_book_id"].apply(tushare_code_2_order_book_id)

    total_df = total_df.set_index("order_book_id").sort_index()
    total_df["order_book_id"] = total_df.index

    total_df["datetime"] = total_df["date"] + " " + total_df["time"]
    # total_df["datetime"] = total_df["datetime"].apply(
    #     lambda x: convert_dt_to_int(datetime.datetime.strptime(x, "%Y-%m-%d %H:%M:%S")))

    total_df["close"] = total_df["price"]
    total_df["last"] = total_df["price"]

    total_df = total_df.rename(columns={
        "{}{}_p".format(base_name, i): "{}{}".format(base_name, i)
        for i in range(1, 6) for base_name in ["a", "b"]
    })
    total_df = total_df.rename(columns={"pre_close": "prev_close"})

    del total_df["code"]
    del total_df["is_index"]
    del total_df["date"]
    del total_df["time"]

    if include_limit:
        total_df["limit_up"] = total_df.apply(
            lambda row: row.prev_close * (1.1 if "ST" not in row["name"] else 1.05), axis=1).round(2)
        total_df["limit_down"] = total_df.apply(
            lambda row: row.prev_close * (0.9 if "ST" not in row["name"] else 0.95), axis=1).round(2)

    if open_only:
        total_df = total_df[total_df.open > 0]

    return total_df 
开发者ID:DingTobest,项目名称:Rqalpha-myquant-learning,代码行数:63,代码来源:utils.py


注:本文中的tushare.get_realtime_quotes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。