Esempio n. 1
0
 def get_Positions(self):
     funcNo = '301503'
     sj = servlet_json(self.conn)
     sj.postdata = {
         'funcsb':
         urllib.parse.quote(Comm.aesEncrypt(self.__aes_key,
                                            funcNo + '*' + self.username),
                            safe=""),
         'funcNo':
         funcNo,
         'fund_account':
         self.username,
         'entrust_way':
         self.__entrust_way,
         'branch_no':
         self.__logInfo['results'][0]['branch_no'],
         'cust_code':
         self.username,
         'password':
         '',
         'op_station':
         OP_STATION,
         'sessionid':
         '',
         'money_type':
         '',
         'op_source':
         '',
     }
     return sj.post()
Esempio n. 2
0
    def Entrust(self, code, bs, price, amount):
        StockInterceptor = self.get_StockInterceptor(code)
        if len(StockInterceptor['results']) != 1:
            return {"error_no": "-1", "results": [], "error_info": "输入的股票代码有误"}
        exchange_type = StockInterceptor['results'][0]['market']
        stockInfo = self.get_StockInfo(code, bs, price)
        if stockInfo['error_no'] != '0':
            return stockInfo
        if float(price) > float(
                stockInfo['results'][0]['up_limit']) or float(price) < float(
                    stockInfo['results'][0]['down_limit']):
            return {
                "error_no": "-1",
                "results": [],
                "error_info": "委托价格在涨跌停范围之外"
            }
        if float(stockInfo['results'][0]['stock_max_amount']) < float(amount):
            return {
                "error_no":
                "-1",
                "results": [],
                "error_info":
                "委托数量%d超过最大限额%s" %
                (amount, stockInfo['results'][0]['stock_max_amount'])
            }
        price = stockInfo['results'][0]['price']
        stock_account = stockInfo['results'][0]['stock_account']

        funcNo = '301501'
        value = '*'.join(
            [funcNo, self.username, 'A467162210', price,
             str(amount), code])
        sj = servlet_json(self.conn)
        sj.postdata = {
            'funcNo':
            funcNo,
            'funcsb':
            urllib.parse.quote(Comm.aesEncrypt(self.__aes_key, value),
                               safe=""),
            'entrust_way':
            self.__entrust_way,
            'branch_no':
            '',
            'fund_account':
            self.username,
            'cust_code':
            self.username,
            'password':
            '',
            'op_station':
            OP_STATION,
            'sessionid':
            '',
            'entrust_bs':
            bs,
            'exchange_type':
            exchange_type,
            'stock_account':
            stock_account,
            'stock_code':
            code,
            'entrust_price':
            price,
            'entrust_amount':
            amount,
            'batch_no':
            ','
        }
        return sj.post()