From a8dbe6cc27267b30e5b458433ce34ba686c63090 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Mon, 4 Dec 2017 17:44:54 +0800 Subject: [PATCH] =?UTF-8?q?[Mod]=E4=BF=AE=E6=94=B9=E4=B8=AD=E4=BF=A1?= =?UTF-8?q?=E6=9C=9F=E6=9D=83=E6=8E=A5=E5=8F=A3=E7=9A=84op=5Fstation?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/TRADE_MARKET_110100001088sop.dat | 2 +- .../gateway/cshshlpGateway/cshshlpGateway.py | 36 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/examples/OptionMaster/data/TRADE_MARKET_110100001088sop.dat b/examples/OptionMaster/data/TRADE_MARKET_110100001088sop.dat index 14e7a965..8d62ccfc 100644 --- a/examples/OptionMaster/data/TRADE_MARKET_110100001088sop.dat +++ b/examples/OptionMaster/data/TRADE_MARKET_110100001088sop.dat @@ -1 +1 @@ -lBUnZalf043zoNavP3G6rA== \ No newline at end of file +rGu69UiZhQTMFXCkVHH1kg== \ No newline at end of file diff --git a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py index 767fd7fb..c3516b41 100644 --- a/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py +++ b/vnpy/trader/gateway/cshshlpGateway/cshshlpGateway.py @@ -3,8 +3,12 @@ import sys import os import json +import socket +import urllib from time import sleep +import wmi + from vnpy.api.cshshlp import CsHsHlp from vnpy.api.ctp import MdApi from vnpy.trader.vtGateway import * @@ -586,10 +590,40 @@ class CshshlpTdApi(CsHsHlp): def connect(self, opEntrustWay, opStation, fundAccount, password): """""" self.opEntrustWay = opEntrustWay - self.opStation = opStation + #self.opStation = opStation self.fundAccount = fundAccount self.password = password + # 生成op_station + data = json.loads(urllib.urlopen("http://ip.jsontest.com/").read()) + iip = data["ip"] + + c = wmi.WMI() + + for interface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1): + mac = interface.MACAddress # MAC地址 + lip = interface.IPAddress[0] # 公网IP + + for processor in c.Win32_Processor(): + cpu = temp.processor.strip() # CPU编号 + + for disk in c.Win32_DiskDrive(): # 硬盘编号 + hdd = disk.SerialNumber.strip() + + for disk in c.Win32_LogicalDisk (DriveType=3): # 硬盘分区信息 + pi = ','.join([disk.Caption, disk.Size]) + + pcn = socket.gethostname() # 计算机名称 + + self.opStation = 'TYJR-%s-IIP.%s-LIP.%s-MAC.%s-HD.%s-PCN.%s-CPU.%s-PI.%s' %(opStation, + iip, + lip, + mac, + hd, + pcn, + cpu, + pi) + # 读取配置文件 i = self.loadConfig("Hsconfig.ini") if i: