VeighNa量化社区
你的开源社区量化交易平台
leapeto's Avatar
Member
离线
14 帖子
声望: 0

对的,但是我上面用c++直接调用api是没有问题的。不清楚还有哪里可能有问题

将vnctptd.cpp中的reqAuthenticate函数改成下面的,然后再自行编译。

int TdApi::reqAuthenticate(const dict &req, int reqid)
{
    CThostFtdcReqAuthenticateField myreq = CThostFtdcReqAuthenticateField();
    memset(&myreq, 0, sizeof(myreq));
    getString(req, "BrokerID", myreq.BrokerID);
    getString(req, "UserID", myreq.UserID);
    getString(req, "UserProductInfo", myreq.UserProductInfo);
    getString(req, "AuthCode", myreq.AuthCode);
    getString(req, "AppID", myreq.AppID);

    std::ofstream outputFile("/home/ubuntu/workspace/output.txt");
    if (!outputFile.is_open()) {
        std::cerr << "Failed to open the file for writing." << std::endl;
        return 1;
    }
    outputFile << myreq.BrokerID << std::endl;
    outputFile << myreq.UserID << std::endl;
    outputFile << myreq.UserProductInfo << std::endl;
    outputFile << myreq.AuthCode << std::endl;
    outputFile << myreq.AppID << std::endl;
    outputFile.close();

    int i = this->api->ReqAuthenticate(&myreq, reqid);
    return i;
};

检查对应的txt文件,发现传出去的参数是一致的。 通过类似的方式更改回调函数:

void TdApi::OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{

    std::ofstream outputFile("/home/ubuntu/workspace/output.txt");
    if (!outputFile.is_open()) {
        std::cerr << "Failed to open the file for writing." << std::endl;
        return;
    }
    outputFile << "OnRspAuthenticate!!!" << std::endl;
    outputFile.close();


    Task task = Task();
    task.task_name = ONRSPAUTHENTICATE;
    if (pRspAuthenticateField)
    {
        CThostFtdcRspAuthenticateField *task_data = new CThostFtdcRspAuthenticateField();
        *task_data = *pRspAuthenticateField;
        task.task_data = task_data;
    }
    if (pRspInfo)
    {
        CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
        *task_error = *pRspInfo;
        task.task_error = task_error;
    }
    task.task_id = nRequestID;
    task.task_last = bIsLast;
    this->task_queue.push(task);
};

会发现没有调用过这个回调函数...

description

我这边用c++可以得到正常的结果

def authenticate(self) -> None:
    """发起授权验证"""
    if self.auth_failed:
        return

    ctp_req: dict = {
        "UserID": self.userid,
        "BrokerID": self.brokerid,
        "AuthCode": self.auth_code,
        "AppID": self.appid
    }

    self.reqid += 1
    print('td发送验证请求', ctp_req)
    n = self.reqAuthenticate(ctp_req, self.reqid)
    print('td验证结果', n)


这个所得到的n输出是0

参考这个:https://cloud.tencent.com/developer/article/1479193

我现在知道mac_address等信息是在动态链接库里面的函数获取的,错误代码64我再和期货公司联系

但是问题是为什么vnpy没有这个错误代码直接卡住。。

在vnpy_ctp/api/vnctpmd/vnctpmd.cpp 中,我想请问一下下图中例如MacAddress这类变量是怎么获取的?我没有找到对应代码,而在python中调用reqUserLogin所传入的字典只有UserID, Password, BrokerID。还是说这类变量是空值?我用c++发送了md login的请求的时候这些是空值,得到的Error64的返回。

description

我这边使用c++,还是可以返回错误代码的。因为我不是很明白这个field怎么填写:CThostFtdcReqUserLoginField,最后出现Error64即CTP:客户端未认证。

但是使用vnpy框架,这个错误代码都没有。

我觉得多半是vnpy在获取信息来填写这个表单的时候,获取信息卡住了。

和这位也是一样的问题:
https://www.vnpy.com/forum/topic/31989-ubuntu22-04xia-ctpshou-quan-yan-zheng-wu-fa-hui-diao

生产环境和simnow都是一样的

参考了这个,是一样的问题:
https://www.vnpy.com/forum/topic/32287-ubuntufu-wu-qi-shang-wu-fa-ding-yue-ctpquan-shi-chang-xing-qing-shu-ju

我这边尝试了sudo启动,
sudo /home/ubuntu/anaconda3/envs/vnpy/bin/python run.py
是一样的结果

以及这个是腾讯云服务器,我不确定有没有虚拟机的问题....

在本地机器上运行no_ui是可以登录的,然而尝试使用linux云服务器的时候,运行no_ui会导致下面的情况一直卡住。连接服务器成功,但是一直没有登陆成功or登录失败的log。请问可以从什么方向排查这个问题?

description

如何不显示这一堆输出?在脚本中反复调用会输出大量这种内容,需要去包里面改,还是说有不输出的模式?

2023-07-04 11:15:59.885622 开始加载历史数据 2023-07-04 11:15:59.885655 加载进度:# [0%] 2023-07-04 11:15:59.886258 加载进度:# [10%] 2023-07-04 11:15:59.886653 加载进度:## [20%] 2023-07-04 11:15:59.887174 加载进度:### [30%] 2023-07-04 11:15:59.887694 加载进度:#### [40%] 2023-07-04 11:15:59.888200 加载进度:##### [50%] 2023-07-04 11:15:59.888714 加载进度:###### [60%] 2023-07-04 11:15:59.889456 加载进度:####### [70%] 2023-07-04 11:15:59.889967 加载进度:######## [80%] 2023-07-04 11:15:59.890482 加载进度:######### [90%] 2023-07-04 11:15:59.890995 加载进度:########## [100%] 2023-07-04 11:15:59.891049 历史数据加载完成,数据量:219135 2023-07-04 11:15:59.974569 开始加载历史数据 2023-07-04 11:15:59.974662 加载进度:# [0%] 2023-07-04 11:16:00.039109 加载进度:# [10%] 2023-07-04 11:16:00.069916 加载进度:## [20%] 2023-07-04 11:16:00.136448 加载进度:### [30%] 2023-07-04 11:16:00.206859 加载进度:#### [40%] 2023-07-04 11:16:00.307291 加载进度:##### [50%] 2023-07-04 11:16:00.430767 加载进度:###### [60%] 2023-07-04 11:16:00.497400 加载进度:####### [70%] 2023-07-04 11:16:00.554654 加载进度:######## [80%] 2023-07-04 11:16:00.609842 加载进度:######### [90%] 2023-07-04 11:16:00.663002 加载进度:########## [100%] 2023-07-04 11:16:00.663613 历史数据加载完成,数据量:11372888

将font size 和font family 调整了之后就不会窗口崩溃了。不过依旧不能往上拉,100%缩放也不行。但可以将窗口拖出来放到上面,也能够使用

MTF wrote:

最低分辨率是1920x1080,如果确认够的话把缩放改为100%

谢谢,缩放为100%确实不会有问题,之前设置全局125%。
但是我不想全局设置为100%,因为会导致其他应用字体模糊。是否存在某种方式单独不缩放VNstation?在win10右键该应用的兼容性设置里所有方式均无法实现

无法将日志窗口往上拉,一旦拖动就会导致日志、资金、持仓三个窗口消失。

description

之后如果“还原窗口”就会出现这样的问题,依然无法上拉:

description

© 2015-2022 微信 18391752892
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

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