diff --git a/README.md b/README.md index ef84a6f4..0f60458b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,15 @@ # By Traders, For Traders.
- + +
+ ++ + + + +
vn.py是一套基于Python的开源量化交易系统开发框架,自2015年1月正式发布以来,在开源社区5年持续不断的贡献下一步步成长为全功能量化交易平台,目前国内外金融机构用户已经超过300家,包括:私募基金、证券自营和资管、期货资管和子公司、高校研究机构、自营交易公司、交易所、Token Fund等。 diff --git a/vnpy/api/apex/FixApi.dll b/vnpy/api/apex/FixApi.dll index bd6dd2a9..9b9003a8 100644 Binary files a/vnpy/api/apex/FixApi.dll and b/vnpy/api/apex/FixApi.dll differ diff --git a/vnpy/api/apex/vnapex.py b/vnpy/api/apex/vnapex.py index 2a425636..a701171e 100644 --- a/vnpy/api/apex/vnapex.py +++ b/vnpy/api/apex/vnapex.py @@ -31,7 +31,7 @@ class ApexApi: def set_app_info(self, name: str, version: str): """设置应用信息""" - n = APEX.Fix_SetAppInfo(c_char_p(name), c_char_p(version)) + n = APEX.Fix_SetAppInfo(to_bytes(name), to_bytes(version)) return bool(n) def uninitialize(self): @@ -42,19 +42,19 @@ class ApexApi: def set_default_info(self, user: str, wtfs: str, fbdm: str, dest: str): """设置默认信息""" n = APEX.Fix_SetDefaultInfo( - c_char_p(user), - c_char_p(wtfs), - c_char_p(fbdm), - c_char_p(dest) + to_bytes(user), + to_bytes(wtfs), + to_bytes(fbdm), + to_bytes(dest) ) return bool(n) def connect(self, address: str, khh: str, pwd: str, timeout: int): """连接交易""" conn = APEX.Fix_Connect( - c_char_p(address), - c_char_p(khh), - c_char_p(pwd), + to_bytes(address), + to_bytes(khh), + to_bytes(pwd), timeout ) return conn @@ -66,13 +66,13 @@ class ApexApi: ): """连接交易""" conn = APEX.Fix_ConnectEx( - c_char_p(address), - c_char_p(khh), - c_char_p(pwd), - c_char_p(file_cert), - c_char_p(cert_pwd), - c_char_p(file_ca), - c_char_p(procotol), + to_bytes(address), + to_bytes(khh), + to_bytes(pwd), + to_bytes(file_cert), + to_bytes(cert_pwd), + to_bytes(file_ca), + to_bytes(procotol), verify, timeout ) @@ -100,27 +100,27 @@ class ApexApi: def set_wtfs(self, sess: int, wtfs: str): """设置委托方式""" - n = APEX.Fix_SetWTFS(sess, c_char_p(wtfs)) + n = APEX.Fix_SetWTFS(sess, to_bytes(wtfs)) return bool(n) def set_fbdm(self, sess: int, fbdm: str): """设置来源营业部""" - n = APEX.Fix_SetFBDM(sess, c_char_p(fbdm)) + n = APEX.Fix_SetFBDM(sess, to_bytes(fbdm)) return bool(n) def set_dest_fbdm(self, sess: int, fbdm: str): """设置目标营业部""" - n = APEX.Fix_SetDestFBDM(sess, c_char_p(fbdm)) + n = APEX.Fix_SetDestFBDM(sess, to_bytes(fbdm)) return bool(n) def set_node(self, sess: int, node: str): """设置业务站点""" - n = APEX.Fix_SetNode(sess, c_char_p(node)) + n = APEX.Fix_SetNode(sess, to_bytes(node)) return bool(n) def set_gydm(self, sess: int, gydm: str): """设置柜员号""" - n = APEX.Fix_SetGYDM(sess, c_char_p(gydm)) + n = APEX.Fix_SetGYDM(sess, to_bytes(gydm)) return bool(n) def create_head(self, sess: int, func: int): @@ -215,14 +215,16 @@ class ApexApi: APEX.Fix_GetToken(sess, out, size) return out.value - def encode(self, data): + def encode(self, data: str): """加密""" + data = to_bytes(data) buf = create_string_buffer(data, 512) APEX.Fix_Encode(buf) return buf.value def add_backup_svc_addr(self, address: str): """设置业务令牌""" + address = to_bytes(address) n = APEX.Fix_AddBackupSvrAddr(address) return bool(n) @@ -239,7 +241,7 @@ class ApexApi: def subscribe_by_customer(self, conn: int, svc: int, khh: str, pwd: str): """订阅数据""" func = APEX[93] - n = func(conn, svc, self.push_call_func, c_char_p(""), khh, pwd) + n = func(conn, svc, self.push_call_func, to_bytes(""), khh, pwd) return bool(n) def unsubscribe_by_handle(self, handle: int): @@ -264,12 +266,12 @@ class ApexApi: def set_system_no(self, sess: int, val: str): """设置系统编号""" - n = APEX.Fix_SetSystemNo(sess, c_char_p(val)) + n = APEX.Fix_SetSystemNo(sess, to_bytes(val)) return bool(n) def set_default_system_no(self, val: str): """设置默认系统编号""" - n = APEX.Fix_SetDefaultSystemNo(c_char_p(val)) + n = APEX.Fix_SetDefaultSystemNo(to_bytes(val)) return bool(n) def set_auto_reconnect(self, conn: int, reconnect: int): @@ -298,13 +300,13 @@ class ApexApi: def set_item(self, sess: int, fid: int, val: str): """设置请求内容""" - n = APEX.Fix_SetString(sess, fid, c_char_p(val)) + n = APEX.Fix_SetString(sess, fid, to_bytes(val)) return bool(n) def get_last_err_msg(self): """获取错误信息""" size = 256 - out = create_string_buffer("", size) + out = create_string_buffer(b"", size) APEX.Fix_GetLastErrMsg(out, size) return out.value @@ -328,3 +330,8 @@ class ApexApi: def on_conn(self, conn: int, event, recv): """连接回调(需要继承)""" return True + + +def to_bytes(data: str): + """""" + return data.encode("GBK")