示例#1
0
 def loadSetting(self):
     """载入设置"""
     # 载入用户信息
     d = load_json(USER_FILE)
     self.userID = d['userID']  # 账号
     self.password = d['password']  # 密码
     self.brokerID = d['brokerID']  # 经纪商代码
     self.MdIp = d['MdIp']  # 行情服务器地址
     self.TdIp = d['TdIp']  # 交易服务器地址
示例#2
0
 def loadSetting(self):
     """载入设置"""
     # 载入用户信息
     d = load_json(USER_FILE)
     self.userID = d['userID']  # 账号
     self.password = d['password']  # 密码
     self.brokerID = d['brokerID']  # 经纪商代码
     self.MdIp = d['MdIp']  # 行情服务器地址
     self.TdIp = d['TdIp']  # 交易服务器地址
     self.authCode = d['authCode']  # 授权码
     self.appID = d['appID']  # 软件代号
     self.userProductInfo = d['userProductInfo']  # 产品信息
示例#3
0
    def loadContracts(self):
        """从硬盘读取合约对象"""

        contractFilePath = WORKING_DIR + 'temp/contracts'
        contractDict = load_json(contractFilePath)

        for k, v in contractDict:
            # 创建合约信息实例
            contract = CtaContractData()
            contract.vtSymbol = contract.symbol = k
            contract.name = v.get('name')
            contract.exchange = v.get('exchange')
            contract.size = v.get('size')
            contract.priceTick = v.get('priceTick')
            contract.strikePrice = v.get('strikePrice')
            contract.underlyingSymbol = v.get('underlyingSymbol')
            contract.optionType = v.get('optionType')
            self.contractDict[k] = contract
示例#4
0
    def loadSyncData(self, strategy):
        """从本地载入策略的持仓情况"""
        flt = {'name': strategy.name, 'vtSymbol': strategy.vtSymbol}
        # syncData = self.mainEngine.dbQuery(POSITION_DB_NAME, strategy.className, flt)
        syncData = {}
        syncFile = WORKING_DIR + 'setting/syncdata/' + strategy.name + '-' + strategy.vtSymbol
        try:
            syncData = load_json(syncFile)
        except IOError:
            content = '策略{name}持仓同步数据读取失败,未找到文件'.format(name=strategy.name)
            self.writeCtaLog(content)

        if not syncData:
            return

        # d = syncData[0]
        d = syncData

        for key in strategy.syncList:
            if key in d:
                strategy.__setattr__(key, d[key])
示例#5
0
 def loadSetting(self):
     """读取策略配置"""
     l = load_json(self.settingfilePath)
     for setting in l:
         self.loadStrategy(setting)