0

所以跟进这个问题,我仍然有相同的代码:开始处理一些实时数据,我从沙箱切换到单个密钥,并开始使用在沙箱模式下工作的代码出现此错误:

HTTPError:401 客户端错误:未经授权的 url:https ://apisb.etrade.com/v1/market/optionexpiredate?symbol=NFLX&expiryType=ALL

这是身份验证代码,以防我在这里搞砸了:

consumer_key = "[key, double checked]"
consumer_secret = "[secret, double checked]" 

def authenticate():
    #get the auth UIL
    oauth = pyetrade.ETradeOAuth(consumer_key, consumer_secret)
    oauth.setToken(consumer_key)
    oauth.setTokenSecret(consumer_secret)
    print(oauth.get_request_token())

    #ask the user to put the verification code in to get tokens
    verifier_code = input("Enter verification code: ")
    global tokens 
    tokens = oauth.get_access_token(verifier_code)
    print(tokens)

    #Setting up the object used for Access Management
    global authManager 
    authManager = pyetrade.authorization.ETradeAccessManager(
        consumer_key,
        consumer_secret,
        tokens['oauth_token'],
        tokens['oauth_token_secret']
    )

这是返回错误的代码:

try:
    q = market.get_option_expire_date(thisSymbol,resp_format='xml')
    expiration_dates = option_expire_dates_from_xml(q)
except:
    raise Exception("Rip, get date not working")

我不确定为什么会这样:(任何帮助将不胜感激!

4

0 回答 0