def __init__(self, ctaEngine, setting): """Constructor""" super(Price_Different, self).__init__(ctaEngine, setting) self.logger = rwLoggerFunction() self.dbCon = rwDbConnection() self.positionDict = {} self.tickDict = {} self.orderDict = {} self.tradeDict = {} self.messageFlag = False self.buySellFlag = 0 self.positionDict_huobi = {} self.positionDict_okcoin = {} # 注意策略类中的可变对象属性(通常是list和dict等),在策略初始化时需要重新创建, # 否则会出现多个策略实例之间数据共享的情况,有可能导致潜在的策略逻辑错误风险, # 策略类中的这些可变对象属性可以选择不写,全都放在__init__下面,写主要是为了阅读 # 策略时方便(更多是个编程习惯的选择) self.flag = False
#!/usr/bin/env python # -*- coding: utf-8 -*- 'a socket example which send echo message to server.' import socket from radarwinFunction.rwDbConnection import * s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # 建立连接: dbCon = rwDbConnection() #SQL = 'SELECT strategy_name as name , port as port FROM strategy_master WHERE flag = 1' data = dbCon.getMySqlData(GET_STRATEGY_MASTER, dbFlag=DATABASE_VNPY) stragety = data[0] s.connect((SERVER_HOST, stragety['port'])) #s.connect(('localhost', stragety['port'])) # 接收欢迎消息: s.recv(1024) #for data in stragety['name']: # 发送数据: s.send(stragety['name']) s.recv(1024) s.send('exit') s.close()
def __init__(self, ctaEngine, setting): """Constructor""" super(Bolling, self).__init__(ctaEngine, setting) self.logger = rwLoggerFunction() self.dbCon = rwDbConnection() self.positionDict = {}