从python变量中提取值

问题描述 投票:0回答:2

[当我运行以下代码时,我得到一个包含要在代码中使用的值(1.11113)的输出(在第一部分之后)。我得到的完整输出显示在代码后。基本上,我要尝试的是提取实时外汇(股票)值以用于订单中。此命令将放在同一Python模块中此初始代码之后。感谢您的帮助。

 import json
    from oandapyV20.contrib.requests import MarketOrderRequest
    from oandapyV20.contrib.requests import TakeProfitDetails, StopLossDetails
    import oandapyV20.endpoints.orders as orders
    import oandapyV20
    import oandapyV20.endpoints.pricing as pricing
    from exampleauth import exampleAuth
    import argparse
    from oandapyV20 import API
    from oandapyV20.exceptions import V20Error
    import oandapyV20.endpoints.instruments as instruments
    from oandapyV20.definitions.instruments import CandlestickGranularity
    import re
    import oandapyV20.endpoints.pricing as pricing

    #pricef=float(price)
    #parser.add_argument('--price', choices=price, default='M', help='Mid/Bid/Ask')
    accountID, access_token = exampleAuth()
    api = oandapyV20.API(access_token=access_token)

    params={"instruments": "EUR_USD"}
    r = pricing.PricingInfo(accountID=accountID, params=params)
    rv = api.request(r)

    print(rv)

输出{'time':'2020-05-31T23:02:40.672716661Z','price':[{'type':'PRICE','time':'2020-05-31T23:02:34.271983628Z',' bids':[{'price':'1.11113','liquidity':10000000}],'asks':[{'price':'1.11132','liquidity':10000000}],'closeoutBid':'1.11113' ,'closeoutAsk':'1.11132','status':'tradeable','tradeable':True,'unitsAvailable':{'default':{'long':'3852555','short':'3852555'}, 'openOnly':{'long':'3852555','short':'3852555'},'reduceFirst':{'long':'3852555','short':'3852555'},'reduceOnly':{' long':'0','short':'0'}},'quoteHomeConversionFactors':{'positiveUnits':'1.00000000','negativeUnits':'1.00000000'},'instrument':'EUR_USD'}]}]] >

[当我运行以下代码时,我得到一个包含要在代码中使用的值(1.11113)的输出(在第一部分之后)。我得到的完整输出显示在代码后。基本上是我的...

python arrays variables extract
2个回答
0
投票

看起来像您想要的:


0
投票

您的输出是带有许多嵌套列表和字典的字典。

© www.soinside.com 2019 - 2024. All rights reserved.