wlm1ke / aiomoex Goto Github PK
View Code? Open in Web Editor NEWAsyncio client for MOEX ISS
Home Page: https://wlm1ke.github.io/aiomoex/
License: The Unlicense
Asyncio client for MOEX ISS
Home Page: https://wlm1ke.github.io/aiomoex/
License: The Unlicense
Приветствую!
Отличный клиент для моекс!
Но не могу получить свечи для инструмента RIM3RIU3. (это календ.спред - https://www.moex.com/ru/spreads/)
Или это не возможно?
Python 3.8, jupyter notebook.
Пример 1:
async def main():
security = "LKOH"
interval = 24
start = "2020-12-01"
end = "2020-12-20"
async with aiohttp.ClientSession() as session:
data = await aiomoex.get_board_candles(session, security, interval, start, end)
df = pd.DataFrame(data)
print(df.head(), '\n')
print(df.tail(), '\n')
df.info()
await main()
Выполняется корректно ("верхняя" пятерка, "нижняя" пятерка и информация
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 14 entries, 0 to 13. и т.д.)
Пример 2: добавим определение board = "TQBR" явно для тикера "LKOH":
async def main():
security = 'LKOH'
interval = 24
start = '2020-12-01'
end = '2020-12-20'
board = 'TQBR'
async with aiohttp.ClientSession() as session:
data = await aiomoex.get_board_candles(session, security, board, interval, start, end)
df = pd.DataFrame(data)
print(df.head(), '\n')
print(df.tail(), '\n')
df.info()
await main()
Уже не выполняется корректно.
<class 'pandas.core.frame.DataFrame'>
Index: 0 entries
Empty DataFrame
Пример 3 (собственно откуда ноги замешательства начали расти) попробуем извлечь данные для ETF FXGD (есть для
'TQTF' и для 'TQTD' - рубли и доллары соответственно):
async def main():
security = 'FXGD'
interval = 24
start = "2020-12-01"
end = "2020-12-20"
board = 'TQTF'
async with aiohttp.ClientSession() as session:
data = await aiomoex.get_board_candles(session, security, board, interval, start, end)
df = pd.DataFrame(data)
print(df.head(), '\n')
print(df.tail(), '\n')
df.info()
await main()
Результат: Empty DataFrame
Если заменить board = 'TQTD'
, то результат аналогичный.
Реализована ли обработка ошибок (Неправильный ответ сервера)?
При выполнении примера функции из документации вываливается ошибка
`import asyncio
import aiomoex
import pandas as pd
async def main():
request_url = ('https://iss.moex.com/iss/engines/stock/'
'markets/shares/boards/TQBR/securities.json')
arguments = {'securities.columns': ('SECID,'
'REGNUMBER,'
'LOTSIZE,'
'SHORTNAME')}
iss = aiomoex.ISSClient(request_url, arguments)
iss.start_session()
data = await iss.get()
df = pd.DataFrame(data['securities'])
df.set_index('SECID', inplace=True)
print(df.head(), '\n')
print(df.tail(), '\n')
df.info()
await iss.close_session()
asyncio.run(main())`
RuntimeError Traceback (most recent call last)
in
23
24
---> 25 asyncio.run(main())
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/runners.py in run(main, debug)
31 """
32 if events._get_running_loop() is not None:
---> 33 raise RuntimeError(
34 "asyncio.run() cannot be called from a running event loop")
35
RuntimeError: asyncio.run() cannot be called from a running event loop
Простите, а авторизация но мосбирже поддерживается?
sudo pip install aiomoex
Downloading/unpacking aiomoex
Downloading aiomoex-1.2.0.tar.gz
Running setup.py (path:/tmp/pip_build_root/aiomoex/setup.py) egg_info for package aiomoex
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/aiomoex/setup.py", line 8, in
with open(pathlib.Path(file).parent / «aiomoex» / "init.py") as file:
TypeError: coercing to Unicode: need string or buffer, PosixPath found
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/aiomoex/setup.py", line 8, in
with open(pathlib.Path(file).parent / «aiomoex» / "init.py") as file:
TypeError: coercing to Unicode: need string or buffer, PosixPath found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.