VeighNa量化社区
你的开源社区量化交易平台
Member
加入于:
帖子: 3
声望: 0

vnpy: 3.1.0
vnpy_ctp: 6.5.1.12
os: windows 10
python: 3.10.4 64bit

加载这句

from vnpy_ctp import CtpGateway

报错

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [3], in <cell line: 2>()
      1 from vnpy_scripttrader import init_cli_trading
----> 2 from vnpy_ctp import CtpGateway

File D:\Miniconda3\envs\py310\lib\site-packages\vnpy_ctp\__init__.py:26, in <module>
      1 # The MIT License (MIT)
      2 #
      3 # Copyright (c) 2015-present, Xiaoyou Chen
   (...)
     20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21 # SOFTWARE.
     24 import importlib_metadata
---> 26 from .gateway import CtpGateway
     29 try:
     30     __version__ = importlib_metadata.version("vnpy_ctp")

File D:\Miniconda3\envs\py310\lib\site-packages\vnpy_ctp\gateway\__init__.py:1, in <module>
----> 1 from .ctp_gateway import CtpGateway

File D:\Miniconda3\envs\py310\lib\site-packages\vnpy_ctp\gateway\ctp_gateway.py:111, in <module>
    102 OFFSET_CTP2VT: Dict[str, Offset] = {v: k for k, v in OFFSET_VT2CTP.items()}
    104 # 交易所映射
    105 EXCHANGE_CTP2VT: Dict[str, Exchange] = {
    106     "CFFEX": Exchange.CFFEX,
    107     "SHFE": Exchange.SHFE,
    108     "CZCE": Exchange.CZCE,
    109     "DCE": Exchange.DCE,
    110     "INE": Exchange.INE,
--> 111     "GFEX": Exchange.GFEX
    112 }
    114 # 产品类型映射
    115 PRODUCT_CTP2VT: Dict[str, Product] = {
    116     THOST_FTDC_PC_Futures: Product.FUTURES,
    117     THOST_FTDC_PC_Options: Product.OPTION,
    118     THOST_FTDC_PC_SpotOption: Product.OPTION,
    119     THOST_FTDC_PC_Combination: Product.SPREAD
    120 }

File D:\Miniconda3\envs\py310\lib\enum.py:437, in EnumMeta.__getattr__(cls, name)
    435     return cls._member_map_[name]
    436 except KeyError:
--> 437     raise AttributeError(name) from None

AttributeError: GFEX
Member
avatar
加入于:
帖子: 644
声望: 34

这是因为新的广州期货交易所枚举值,升级到3.2.0版本试试吧

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】