Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MarketTradingDays, CapitalFlowLine, CapitalDistributionResponse 这三个类型没法正确 import #609

@LokiSharp

Description

@LokiSharp

问题描述

MarketTradingDays, CapitalFlowLine, CapitalDistributionResponse 这三个类型没法正确 import

代码例子

    def fetch_trading_days(
        self, market: str, begin: date, end: date
    ) -> MarketTradingDays:
        """
        获取交易日历

        :param market: 市场代码
        :param begin: 开始日期
        :param end: 结束日期
        :return: 交易日历信息
        """
        trading_days = self.ctx.trading_days(market, begin, end)
        return trading_days

    def fetch_capital_flow(self, symbol: str, count: int) -> List[CapitalFlowLine]:
        """
        获取标的的资金流向数据

        :param symbol: 标的代码
        :param count: 请求数量
        :return: 资金流向数据列表
        """
        capital_flow = self.ctx.capital_flow(symbol, count)
        return capital_flow

    def fetfch_capital_distribution(
        self, symbol: str, count: int
    ) -> CapitalDistributionResponse:
        """
        获取标的的资金分布数据

        :param symbol: 标的代码
        :param count: 请求数量
        :return: 资金分布数据列表
        """
        capital_distribution = self.ctx.capital_distribution(symbol, count)
        return capital_distribution

错误信息或结果截图

脚本检查发现这几个类型没有被注册

# check_longport.py

import longport
from longport import openapi
import inspect

import longport.openapi

print("\nAvailable modules in longport.openapi:")
for name, obj in inspect.getmembers(openapi):
    if not name.startswith("_"):
        print(f" - {name}")
❯ uv run check_longport.py

Available modules in longport.openapi:
 - AdjustType
 - BalanceType
 - Brokers
 - CalcIndex
 - Candlestick
 - ChargeCategoryCode
 - CommissionFreeStatus
 - Config
 - DeductionStatus
 - Depth
 - DerivativeType
 - EstimateMaxPurchaseQuantityResponse
 - Execution
 - FilterWarrantExpiryDate
 - FilterWarrantInOutBoundsType
 - Granularity
 - HistoryMarketTemperatureResponse
 - HttpClient
 - IntradayLine
 - IssuerInfo
 - Language
 - MarginRatio
 - Market
 - MarketTemperature
 - MarketTradingSession
 - OpenApiException
 - OptionQuote
 - OptionType
 - Order
 - OrderChargeDetail
 - OrderChargeFee
 - OrderChargeItem
 - OrderDetail
 - OrderHistoryDetail
 - OrderSide
 - OrderStatus
 - OrderTag
 - OrderType
 - OutsideRTH
 - ParticipantInfo
 - Period
 - PrePostQuote
 - PushBrokers
 - PushCandlestick
 - PushCandlestickMode
 - PushDepth
 - PushOrderChanged
 - PushQuote
 - PushTrades
 - QuoteContext
 - RealtimeQuote
 - SecuritiesUpdateMode
 - Security
 - SecurityBrokers
 - SecurityCalcIndex
 - SecurityDepth
 - SecurityListCategory
 - SecurityQuote
 - SecurityStaticInfo
 - SortOrderType
 - StrikePriceInfo
 - SubType
 - TimeInForceType
 - TopicType
 - Trade
 - TradeContext
 - TradeDirection
 - TradeSession
 - TradeSessions
 - TradeStatus
 - TradingSessionInfo
 - TriggerStatus
 - WarrantInfo
 - WarrantQuote
 - WarrantSortBy
 - WarrantStatus
 - WarrantType
 - WatchlistGroup
 - WatchlistSecurity
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.devbox/nix/profile/default/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_long_port_market_adapter.py:4: in <module>
    from modules.market_adapter import LongPortMarketAdapter
modules/market_adapter.py:3: in <module>
    from longport.openapi import (
E   ImportError: cannot import name 'MarketTradingDays' from 'openapi' (unknown location)
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.devbox/nix/profile/default/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_long_port_market_adapter.py:4: in <module>
    from modules.market_adapter import LongPortMarketAdapter
modules/market_adapter.py:3: in <module>
    from longport.openapi import (
E   ImportError: cannot import name 'CapitalFlowLine' from 'openapi' (unknown location)
Hint: make sure your test modules/packages have valid Python names.
Traceback:
.devbox/nix/profile/default/lib/python3.13/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_long_port_market_adapter.py:4: in <module>
    from modules.market_adapter import LongPortMarketAdapter
modules/market_adapter.py:3: in <module>
    from longport.openapi import (
E   ImportError: cannot import name 'CapitalDistributionResponse' from 'openapi' (unknown location)

你的环境信息

  • 操作系统: macOS / Linux(NixOS)
  • 开发语言: Python
  • SDK 版本号:3.0.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions