4 Star 3 Fork 1

柔为信息技术/虚拟货币交易系统python策略示例

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
小瀚 提交于 2018-08-01 19:35 . Create position strategy
import sys
sys.path.append('protosGen')
from config.constants import Constants
from protosGen.marketGateway_pb2_grpc import *
from protosGen.login_pb2 import *
from protosGen.login_pb2_grpc import *
from protosGen.orderreporting_pb2 import *
from protosGen.orderreporting_pb2_grpc import *
import time
from common import header_manipulator_client_interceptor
import signal
import ma_strategy
import position_strategy
class RouweiDemo:
def __init__(self):
channelAuth = grpc.insecure_channel(Constants.HOST + ":" + Constants.PORT_AUTH)
loginStub = LoginStub(channelAuth)
rspLogin = loginStub.login(ReqLogin(
username=Constants.USER_NAME,
password=Constants.USER_PASSWORD))
if not rspLogin.success:
print("rspLogin.message:" + str(rspLogin.message))
print("rspLogin.success:" + str(rspLogin.success))
print("rspLogin.token:" + str(rspLogin.token))
return
header_adder_interceptor = header_manipulator_client_interceptor.header_adder_interceptor('token', rspLogin.token)
intercept_channel = grpc.intercept_channel(channelAuth, header_adder_interceptor)
order_stub = OrderReportingStub(intercept_channel)
channelPublic = grpc.insecure_channel(Constants.HOST + ':' + Constants.PORT_PUBLIC)
mdmStub = MarketDataManageStub(channelPublic)
# maStrategy = ma_strategy.MaStrategy(mdmStub, order_stub)
# maStrategy.start()
# print(ma_strategy.strategy_name + " started, you could follow its logs in the output folder.")
positionStrategy = position_strategy.PositionStrategy(mdmStub, order_stub)
positionStrategy.start()
print(position_strategy.strategy_name + " started, you could follow its logs in the output folder.")
# Safely exit using keybord: Ctrl + c
def shutdown(signal, frame):
# maStrategy.stop()
positionStrategy.stop()
sys.exit()
for sig in [signal.SIGINT, signal.SIGTERM]:
signal.signal(sig, shutdown)
while True:
time.sleep(360)
if __name__ == '__main__':
RouweiDemo()
print('--end--')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/softwin/ccts_python_strategy.git
git@gitee.com:softwin/ccts_python_strategy.git
softwin
ccts_python_strategy
虚拟货币交易系统python策略示例
master

搜索帮助