def get_stock_delay_briefs(self, symbols, lang=None):
        """
        query delay quote
        :param symbols: stock symbol list, like ['AAPL', 'GOOG']
        :param lang: language: tigeropen.common.consts.Language:  zh_CN,zh_TW,en_US
        :return: pandas.DataFrame. the columns are as follows:
            symbol:
            pre_close:
            time: last quote change time
            volume:
            open:
            high:
            low:
            close:
            halted: stock status(0: normal 3: suspended  4: delist 7: ipo 8: changed)
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = get_enum_value(lang) if lang else get_enum_value(
            self._lang)

        request = OpenApiRequest(QUOTE_DELAY, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = DelayBriefsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.briefs
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #2
0
    def get_trade_ticks(self, symbols, begin_index=0, end_index=30, limit=30, lang=None):
        """
        获取逐笔成交
        :param symbols: 股票代码
        :param begin_index: 开始索引
        :param end_index: 结束索引
        :param limit: 数量限制
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.begin_index = begin_index
        params.end_index = end_index
        params.limit = limit
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(TRADE_TICK, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = TradeTickResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.trade_ticks
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #3
0
    def get_timeline(self,
                     symbols,
                     include_hour_trading=False,
                     begin_time=-1,
                     lang=None):
        """
        获取当日分时数据
        :param symbols: 股票代码
        :param include_hour_trading: 是否包含盘前盘后分时
        :param begin_time: 开始时间
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.include_hour_trading = include_hour_trading
        params.begin_time = begin_time
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(TIMELINE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = QuoteTimelineResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.timelines
            else:
                raise ApiException(response.code, response.message)
Пример #4
0
    def get_short_interest(self, symbols, lang=None):
        """
        获取美股的做空数据
        :param symbols: 股票代号列表
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return: pandas.DataFrame 对象,各 column 含义如下:
            symbol: 证券代码
            settlement_date: 收集信息的时间
            short_interest: 未平仓做空股数
            avg_daily_volume: 过去一年的日均成交量
            days_to_cover: 回补天数。使用最近一次获取的未平仓做空股数/日均成交量得到
            percent_of_float: 未平仓股数占流通股本的比重
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(QUOTE_SHORTABLE_STOCKS, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = ShortInterestResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.short_interests
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #5
0
    def get_briefs(self,
                   symbols,
                   include_hour_trading=False,
                   include_ask_bid=False,
                   right=QuoteRight.BR,
                   lang=None):
        """
        获取股票摘要
        :param symbols: 股票代号列表
        :param include_hour_trading: 是否包含盘前盘后
        :param include_ask_bid: 是否包含买卖盘
        :param right: 复权选项 ,br: 前复权,nr: 不复权
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.include_hour_trading = include_hour_trading
        params.include_ask_bid = include_ask_bid
        params.right = right.value
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(BRIEF, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = QuoteBriefResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.briefs
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #6
0
    def get_bars(self, symbols, period=BarPeriod.DAY, begin_time=-1, end_time=-1, right=QuoteRight.BR, limit=251,
                 lang=None):
        """
        获取K线数据
        :param symbols: 股票代码
        :param period: day: 日K,week: 周K,month:月K ,year:年K,1min:1分钟,5min:5分钟,15min:15分钟,30min:30分钟,60min:60分钟
        :param begin_time: 开始时间
        :param end_time: 结束时间
        :param right: 复权选项 ,br: 前复权,nr: 不复权
        :param limit: 数量限制
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        if period:
            params.period = period.value
        params.begin_time = begin_time
        params.end_time = end_time
        params.right = right.value
        params.limit = limit
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(KLINE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = QuoteBarResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.bars
            else:
                raise ApiException(response.code, response.message)
    def get_stock_details(self, symbols, lang=None):
        """
        获取股票详情
        :param symbols: 股票代号列表
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return: pandas.DataFrame.  各 column 含义如下:
            symbol: 代码
            market: 市场
            sec_type: 证券类型
            exchange: 交易所
            name: 名称
            shortable: 做空信息
            ask_price: 卖一价
            ask_size: 卖一量
            bid_price: 买一价
            bid_size: 买一量
            pre_close: 前收价
            latest_price: 最新价
            adj_pre_close: 复权后前收价
            latest_time: 最新成交时间
            volume: 成交量
            open: 开盘价
            high: 最高价
            low: 最低价
            change: 涨跌额
            amount: 成交额
            amplitude: 振幅
            market_status: 市场状态 (未开盘,交易中,休市等)
            trading_status:   0: 非交易状态 1: 盘前交易(盘前竞价) 2: 交易中 3: 盘后交易(收市竞价)
            float_shares: 流通股本
            shares: 总股本
            eps: 每股收益
            adr_rate: ADR的比例数据,非ADR的股票为None
            etf: 非0表示该股票是ETF,1表示不带杠杆的etf,2表示2倍杠杆etf,3表示3倍etf杠杆
            listing_date: 上市日期时间戳(该市场当地时间零点),该key可能不存在
            更多字段见 tigeropen.quote.response.stock_details_response.StockDetailsResponse
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = get_enum_value(lang) if lang else get_enum_value(
            self._lang)

        request = OpenApiRequest(STOCK_DETAIL, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = StockDetailsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.details
            else:
                raise ApiException(response.code, response.message)
        return None
Пример #8
0
    def get_details(self, symbols, lang=None):
        """
        获取股票详情(废弃)
        :param symbols: 股票代号列表
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(STOCK_DETAIL, biz_model=params)
        response_content = self.__fetch_data(request)
        return response_content
Пример #9
0
    def get_bars(self,
                 symbols,
                 period=BarPeriod.DAY,
                 begin_time=-1,
                 end_time=-1,
                 right=QuoteRight.BR,
                 limit=251,
                 lang=None):
        """
        获取K线数据
        :param symbols: 股票代号列表
        :param period: day: 日K,week: 周K,month:月K ,year:年K,1min:1分钟,5min:5分钟,15min:15分钟,30min:30分钟,60min:60分钟
        :param begin_time: 开始时间. 若是时间戳需要精确到毫秒, 为13位整数;
                                    或是日期时间格式的字符串, 如 "2019-01-01" 或 "2019-01-01 12:00:00"
        :param end_time: 结束时间. 格式同 begin_time
        :param right: 复权选项 ,QuoteRight.BR: 前复权,nQuoteRight.NR: 不复权
        :param limit: 数量限制
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return: pandas.DataFrame 对象,各 column 的含义如下;
            time: 毫秒时间戳
            open: Bar 的开盘价
            close: Bar 的收盘价
            high: Bar 的最高价
            low: Bar 的最低价
            volume: Bar 的成交量
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        if period:
            params.period = period.value
        params.begin_time = begin_time
        params.end_time = end_time
        params.right = right.value
        params.limit = limit
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(KLINE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = QuoteBarResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.bars
            else:
                raise ApiException(response.code, response.message)
    def get_stock_briefs(self, symbols, lang=None):
        """
        获取股票实时行情
        :param symbols: 股票代号列表
        :param lang: 语言支持: tigeropen.common.consts.Language:  zh_CN,zh_TW,en_US
        :return: pandas.DataFrame.  各 column 含义如下:
            symbol: 证券代码
            ask_price: 卖一价
            ask_size: 卖一量
            bid_price: 买一价
            bid_size: 买一量
            pre_close: 前收价
            latest_price: 最新价
            latest_time: 最新成交时间
            volume: 成交量
            open: 开盘价
            high: 最高价
            low: 最低价
            status: 交易状态:
                "UNKNOWN": 未知
                "NORMAL": 正常
                "HALTED": 停牌
                "DELIST": 退市
                "NEW": 新股
                "ALTER": 变更
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = get_enum_value(lang) if lang else get_enum_value(
            self._lang)

        request = OpenApiRequest(QUOTE_REAL_TIME, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = StockBriefsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.briefs
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #11
0
    def get_option_expirations(self, symbols):
        """
        返回美股期权的过期日
        :param symbols: 股票列表
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols

        request = OpenApiRequest(OPTION_EXPIRATION, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = OptionExpirationsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.expirations
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #12
0
    def get_trade_metas(self, symbols):
        """
        获取股票交易需要的信息(最新数量和报价单位等)
        :param 股票代号列表
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols

        request = OpenApiRequest(QUOTE_STOCK_TRADE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = TradeMetaResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.metas
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #13
0
    def get_short_interest(self, symbols, lang=None):
        """
        获取美股的做空数据
        :param symbols: 股票列表
        :param lang:
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(QUOTE_SHORTABLE_STOCKS, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = ShortInterestResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.short_interests
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #14
0
    def get_stock_briefs(self, symbols, lang=None):
        """
        获取股票实时行情
        :param symbols: 股票代号列表
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return:
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.lang = lang.value if lang else self._lang.value

        request = OpenApiRequest(QUOTE_REAL_TIME, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = StockBriefsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.briefs
            else:
                raise ApiException(response.code, response.message)

        return None
    def get_trade_ticks(self,
                        symbols,
                        begin_index=None,
                        end_index=None,
                        limit=None,
                        lang=None):
        """
        获取逐笔成交
        :param symbols: 股票代号列表
        :param begin_index: 开始索引
        :param end_index: 结束索引
        :param limit: 数量限制
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return: pandas.DataFrame 对象, column 有如下属性:
            index: 索引值
            time: 毫秒时间戳
            price: 成交价
            volume: 成交量
            direction: 价格变动方向,"-"表示向下变动, "+" 表示向上变动
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.begin_index = begin_index
        params.end_index = end_index
        params.limit = limit
        params.lang = get_enum_value(lang) if lang else get_enum_value(
            self._lang)

        request = OpenApiRequest(TRADE_TICK, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = TradeTickResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.trade_ticks
            else:
                raise ApiException(response.code, response.message)

        return None
Пример #16
0
    def get_option_expirations(self, symbols):
        """
        返回美股期权的过期日
        :param symbols: 股票代码列表
        :return: pandas.DataFrame, 各 column 的含义如下:
            symbol: 证券代码
            date: 到日期 YYYY-MM-DD 格式的字符串
            timestamp: 到期日,精确到毫秒的时间戳
        """
        params = MultipleQuoteParams()
        params.symbols = symbols

        request = OpenApiRequest(OPTION_EXPIRATION, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = OptionExpirationsResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.expirations
            else:
                raise ApiException(response.code, response.message)

        return None
    def get_timeline(self,
                     symbols,
                     include_hour_trading=False,
                     begin_time=-1,
                     lang=None):
        """
        获取当日分时数据
        :param symbols: 股票代号列表
        :param include_hour_trading: 是否包含盘前盘后分时
        :param begin_time: 开始时间. 若是时间戳需要精确到毫秒, 为13位整数;
                                    或是日期时间格式的字符串, 如 "2019-01-01" 或 "2019-01-01 12:00:00"
        :param lang: 语言支持: zh_CN,zh_TW,en_US
        :return: pandas.DataFrame, DataFrame 的 column 及含义如下:
            symbol: 证券代码
            time: 精确到毫秒的时间戳
            price: 当前分钟的收盘价
            avg_price: 截至到当前时间的成交量加权均价
            pre_close: 昨日收盘价
            volume: 这一分钟的成交量
            trading_session: 字符串, "pre_market" 表示盘前交易, "regular" 表示盘中交易, "after_hours"表示盘后交易
        """
        params = MultipleQuoteParams()
        params.symbols = symbols
        params.include_hour_trading = include_hour_trading
        params.begin_time = begin_time
        params.lang = get_enum_value(lang) if lang else get_enum_value(
            self._lang)

        request = OpenApiRequest(TIMELINE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = QuoteTimelineResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.timelines
            else:
                raise ApiException(response.code, response.message)
Пример #18
0
    def get_trade_metas(self, symbols):
        """
        获取股票交易需要的信息(最新数量和报价单位等)
        :param symbols: 股票代号列表
        :return: pandas.DataFrame, 各 column 的含义如下:
            symbol: 证券代码
            lot_size: 每股手数
            min_tick: 价格最小变动单位
            spread_scale: 报价精度
        """
        params = MultipleQuoteParams()
        params.symbols = symbols

        request = OpenApiRequest(QUOTE_STOCK_TRADE, biz_model=params)
        response_content = self.__fetch_data(request)
        if response_content:
            response = TradeMetaResponse()
            response.parse_response_content(response_content)
            if response.is_success():
                return response.metas
            else:
                raise ApiException(response.code, response.message)

        return None