vnpy/examples/simple_rpc/test_client.py

37 lines
726 B
Python
Raw Permalink Normal View History

2019-04-02 09:07:07 +00:00
from __future__ import print_function
from __future__ import absolute_import
from time import sleep
from vnpy.rpc import RpcClient
2019-04-02 09:07:07 +00:00
class TestClient(RpcClient):
"""
Test RpcClient
"""
def __init__(self):
2019-04-02 09:07:07 +00:00
"""
Constructor
"""
super(TestClient, self).__init__()
2019-04-02 09:07:07 +00:00
def callback(self, topic, data):
"""
Realize callable function
"""
print(f"client received topic:{topic}, data:{data}")
2019-04-02 09:07:07 +00:00
if __name__ == "__main__":
req_address = "tcp://localhost:2014"
sub_address = "tcp://localhost:4102"
2019-04-02 09:07:07 +00:00
tc = TestClient()
tc.subscribe_topic("")
tc.start(req_address, sub_address)
2019-04-02 09:07:07 +00:00
while 1:
print(tc.add(1, 3))
sleep(2)