|
35 | 35 | from tigeropen.quote.response.stock_trade_meta_response import TradeMetaResponse |
36 | 36 | from tigeropen.quote.response.symbol_names_response import SymbolNamesResponse |
37 | 37 | from tigeropen.quote.response.symbols_response import SymbolsResponse |
38 | | -from tigeropen.quote.response.quote_depth_entry_response import DepthEntryResponse |
| 38 | +from tigeropen.quote.response.quote_order_book_response import OrderBookResponse |
39 | 39 | from tigeropen.tiger_open_client import TigerOpenClient |
40 | 40 | from tigeropen.quote.request.model import MarketParams, MultipleQuoteParams, MultipleContractParams, \ |
41 | 41 | FutureQuoteParams, FutureExchangeParams, FutureTypeParams, FutureTradingTimeParams, SingleContractParams, \ |
42 | | - SingleOptionQuoteParams, DepthEntryParams |
| 42 | + SingleOptionQuoteParams, OrderBookParams |
43 | 43 | from tigeropen.quote.request import OpenApiRequest |
44 | 44 | from tigeropen.quote.response.quote_ticks_response import TradeTickResponse |
45 | 45 | from tigeropen.quote.response.market_status_response import MarketStatusResponse |
|
48 | 48 | OPTION_KLINE, OPTION_TRADE_TICK, FUTURE_KLINE, FUTURE_TICK, FUTURE_CONTRACT_BY_EXCHANGE_CODE, \ |
49 | 49 | FUTURE_TRADING_DATE, QUOTE_SHORTABLE_STOCKS, FUTURE_REAL_TIME_QUOTE, \ |
50 | 50 | FUTURE_CURRENT_CONTRACT, QUOTE_REAL_TIME, QUOTE_STOCK_TRADE, FINANCIAL_DAILY, FINANCIAL_REPORT, CORPORATE_ACTION, \ |
51 | | - DEPTH_ENTRY |
| 51 | + ORDER_BOOK |
52 | 52 | from tigeropen.common.consts import Market, Language, QuoteRight, BarPeriod |
53 | 53 | from tigeropen.common.util.contract_utils import extract_option_info |
54 | 54 | from tigeropen.common.util.common_utils import eastern |
@@ -375,22 +375,51 @@ def get_short_interest(self, symbols, lang=None): |
375 | 375 |
|
376 | 376 | return None |
377 | 377 |
|
378 | | - def get_depth_entry(self, symbols): |
| 378 | + def get_order_book(self, symbols): |
379 | 379 | """ |
380 | 380 | 获取深度行情 |
381 | 381 | :param symbols: |
382 | 382 | :return: |
383 | | - """ |
384 | | - params = DepthEntryParams() |
| 383 | + 数据结构: |
| 384 | + 若返回单个 symbol: |
| 385 | + {'symbol': '02833', |
| 386 | + 'asks': [(27.4, 300, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0), (27.6, 5700, 3), (27.65, 0, 0), |
| 387 | + (27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0), (27.85, 0, 0)], |
| 388 | + 'bids': [(27, 4000, 3), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0), (26.75, 0, 0), |
| 389 | + (26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0), (26.55, 0, 0)] |
| 390 | + } |
| 391 | +
|
| 392 | + 若返回多个 symbol: |
| 393 | + {'02833': |
| 394 | + {'symbol': '02833', |
| 395 | + 'asks': [(27.35, 200, 1), (27.4, 2100, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0), |
| 396 | + (27.6, 5700, 3), (27.65, 0, 0), (27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0)], |
| 397 | + 'bids': [(27.05, 100, 1), (27, 5000, 4), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0), |
| 398 | + (26.75, 0, 0), (26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0)] |
| 399 | + }, |
| 400 | + '02828': |
| 401 | + {'symbol': '02828', |
| 402 | + 'asks': [(106.6, 6800, 7), (106.7, 110200, 10), (106.8, 64400, 8), (106.9, 80600, 8), (107, 9440, 16), |
| 403 | + (107.1, 31800, 5), (107.2, 11800, 4), (107.3, 9800, 2), (107.4, 9400, 1), (107.5, 21000, 9)], |
| 404 | + 'bids': [(106.5, 62800, 17), (106.4, 68200, 9), (106.3, 78400, 6), (106.2, 52400, 4), (106.1, 3060, 4), |
| 405 | + (106, 33400, 4), (105.9, 29600, 3), (105.8, 9600, 2), (105.7, 15200, 2), (105.6, 0, 0)]} |
| 406 | + } |
| 407 | +
|
| 408 | + asks 和 bids 列表项数据含义为: |
| 409 | + [(ask_price1, ask_volume1, order_count), (ask_price2, ask_volume2, order_count), ...] |
| 410 | + [(bid_price1, bid_volume2, order_count), (bid_price2, bid_volume2, order_count), ...] |
| 411 | +
|
| 412 | + """ |
| 413 | + params = OrderBookParams() |
385 | 414 | params.symbols = symbols if isinstance(symbols, list) else [symbols] |
386 | 415 |
|
387 | | - request = OpenApiRequest(DEPTH_ENTRY, biz_model=params) |
| 416 | + request = OpenApiRequest(ORDER_BOOK, biz_model=params) |
388 | 417 | response_content = self.__fetch_data(request) |
389 | 418 | if response_content: |
390 | | - response = DepthEntryResponse() |
| 419 | + response = OrderBookResponse() |
391 | 420 | response.parse_response_content(response_content) |
392 | 421 | if response.is_success(): |
393 | | - return response.depth_entry |
| 422 | + return response.order_book |
394 | 423 | else: |
395 | 424 | raise ApiException(response.code, response.message) |
396 | 425 |
|
|
0 commit comments