Open Maksim-Sheyngalts opened 1 year ago
import requests
import apimoex
import pandas as pd
share_name = 'MGNT'
xls_name = 'sberp.xlsx'
end_date = '2023-01-26'
with requests.Session() as session:
data = apimoex.get_board_candles(session, share_name, interval=10, start='2022-08-01', end=end_date)
df = pd.DataFrame(data)
print(df.head())
print(df.tail())
df.info()
У меня работает. Тут несколько вариантов:
А через proxy ? session.proxies.update(proxies)
не работает, такая же ошибка, но платный proxy ещё не использовал
Не знаю, у меня все работает. По какому принципу MOEX банит не знаю.
Traceback (most recent call last): at block 1, line 17 at /var/datalore/manager/.pip/apimoex/requests.py, line 377, in get_board_candles(session, security, interval, start, end, columns, board, market, engine) at /var/datalore/manager/.pip/apimoex/requests.py, line 126, in _get_long_data(session, url, table, query) at /var/datalore/manager/.pip/apimoex/client.py, line 124, in get_all(self) at /var/datalore/manager/.pip/apimoex/client.py, line 62, in iter(self) at /var/datalore/manager/.pip/apimoex/client.py, line 97, in get(self, start) at /var/datalore/manager/.pip/requests/sessions.py, line 600, in get(self, url, kwargs) at /var/datalore/manager/.pip/requests/sessions.py, line 587, in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json) at /var/datalore/manager/.pip/requests/sessions.py, line 701, in send(self, request, kwargs) at /var/datalore/manager/.pip/requests/adapters.py, line 565, in send(self, request, stream, timeout, verify, cert, proxies) ConnectionError: HTTPSConnectionPool(host='iss.moex.com', port=443): Max retries exceeded with url: /iss/engines/stock/markets/shares/boards/TQBR/securities/MGNT/candles.json?iss.json=extended&iss.meta=off&interval=10&from=2022-08-01&till=2023-01-26&iss.only=candles%2Chistory.cursor&candles.columns=begin%2Copen%2Cclose%2Chigh%2Clow%2Cvalue (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f9b62e6dd90>: Failed to establish a new connection: [Errno 110] Connection timed out'))