查询订单

        Arguments:
            accounts {[type]} -- [description]

        Keyword Arguments:
            status {str} -- 'open' 待成交 'filled' 成交 (default: {'filled'})

        Returns:
            [type] -- [description]
490174
def query_orders(self, accounts, status='filled'):
        
        try:
            data = self.call("orders", {'client': accounts, 'status': status})

            if data is not None:
                orders = data.get('dataTable', False)

                order_headers = orders['columns']
                if ('成交状态' in order_headers
                        or '状态说明' in order_headers) and ('备注' in order_headers):
                    order_headers[order_headers.index('备注')] = '废弃'

                order_headers = [cn_en_compare[item] for item in order_headers]
                order_all = pd.DataFrame(
                    orders['rows'],
                    columns=order_headers
                ).assign(account_cookie=accounts)

                order_all.towards = order_all.towards.apply(
                    lambda x: trade_towards_cn_en[x]
                )
                if 'order_time' in order_headers:
                    # 这是order_status
                    order_all['status'] = order_all.status.apply(
                        lambda x: order_status_cn_en[x]
                    )
                    if 'order_date' not in order_headers:
                        order_all.order_time = order_all.order_time.apply(
                            lambda x: QA_util_get_order_datetime(
                                dt='{} {}'.format(datetime.date.today(),
                                                  x)
                            )
                        )
                    else:
                        order_all = order_all.assign(
                            order_time=order_all.order_date
                            .apply(QA_util_date_int2str) + ' ' +
                            order_all.order_time
                        )

                if 'trade_time' in order_headers:

                    order_all.trade_time = order_all.trade_time.apply(
                        lambda x: '{} {}'.format(datetime.date.today(),
                                                 x)
                    )

                if status is 'filled':
                    return order_all.loc[:,
                                         self.dealstatus_headers].set_index(
                                             ['account_cookie',
                                              'realorder_id']
                    ).sort_index()
                else:
                    return order_all.loc[:,
                                         self.orderstatus_headers].set_index(
                                             ['account_cookie',
                                              'realorder_id']
                    ).sort_index()
            else:
                print('response is None')
                return False
        except Exception as e:
            print(e)
            return False
85295
def get_info(self, account, params={}):
        
        res = self.invoke(zconstant.NS_ZIMBRA_ADMIN_URL,
                          sconstant.GetInfoRequest,
                          params)

        return res
102353
def query_positions(self, accounts):
        
        try:
            data = self.call("positions", {'client': accounts})
            if data is not None:
                cash_part = data.get('subAccounts', {}).get('人民币', False)
                if cash_part:
                    cash_available = cash_part.get('可用金额', cash_part.get('可用'))

                position_part = data.get('dataTable', False)
                if position_part:
                    res = data.get('dataTable', False)
                    if res:
                        hold_headers = res['columns']
                        hold_headers = [
                            cn_en_compare[item] for item in hold_headers
                        ]
                        hold_available = pd.DataFrame(
                            res['rows'],
                            columns=hold_headers
                        )
                if len(hold_available) == 1 and hold_available.amount[0] in [
                        None,
                        '',
                        0
                ]:
                    hold_available = pd.DataFrame(
                        data=None,
                        columns=hold_headers
                    )
                return {
                    'cash_available':
                    cash_available,
                    'hold_available':
                    hold_available.assign(
                        amount=hold_available.amount.apply(float)
                    ).loc[:,
                          ['code',
                           'amount']].set_index('code').amount
                }
            else:
                print(data)
                return False, 'None ACCOUNT'
        except:
            return False
613940
def get_initial_status_brok(self, extra=None):
        
        data = {'uuid': self.uuid}
        self.fill_data_brok_from(data, 'full_status')
        if extra:
            data.update(extra)
        return Brok({'type': 'initial_' + self.my_type + '_status', 'data': data})
431681
def status(self, **kwargs):
        
        self.services = dict(
            init_system=self.init_system,
            services=[]
        )
285927
def __get_holding_accounts_query(self):
        
        query = (
            self.book.session.query(Account)
            .filter(Account.commodity == self.security)
            .filter(Account.type != AccountType.trading.value)
        )
        # generic.print_sql(query)
        return query
1009256
def rpc_get_account_record(self, address, token_type, **con_info):
        
        if not check_account_address(address):
            return {'error': 'Invalid address', 'http_status': 400}

        if not check_token_type(token_type):
            return {'error': 'Invalid token type', 'http_status': 400}

        # must be b58
        if is_c32_address(address):
            address = c32ToB58(address)

        db = get_db_state(self.working_dir)
        account = db.get_account(address, token_type)
        db.close()

        if account is None:
            return {'error': 'No such account', 'http_status': 404}

        state = self.export_account_state(account)
        return self.success_response({'account': state})
230499
def get_customer_request_status(self, issue_id_or_key):
        
        request = self.get('rest/servicedeskapi/request/{}/status'.format(issue_id_or_key)).get('values')
        status = request[0].get('status')

        return status
856685
def list_tickets(self, open_status=True, closed_status=True):
        
        mask = """mask[id, title, assignedUser[firstName, lastName], priority,
                  createDate, lastEditDate, accountId, status, updateCount]"""

        call = 'getTickets'
        if not all([open_status, closed_status]):
            if open_status:
                call = 'getOpenTickets'
            elif closed_status:
                call = 'getClosedTickets'
            else:
                raise ValueError("open_status and closed_status cannot both be False")

        return self.client.call('Account', call, mask=mask, iter=True)
199433
def lock_status(account_id, resource_id, parent_id):
    
    return output(
        Client(BASE_URL, account_id).lock_status(resource_id, parent_id))
800032
def get_update_status_brok(self):
        
        data = {'uuid': self.uuid}
        self.fill_data_brok_from(data, 'full_status')
        return Brok({'type': 'update_' + self.my_type + '_status', 'data': data})
279007
def get_account_details(self):
        
        headers = self._manager.get_account_headers()
        acct_prefix = "x-account-"
        meta_prefix = ACCOUNT_META_PREFIX.lower()
        ret = {}
        for hkey, hval in list(headers.items()):
            lowkey = hkey.lower()
            if lowkey.startswith(acct_prefix):
                if not lowkey.startswith(meta_prefix):
                    cleaned = hkey.replace(acct_prefix, "").replace("-", "_")
                    try:
                        # Most values are ints
                        ret[cleaned] = int(hval)
                    except ValueError:
                        ret[cleaned] = hval
        return ret
472932
def get_openOrders(self, acc_id=None, symbol=None, side=None, size=None, _async=False):
        
        params = {}
        path = '/v1/order/openOrders'
        if all([acc_id, symbol]):
            params['account-id'] = acc_id
            params['symbol'] = symbol
        if side:
            assert side in ['buy', 'sell']
            params['side'] = side
        if size:
            params['size'] = size

        return api_key_get(params, path, _async=_async)
745533
def status(self):
        
        if 'sandbox_type' in self.engine.data:
            if self.engine.sandbox_type == 'none':
                return False
            return True
        return False
520333
def params(self):
        
        params = {}
        params["access_token"] = self.access_token
        params["account_id"] = self.account_id
        params["alert_id"] = self.alert_id
        params["mention_id"] = self.mention_id
        params["before_date"] = self.before_date if self.before_date else ""

        if self.limit:
            if int(self.limit) > 1000:
                params["limit"] = "1000"
            elif int(self.limit) < 1:
                params["limit"] = ""
            else:
                params["limit"] = self.limit

        return params
681981
def login(self, login_type, **kwargs):
        
        content = {
            "type": login_type
        }
        for key in kwargs:
            if kwargs[key]:
                content[key] = kwargs[key]

        return self._send("POST", "/login", content)
1234903
def descriptions(cls):
        
        schema = cls.json_get('%s/status/schema' % cls.api_url, empty_key=True,
                              send_key=False)
        descs = {}
        for val in schema['fields']['status']['value']:
            descs.update(val)
        return descs