Skip to content

Commit

Permalink
moex data provider: upgrade for aiomoex 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Jan 9, 2022
1 parent 197f475 commit d0504a9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions investments/data_providers/moex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
from typing import Optional

import aiohttp
import aiomoex # type: ignore
import pandas # type: ignore

Expand All @@ -18,10 +19,10 @@ async def async_get_board_candles(ticker: Ticker, cache_dir: Optional[str], star
if df is not None:
return df

async with aiomoex.ISSClientSession():
async with aiohttp.ClientSession() as session:
engine, market, board = '', '', ''

resp = await aiomoex.find_securities(ticker.symbol, columns=('secid', 'name', 'group', 'primary_boardid'))
resp = await aiomoex.find_securities(session, ticker.symbol, columns=('secid', 'name', 'group', 'primary_boardid'))
for x in resp:
if x['secid'] != ticker.symbol:
continue
Expand All @@ -31,7 +32,7 @@ async def async_get_board_candles(ticker: Ticker, cache_dir: Optional[str], star
if engine == '':
raise Exception(f'unknown ticker {ticker}')

rdata = await aiomoex.get_board_candles(ticker.symbol, start=start, end=end, interval=interval, engine=engine, market=market, board=board)
rdata = await aiomoex.get_board_candles(session, ticker.symbol, start=start, end=end, interval=interval, engine=engine, market=market, board=board)
df = pandas.DataFrame(rdata)
df.set_index('begin', inplace=True)
df.drop(['value'], axis=1, inplace=True)
Expand Down

0 comments on commit d0504a9

Please sign in to comment.