def security_aggregates(q='', lang='ru', date=None): """/iss/securities/[security]/aggregates - https://iss.moex.com/iss/reference/214""" name = 'aggregates' url = 'http://iss.moex.com/iss/securities/{0}/aggregates.json?lang={1}&date={2}' if date: date = date.strftime('%Y-%m-%d') aggregates = request(url.format(q, lang, date), name) return aggregates
def security_bondyields(q='', boardid='', date=None): """/iss/securities/[security]/bondyields - https://iss.moex.com/iss/reference/713""" name = 'yields' url = 'http://iss.moex.com/iss/securities/{0}/bondyields.json?boardid={1}&date={2}' if date: date = date.strftime('%Y-%m-%d') bondyields = request(url.format(q, boardid, date), name) return bondyields
def trades(engine=None, market=None, boardid=None, securityid=None, limit=5000, reversed=0, previous_session=0, tradeno=0, start=0): """/iss/engines/.../trades""" name = 'trades' url = 'https://iss.moex.com/iss/engines/{0}/markets/{1}/trades.json?limit={4}&resersed={5}&previous_session={6}&tradeno={7}&start={8}' if boardid: url = 'https://iss.moex.com/iss/engines/{0}/markets/{1}/boards/{2}/trades.json?limit={4}&resersed={5}&previous_session={6}&tradeno={7}&start={8}' if securityid: url = 'https://iss.moex.com/iss/engines/{0}/markets/{1}/securities/{3}/trades.json?limit={4}&resersed={5}&previous_session={6}&tradeno={7}&start={8}' trades = request(url.format(engine, market, boardid, securityid, limit, reversed, previous_session, tradeno, start), name) trades.columns = trades.columns.str.lower() trades.loc[:, 'systime'] = pd.to_datetime(trades['systime'], format='%Y-%m-%d %H:%M:%S') return trades
def q(q='', lang='ru', engine='', market='', is_trading=None, group_by='', limit=100, start=0): """/iss/securities - https://iss.moex.com/iss/reference/5""" name = 'securities' url = 'https://iss.moex.com/iss/securities.json?q={0}&lang={1}&engine={2}&market={3}&is_trading={4}&group_by={5}\ &limit={6}&start={7}' secs = request( url.format(q, lang, engine, market, is_trading, group_by, limit, start), name) return secs
def candles(engine=None, market=None, boardid=None, securityid=None, start=0, dt1='', dt2='', interval=10): """/iss/engines/.../candles""" name = 'candles' if dt1: dt1 = dt1.strftime('%Y-%m-%d') if dt2: dt2 = dt2.strftime('%Y-%m-%d') if securityid: url = 'https://iss.moex.com/iss/engines/{0}/markets/{1}/securities/{3}/candles.json?start={4}&from={5}&till={6}&interval={7}' if boardid: url = 'https://iss.moex.com/iss/engines/{0}/markets/{1}/boards/{2}/securities/{3}/candles.json?start={4}&from={5}&till={6}&interval={7}' candles = request(url.format(engine, market, boardid, securityid, start, dt1, dt2, interval), name) else: raise AttributeError('securityid must be specified') candles.loc[:, 'begin'] = pd.to_datetime(candles['begin'], format='%Y-%m-%d %H:%M:%S') candles.loc[:, 'end'] = pd.to_datetime(candles['end'], format='%Y-%m-%d %H:%M:%S') return candles
def security_indices(q='', lang='ru', only_actual=0): """/iss/securities/[security]/indices - https://iss.moex.com/iss/reference/160""" name = 'indices' url = 'https://iss.moex.com/iss//securities/{0}/indices.json?lang={1}&only_actual={2}' indices = request(url.format(q, lang, only_actual), name) return indices
def security_boards(q='', lang='ru', start=0): """/iss/securities/[security] - https://iss.moex.com/iss/reference/13 (boards)""" name = 'boards' url = 'https://iss.moex.com/iss/securities/{0}.json?lang={1}&start={2}' boards = request(url.format(q, lang, start), name) return boards
def security_description(q='', lang='ru', start=0): """/iss/securities/[security] - https://iss.moex.com/iss/reference/13 (description)""" name = 'description' url = 'https://iss.moex.com/iss/securities/{0}.json?lang={1}&start={2}' description = request(url.format(q, lang, start), name) return description