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

启动VN Station 加密策略文件成功了。
但尝试了一下,加密非策略文件,譬如加密回测的backtesting.py,报错,加密vnpy/app/cta_strategy/ 中的engine.py文件也报类似的错误。
请问是什么原因?

c:\vnstudio\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\vnstudio\Lib\site-packages\vnpy\app\cta_strategy\backtesting.py
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...

    def write_log(self, msg: str, strategy: CtaTemplate = None):
        """
        Write log message.
        """
        msg = f"{self.datetime}\t{msg}"
             ^
------------------------------------------------------------

Lib\site-packages\vnpy\app\cta_strategy\backtesting.py:1057:14: Cannot convert Unicode string to 'str' implicitly. This is not portable and requires explicit encoding.
Traceback (most recent call last):
  File "c:\vnstudio\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\vnstudio\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\vnstudio\Scripts\easycython.exe\__main__.py", line 9, in <module>
  File "c:\vnstudio\lib\site-packages\begin\main.py", line 54, in start
    collector=self._collector)
  File "c:\vnstudio\lib\site-packages\begin\cmdline.py", line 253, in apply_options
    return_value = call_function(func, signature(ext), opts)
  File "c:\vnstudio\lib\site-packages\begin\cmdline.py", line 236, in call_function
    return func(*pargs, **kwargs)
  File "c:\vnstudio\lib\site-packages\easycython\easycython.py", line 77, in main
    ext_modules = cythonize(ext_modules),
  File "c:\vnstudio\lib\site-packages\Cython\Build\Dependencies.py", line 1102, in cythonize
    cythonize_one(*args)
  File "c:\vnstudio\lib\site-packages\Cython\Build\Dependencies.py", line 1225, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: C:/vnstudio/Lib/site-packages/vnpy/app/cta_strategy/backtesting.py
Compiling C:/vnstudio/Lib/site-packages/vnpy/app/cta_strategy/backtesting.py because it changed.
[1/1] Cythonizing C:/vnstudio/Lib/site-packages/vnpy/app/cta_strategy/backtesting.py

加密失败。
Member
avatar
加入于:
帖子: 458
声望: 23

这里报错是因为日志输出语句:

msg = f"{self.datetime}\t{msg}"

这里的f-string写法在cython中不支持,可以跳帧改为其他的字符串拼接写法试试

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

沪公网安备 31011502017034号

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