3fbe6c9be5
- 添加 vnpy_v4.4.0/ 目录到版本控制 - 删除嵌入的 .git 目录避免嵌套仓库 - 添加 README_SANGUO.md 说明来源和用途 - 更新 .gitignore 移除 vnpy_v4.4.0/ 忽略规则 上游代码信息: - 项目: VeighNa 量化交易平台 - 版本: 4.4.0 - 来源: https://github.com/vnpy/vnpy 用途: 版本参考、代码学习、差异对比、离线开发 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
39 lines
685 B
Python
39 lines
685 B
Python
from time import sleep, time
|
|
|
|
from vnpy.rpc import RpcServer
|
|
|
|
|
|
class TestServer(RpcServer):
|
|
"""
|
|
Test RpcServer
|
|
"""
|
|
|
|
def __init__(self):
|
|
"""
|
|
Constructor
|
|
"""
|
|
super().__init__()
|
|
|
|
self.register(self.add)
|
|
|
|
def add(self, a, b):
|
|
"""
|
|
Test function
|
|
"""
|
|
print(f"receiving:{a} {b}")
|
|
return a + b
|
|
|
|
|
|
if __name__ == "__main__":
|
|
rep_address = "tcp://*:2014"
|
|
pub_address = "tcp://*:4102"
|
|
|
|
ts = TestServer()
|
|
ts.start(rep_address, pub_address)
|
|
|
|
while 1:
|
|
content = f"current server time is {time()}"
|
|
print(content)
|
|
ts.publish("test", content)
|
|
sleep(2)
|