{"action":"opened","issue":{"url":"https://api.github.com/repos/vnpy/vnpy/issues/136","repository_url":"https://api.github.com/repos/vnpy/vnpy","labels_url":"https://api.github.com/repos/vnpy/vnpy/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/vnpy/vnpy/issues/136/comments","events_url":"https://api.github.com/repos/vnpy/vnpy/issues/136/events","html_url":"https://github.com/vnpy/vnpy/issues/136","id":170826240,"number":136,"title":"exchange拿不到交易所名称，其他关键字都没问题。调用的的是ctp接口。","user":{"login":"jieyujing","id":12085501,"avatar_url":"https://avatars.githubusercontent.com/u/12085501?v=3","gravatar_id":"","url":"https://api.github.com/users/jieyujing","html_url":"https://github.com/jieyujing","followers_url":"https://api.github.com/users/jieyujing/followers","following_url":"https://api.github.com/users/jieyujing/following{/other_user}","gists_url":"https://api.github.com/users/jieyujing/gists{/gist_id}","starred_url":"https://api.github.com/users/jieyujing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jieyujing/subscriptions","organizations_url":"https://api.github.com/users/jieyujing/orgs","repos_url":"https://api.github.com/users/jieyujing/repos","events_url":"https://api.github.com/users/jieyujing/events{/privacy}","received_events_url":"https://api.github.com/users/jieyujing/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-12T08:51:24Z","updated_at":"2016-08-12T08:51:24Z","closed_at":null,"body":"class getAccoutInfo(object):\r\n    \"\"\"获取账户信息\"\"\"\r\n    #----------------------------------------------------------------------\r\n    def __init__(self, mainEngine):\r\n        self.eventEngine = mainEngine.eventEngine\r\n        # 注册事件监听\r\n        self.accountDic = {}\r\n        self.positionDic = {}\r\n        self.registerEvent()\r\n\r\n    def onAccount(self, event):\r\n        info = event.dict_['data']\r\n        # 账号代码相关\r\n        self.accountDic[\"accountID\"] = info.accountID     # 账户代码\r\n        self.accountDic[\"vtAccountID\"] = info.vtAccountID         # 账户在vt中的唯一代码，通常是 Gateway名.账户代码\r\n        # 数值相关\r\n        self.accountDic[\"preBalance\"] = info.preBalance           # 昨日账户结算净值\r\n        self.accountDic[\"balance\"] = info.balance              # 账户净值\r\n        self.accountDic[\"available\"] = info.available            # 可用资金\r\n        self.accountDic[\"commission\"] = info.commission           # 今日手续费\r\n        self.accountDic[\"margin\"] = info.margin               # 保证金占用\r\n        self.accountDic[\"closeProfit\"] = info.closeProfit          # 平仓盈亏\r\n        self.accountDic[\"positionProfit\"] = info.positionProfit       # 持仓盈亏\r\n\r\n    def onPosition(self, event):\r\n        p = event.dict_['data']\r\n        # 代码编号相关\r\n        self.positionDic[\"symbol\"] = p.symbol              # 合约代码\r\n        self.positionDic[\"exchange\"] = p.exchange            # 交易所代码\r\n        self.positionDic[\"vtSymbol\"] = p.vtSymbol            # 合约在vt系统中的唯一代码，合约代码.交易所代码  \r\n    \r\n        # 持仓相关\r\n        self.positionDic[\"direction\"] = p.direction           # 持仓方向\r\n        self.positionDic[\"position\"] = p.position               # 持仓量\r\n        self.positionDic[\"frozen\"] = p.frozen                 # 冻结数量\r\n        self.positionDic[\"price\"] = p.price                # 持仓均价\r\n        self.positionDic[\"vtPositionName\"] = p.vtPositionName      # 持仓在vt系统中的唯一代码，通常是vtSymbol.方向\r\n    \r\n        # 20151020添加\r\n        self.positionDic[\"ydPosition\"] = p.ydPosition             # 昨持仓            \r\n        print self.positionDic\r\n        \r\n    def registerEvent(self):\r\n        \"\"\"注册事件监听\"\"\"\r\n        self.eventEngine.register(EVENT_POSITION, self.onPosition)"}}
{"actor":{"display_login":"jieyujing"}}