当前位置: 首页>>代码示例>>Python>>正文


Python Request.set_param方法代码示例

本文整理汇总了Python中request.Request.set_param方法的典型用法代码示例。如果您正苦于以下问题:Python Request.set_param方法的具体用法?Python Request.set_param怎么用?Python Request.set_param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在request.Request的用法示例。


在下文中一共展示了Request.set_param方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import set_param [as 别名]
    def list(
        self,
        accountID,
        **kwargs
    ):
        """List Trades

        Get a list of Trades for an Account

        Parameters
        ----------
        accountID : 
            ID of the Account to fetch Trades for.
        ids : array, optional
            List of Trade IDs to retrieve.
        state : , optional
            The state to filter the requested Trades by.
        instrument : , optional
            The instrument to filter the requested Trades by.
        count : integer, optional
            The maximum number of Trades to return.
        beforeID : , optional
            The maximum Trade ID to return. If not provided the most recent
            Trades in the Account are returned.
        """


        request = Request(
            'GET',
            '/v3/accounts/{accountID}/trades'
        )

        request.set_path_param(
            'accountID',
            accountID
        )

        request.set_param(
            'ids',
            kwargs.get('ids')
        )

        request.set_param(
            'state',
            kwargs.get('state')
        )

        request.set_param(
            'instrument',
            kwargs.get('instrument')
        )

        request.set_param(
            'count',
            kwargs.get('count')
        )

        request.set_param(
            'beforeID',
            kwargs.get('beforeID')
        )

        response = self.ctx.request(request)


        if response.content_type is None:
            return response

        if not response.content_type.startswith("application/json"):
            return response

        jbody = json.loads(response.raw_body)

        parsed_body = {}

        if response.status is 200:
            if jbody.get('trades') is not None:
                parsed_body['trades'] = [
                    Trade.from_dict(d)
                    for d in jbody.get('trades')
                ]

            if jbody.get('lastTransactionID') is not None:
                parsed_body['lastTransactionID'] = \
                    jbody.get('lastTransactionID')


        if response.status is 401:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
                    jbody.get('errorCode')

            if jbody.get('errorMessage') is not None:
                parsed_body['errorMessage'] = \
                    jbody.get('errorMessage')


        if response.status is 404:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
#.........这里部分代码省略.........
开发者ID:darthjewel,项目名称:v20-python,代码行数:103,代码来源:trade.py

示例2: get

# 需要导入模块: from request import Request [as 别名]
# 或者: from request.Request import set_param [as 别名]
    def get(
        self,
        accountID,
        **kwargs
    ):
        """Current Prices

        Get pricing information for a specified list of Instruments within an
        Account.

        Parameters
        ----------
        accountID : 
            ID of the Account to fetch current Prices for.
        instruments : array, optional
            List of Instruments to get pricing for.
        since : , optional
            Date/Time filter to apply to the returned prices. Only prices with
            a time later than this filter will be provided.
        """


        request = Request(
            'GET',
            '/v3/accounts/{accountID}/pricing'
        )

        request.set_path_param(
            'accountID',
            accountID
        )

        request.set_param(
            'instruments',
            kwargs.get('instruments')
        )

        request.set_param(
            'since',
            kwargs.get('since')
        )

        response = self.ctx.request(request)


        if response.content_type is None:
            return response

        if not response.content_type.startswith("application/json"):
            return response

        jbody = json.loads(response.raw_body)

        parsed_body = {}

        if response.status is 200:
            if jbody.get('prices') is not None:
                parsed_body['prices'] = [
                    Price.from_dict(d)
                    for d in jbody.get('prices')
                ]


        if response.status is 400:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
                    jbody.get('errorCode')

            if jbody.get('errorMessage') is not None:
                parsed_body['errorMessage'] = \
                    jbody.get('errorMessage')


        if response.status is 401:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
                    jbody.get('errorCode')

            if jbody.get('errorMessage') is not None:
                parsed_body['errorMessage'] = \
                    jbody.get('errorMessage')


        if response.status is 404:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
                    jbody.get('errorCode')

            if jbody.get('errorMessage') is not None:
                parsed_body['errorMessage'] = \
                    jbody.get('errorMessage')


        if response.status is 405:
            if jbody.get('errorCode') is not None:
                parsed_body['errorCode'] = \
                    jbody.get('errorCode')

            if jbody.get('errorMessage') is not None:
                parsed_body['errorMessage'] = \
#.........这里部分代码省略.........
开发者ID:darthjewel,项目名称:v20-python,代码行数:103,代码来源:pricing.py


注:本文中的request.Request.set_param方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。