get_equity()#

Retrieving Equity Prices#

Note

See Equity Market Data for documentation about the dataset and variables.

MoabDB

moabdb.get_equity(tickers: str | list, sample: str = '1m', start: str | None = None, end: str | None = None, intraday: bool = False) DataFrame[source]#

Returns a pandas.DataFrame of historical price and volume information for the ticker(s) requested.

Modifying the intraday flag changes the return dataframe between daily-level and intraday-level data. Daily-level data is returned by default, and intraday-level data is returned when the intraday flag is set to True. Intraday data is only available to users with an active subscription to intraday data from moabdb.com. Daily level data reports aggregated information for trades between 9:30 AM and 4:00 PM Eastern. Intraday level data reports aggregated information by second for trades between 8:00 AM and 6:00 PM Eastern.

Parameters:
tickersstr or list of str

The ticker(s) to look up. Accepts a single ticker as a string or multiple tickers as a list of strings.

If a single ticker (str) is provided, the resulting DataFrame will have a Datetime index, and the columns will represent individual data variables, such as “Open”, “High”, “Low”, “Close”, etc.

If multiple tickers (List[str]) are provided, the resulting DataFrame will have a Datetime index, and the columns will have a multi-index with the first level being the ticker symbol, and the second level being the data variable, such as “Open”, “High”, “Low”, “Close”, etc. For example, if you pass [“AAPL”, “MSFT”], the DataFrame columns will look like:

‘AAPL’

‘MSFT’

‘AAPL’

‘MSFT’

Open

Open

High

High

Datetime

samplestr, optional

Sample period length. It can be used alone or with start | end.

startstr, optional

Sample start date. Requires one of end or sample.

endstr, optional

Sample end date. Requires one of start or sample.

intradaybool, optional, default False

Set to True to return intraday data. Default is False to return end-of-day data. See moabdb.com for subscriptions for intraday access.

Returns:
outpandas.DataFrame

DataFrame containing equity price and volume information, indexed by datetime64. The format of the DataFrame depends on the request type.

If the request is for a single ticker, the DataFrame will be returned with single index.If the request is for multiple tickers, the DataFrame will be returned with multi-index columns, with the first level being the ticker symbol.

Daily data includes the following variables:

DataFrame Column

Variable Description

Symbol (str)

Ticker symbol of the equity.

Open (float)

Opening trade price.

High (float)

Highest trade price.

Low (float)

Lowest trade price.

Close (float)

Closing trade price.

VWAP (float)

Volume-weighted average price.

BidPrc (float)

Bid price.

AskPrc (float)

Ask price.

Volume (int)

Volume traded.

Trades (int)

Number of trades.

Intraday data includes the following variables:

DataFrame Column

Variable Description

Symbol (str)

Ticker symbol of the equity.

Trades (int)

Number of trades.

Volume (int)

Volume traded.

Imbalance (int)

Buy-initiated volume minus sell-initiated volume.

Close (float)

Closing trade price.

VWAP (float)

Volume-weighted average price.

BidPrc (float)

Bid price.

AskPrc (float)

Ask price.

BidSz (int)

Round lots available at BidPrc.

AskSz (int)

Round lots available at AskPrc.

Note

  • If the request is for a single ticker, the DataFrame will be returned with individual columns representing variables.

  • If the request is for multiple tickers, the DataFrame will have multi-index columns with the first level being the ticker symbol, and the second level being the data variable.

Raises:
errors.MoabResponseError:

If there’s a problem interpreting the response

errors.MoabRequestError:

If the server has a problem interpreting the request, or if an invalid parameter is passed

errors.MoabInternalError:

If the server runs into an unrecoverable error internally

errors.MoabHttpError:

If there’s a problem transporting the payload or receiving a response

errors.MoabUnauthorizedError:

If the user is not authorized to request the datatype

errors.MoabNotFoundError:

If the data requested wasn’t found

errors.MoabUnknownError:

If the error code couldn’t be parsed

Daily data examples, no login#

 1import moabdb as mdb
 2
 3# Request the last year of ``AAPL`` daily data.
 4df = mdb.get_equity("AAPL", "1y")
 5
 6# Request the most recent year of daily equity data for multiple stocks.
 7df = mdb.get_equity(["AMZN", "MSFT", "TSLA"], "1y")
 8
 9# Request a specific month of daily data.
10df = mdb.get_equity("AMZN", start="2022-04-01", sample="1m")
11
12# Request daily data between two specific dates.
13df = mdb.get_equity("AMZN", start="2022-04-01", end="2022-10-01")

Intraday data examples, with login#

Login for intraday data requests

>>> mdb.login("your_email@example.com", "moabdb_api_key")

Request the most recent month of intraday data.

>>> df = mdb.get_equity("TSLA", "1m", intraday=True)

Request intraday data between two specific dates:**

>>> df = mdb.get_equity("TSLA", start="2020-01-01", end="2020-06-01", intraday=True)