API eTrade — ошибка загруженного примера: onnectionResetError: [WinError 10054] Существующее соединение было принудительPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 API eTrade — ошибка загруженного примера: onnectionResetError: [WinError 10054] Существующее соединение было принудитель

Сообщение Anonymous »

Надеюсь, кто-нибудь мне поможет. Я новичок в программировании на Python, я загрузил образец API eTrade и пытаюсь запустить его, и получаю эту ошибку. Я также пробовал это на C# и VB.NET, но безуспешно.

Код: Выделить всё

Exception has occurred: ConnectionError
('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

During handling of the above exception, another exception occurred:

File "C:\Users\kg5fc\Downloads\Bots\etrade_python_client.py", line 63, in oauth
request_token, request_token_secret = etrade.get_request_token(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\kg5fc\Downloads\Bots\etrade_python_client.py", line 111, in 
oauth()
Фрагмент кода, в котором обнаружена ошибка (последние 2 строки):

Код: Выделить всё

"""This Python script provides examples on using the E*TRADE API endpoints"""
from __future__ import print_function
import webbrowser
import json
import logging
import configparser
import sys
import requests
from rauth import OAuth1Service
from logging.handlers import RotatingFileHandler
from accounts.accounts import Accounts
from market.market import Market

# loading configuration file
config = configparser.ConfigParser()
config.read('config.ini')

# logger settings
logger = logging.getLogger('my_logger')
logger.setLevel(logging.DEBUG)
handler = RotatingFileHandler("python_client.log", maxBytes=5*1024*1024, backupCount=3)
FORMAT = "%(asctime)-15s %(message)s"
fmt = logging.Formatter(FORMAT, datefmt='%m/%d/%Y %I:%M:%S %p')
handler.setFormatter(fmt)
logger.addHandler(handler)

print('consumer_key: ' + config["DEFAULT"]["CONSUMER_KEY"])
print('consumer_secret: ' + config["DEFAULT"]["CONSUMER_SECRET"])

def oauth():
"""Allows user authorization for the sample application with OAuth 1"""
etrade = OAuth1Service(
name="etrade",
consumer_key=config["DEFAULT"]["CONSUMER_KEY"],
consumer_secret=config["DEFAULT"]["CONSUMER_SECRET"],
request_token_url="https://api.etrade.com/oauth/request_token",
access_token_url="https://api.etrade.com/oauth/access_token",
authorize_url="https://us.etrade.com/e/t/etws/authorize?key={}&token={}",
base_url="https://api.etrade.com")

menu_items = {"1": "Sandbox Consumer Key",
"2": "Live Consumer Key",
"3": "Exit"}
while True:
print("")
options = menu_items.keys()
for entry in options:
print(entry + ")\t" + menu_items[entry])
selection = input("Please select Consumer Key Type: ")
if selection == "1":
base_url = config["DEFAULT"]["SANDBOX_BASE_URL"]
break
elif selection == "2":
base_url = config["DEFAULT"]["PROD_BASE_URL"]
break
elif selection == "3":
break
else:
print("Unknown Option Selected!")
print("")

# Step 1: Get OAuth 1 request token and secret
request_token, request_token_secret = etrade.get_request_token(
params={"oauth_callback": "oob", "format": "json"})
Я использовал Google, ChatGPT и все, что мог придумать, чтобы найти решение.

Подробнее здесь: https://stackoverflow.com/questions/769 ... 10054-an-e
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»