-
Notifications
You must be signed in to change notification settings - Fork 1
Documentation
class MoexImporter()
Class MoexImporter implements https-queries to MOEX ISS API.
You should to create at least one instance to work with other objects in the package. \
Base methods allow to get generic information about available engines and markets,
request securities lists and quotes. \
Quotes requests are wrapped in the MoexSecurity class to improve convenience.
def __init__(
header={
'user-agent':
'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0',
},
loadinfo=False)
Class constructor initializes base variables and load information about
engines and markets if flag _loadinfo
is True
header : dict, optional
HTTP-header for all requests to MOEX ISS API.
loadinfo: boolean, optional
If True
, engines and markets lists are requested from MOEX ISS. You may get
this information later with methods getEngines and getMarkets.
def getEngines()
Returns the list of engines.
array_like List of engines.
def getMarkets(engine)
Returns the list of markets.
engine: str The engine string identifier to get markets list.
array_like
List of markets for the specific engine
.
def getSecurity(seccode)
Returns the specific data for the security.
seccode: str
Security ticker.
array_like
List of specific data for seccode
.
def searchForSecurity(secpart)
Returns the list of all securities with the specific secpart
of the name or ticker.
secpart: str
Part of the security name or ticker.
array_like
List of securities.
def searchForSecurityTraded(secpart)
Returns the list of traded securities with the specific secpart
of the name or ticker.
secpart: str
Part of the security name or ticker.
array_like
List of securities.
def searchForSecurityNonTraded(secpart)
Returns the list of non-traded securities with the specific secpart
of the name or ticker.
secpart: str
Part of the security name or ticker.
array_like
List of securities.
def getSecuritiesAll()
Returns the list of all securities.
array_like List of securities.
def getSecuritiesAllTraded()
Returns the list of traded securities.
array_like List of securities.
def getSecuritiesAllNonTraded()
Returns the list of non-traded securities.
array_like List of securities.
def getBondsAll()
Returns the list of all local bonds.
array_like List of securities.
def getBondsAllTraded()
Returns the list of all traded local bonds.
array_like List of securities.
def getBondsAllNonTraded()
Returns the list of all non-traded local bonds.
array_like List of securities.
def getSharesAll()
Returns the list of all local shares.
array_like List of securities.
def getSharesAllTraded()
Returns the list of all traded local shares.
array_like List of securities.
def getSharesAllNonTraded()
Returns the list of all non-traded local shares.
array_like List of securities.
def getHistoryQuotes(engine, market, board, seccode, dtfrom, dttill, tsession,
start)
Returns quotes for the specific security.
engine: str Specify engine for quotes. market: str Specify market for quotes. board: str Specify board for quotes. seccode: str Security ticker. dtfrom: date Left bound of daterange for quotes. dttill: date Right bound of daterange for quotes. tsession: MoexSessions Specify trading session for quotes. start: int Specify cursor for query. MOEX ISS returns only limited number of quotes per request. You have to shift the cursor to get the next portion.
array_like List of quotes.
def getCandles(engine, market, board, seccode, dtfrom, dttill, start,
candleperiod)
Returns candles for the specific security.
engine: str Specify engine for quotes. market: str Specify market for quotes. board: str Specify board for quotes. seccode: str Security ticker. dtfrom: date Left bound of daterange for quotes. dttill: date Right bound of daterange for quotes. start: int Specify cursor for query. MOEX ISS returns only limited number of quotes per request. You have to shift the cursor to get the next portion. candleperiod: MoexCandlePeriods Period for candle.
array_like List of quotes.
class MoexSecurity()
Class MoexSecurity implements methods to store and request security-specific information.
Instance of MoexImporter should be created before.
def __init__(seccode, mi)
Class constructor initializes base variables and loads security-specific information from MOEX ISS.
seccode: str Security ticker from MOEX. mi: MoexImporter The object of MoexImporter that was created before. You can't use the class without this object.
def getHistoryQuotesAsDataFrame(dtfrom,
dttill,
board=None,
ts=MoexSessions.MainSession)
Returns quotes for the security as a pandas dataframe.
dtfrom: date
The left bound of the range to request quotes.
dttill: date
The right bound of the range to request quotes.
board: str, optional
Request quotes for the specific board. The primary board
is used if the parameter is ommited. You can check
class attribute boards
to get all available boards.
ts: MoexSessions, optional
Request quotes for the specific session. The main session
is used if the parameter is ommited.
pd.DataFrame
Quotes as pandas dataframe.
Columns:
'TRADEDATE' - date of the quote,
'OPEN' - open price,
'HIGH' - high price,
'LOW' - low price,
'CLOSE' - last price,
'YIELD' - yield to maturity, may be None for non-bonds,
'DURATION' - duration in days, may be None for non-bonds,
'VALUE' - trading value in rubles,
'QUANTITY' - trading value in securities.
def getHistoryQuotesAsArray(dtfrom,
dttill,
board=None,
ts=MoexSessions.MainSession)
Returns quotes for the security as an array of dicts.
dtfrom: date
The left bound of the range to request quotes.
dttill: date
The right bound of the range to request quotes.
board: str, optional
Request quotes for the specific board. The primary board
is used if the parameter is ommited. You can check
class attribute boards
to get all available boards.
ts: MoexSessions, optional
Request quotes for the specific session. The main session
is used if the parameter is ommited.
array_like
Quotes as an array of dicts.
Dict keys:
'TRADEDATE' - date of the quote,
'OPEN' - open price,
'HIGH' - high price,
'LOW' - low price,
'CLOSE' - last price,
'YIELD' - yield to maturity, may be None for non-bonds,
'DURATION' - duration in days, may be None for non-bonds,
'VALUE' - trading value in rubles,
'QUANTITY' - trading value in securities.
def getCandleQuotesAsDataFrame(dtfrom,
dttill,
board=None,
interval=MoexCandlePeriods.Period1Day)
Returns candles for the security as a pandas dataframe.
dtfrom: date
The left bound of the range to request quotes.
dttill: date
The right bound of the range to request quotes.
board: str, optional
Request quotes for the specific board. The primary board
is used if the parameter is ommited. You can check
class attribute boards
to get all available boards.
interval: MoexCandlePeriods, optional
Request candles for the specified period. Default is 1 day.
pd.DataFrame Candles as pandas dataframe. Columns: 'begin' - begin time of the candle, 'end' - end time of the candle, 'open' - open price, 'high' - high price, 'low' - low price, 'close' - last price, 'value' - trading value in rubles, 'quantity' - trading value in securities.
def getCandleQuotesAsArray(dtfrom,
dttill,
board=None,
interval=MoexCandlePeriods.Period1Day)
Returns quotes for the security as an array of dicts.
dtfrom: date
The left bound of the range to request quotes.
dttill: date
The right bound of the range to request quotes.
board: str, optional
Request quotes for the specific board. The primary board
is used if the parameter is ommited. You can check
class attribute boards
to get all available boards.
interval: MoexCandlePeriods, optional
Request candles for the specified period. Default is 1 day.
array_like Candles as an array of dicts. Dict keys: 'begin' - begin time of the candle, 'end' - end time of the candle, 'open' - open price, 'high' - high price, 'low' - low price, 'close' - last price, 'value' - trading value in rubles, 'quantity' - trading value in securities.
class MoexCandlePeriods(IntEnum)
Enum of candle periods.
Period for 1 minute candles.
Period for 10 minutes candles.
Period for 1 hour candles.
Period for 1 day candles.
Period for 1 week candles.
Period for 1 month candles.
Period for 1 quarter candles.
class MoexSessions(IntEnum)
Enum for MOEX sessions. Not applicable to all instruments.
Morning trading session.
Main trading session.
Evening tradning session.
Data for all sessions.