FMP: FMP Class

FMPR Documentation

FMP Class

Description

Get data data from FMP Cloud.

Super class

findata::DataAbstract -> FMP

Public fields

api_key

API KEY for FMP Cloud

base_url

Base URL for the FMP Cloud API.

Methods

Public methods


Method new()

Create a new FMP object.

Usage
FMP$new(api_key = NULL, context_with_config = NULL, base_url = NULL)
Arguments
api_key

API KEY for FMP cloud data.

context_with_config

AWS S3 Tiledb config

base_url

Base URL for the FMP Cloud API.

Returns

A new 'FMP' object.


Method get_earning_announcements()

Create a new FMP object.

Usage
FMP$get_earning_announcements(path, start_date = NULL)
Arguments
path

to save reulst data.table

start_date

First date to scrape from.If NULL, date is 2010-01-01.

Returns

Earning announcements data.


Method get_earnings_suprises()

Get earnings suprises data from FMP cloud Prep.

Usage
FMP$get_earnings_suprises(year = format(Sys.Date(), "%Y"))
Arguments
year

Year.

Returns

data.table with earnings surprises data.


Method get_transcripts()

Get Earning Call Transcript from FMP cloud.

Usage
FMP$get_transcripts(symbols, uri)
Arguments
symbols

stock symbols. If tiledburi, import symbols from FMP events.

uri

to save transcripts data for every symbol.

Returns

Result of GET request


Method get_daily_tiledb()

get daily data from FMP cloud for all stocks

Usage
FMP$get_daily_tiledb(uri)
Arguments
uri

to save daily data for every date.

Returns

Scrap all daily data


Method get_intraday_equities()

retrieving intraday market data from FMP cloud.

Usage
FMP$get_intraday_equities(
  symbol,
  multiply = 1,
  time = "day",
  from = as.character(Sys.Date() - 3),
  to = as.character(Sys.Date())
)
Arguments
symbol

Symbol of the stock.

multiply

multiplier.Start date.

time

Size of the time. (minute, hour, day, week, month, quarter, year)

from

Start date,

to

End date.

Returns

Data frame with ohlcv data. #' @description Get tick quote data from FMP cloud. #' #' @param symbol Symbol of the stock. #' @param date multiplier.Start date. #' #' @return Data frame with ohlcv data. get_quotes = function(symbol, date)

# debug # library(httr) # library(data.table) # self = list() # self$api_key = Sys.getenv("APIKEY-FMPCLOUD") # symbol = "SPY" # date = "2023-08-18"

# init list q = list()

# initial GET request. Don't use RETRY here yet. x <- tryCatch( GET(paste0('https://financialmodelingprep.com/api/v4/historical-price-tick/', symbol, '/', date), query = list(limit = 30000, apikey = self$api_key), timeout(100)) , error = function(e) NA) x <- content(x) q[[1]] = rbindlist(x$results)

# get last time last_time = tail(q[[1]]$t, 1)

x <- tryCatch( GET(paste0('https://financialmodelingprep.com/api/v4/historical-price-tick/', symbol, '/', date), query = list(limit = 300, ts = last_time, te = last_time + 1000, apikey = self$api_key), timeout(100)) , error = function(e) NA) x <- content(x) rbindlist(x$results) q[[2]] = rbindlist(x$results)

# url = "https://financialmodelingprep.com/api/v4/historical-price-tick/SPY/2023-08-04?limit=500&apikey=15cd5d0adf4bc6805a724b4417bbaafc" # GET(url)

# control error tries <- 0 while (all(is.na(x)) & tries < 20) print("There is an error in scraping market data. Sleep and try again!") Sys.sleep(60L) x <- tryCatch( GET(paste0('https://financialmodelingprep.com/api/v4/historical-price/', symbol, '/', multiply, '/', time, '/', from, '/', to), query = list(apikey = self$api_key), timeout(100)) , error = function(e) NA) tries <- tries + 1

# check if status is ok. If not, try to download again if (x$status_code == 404) print("There is an 404 error!") return(NULL) else if (x$status_code == 200) x <- content(x) return(rbindlist(x$results)) else x <- RETRY("GET", paste0('https://financialmodelingprep.com/api/v4/historical-price/', symbol, '/', multiply, '/', time, '/', from, '/', to), query = list(apikey = self$api_key), times = 5, timeout(100)) if (x$status_code == 200) x <- content(x) return(rbindlist(x$results)) else stop('Error in reposne. Status not 200 and not 404') ,


Method create_start_end_dates()

Help function for calculating start and end dates

Usage
FMP$create_start_end_dates(start_dates, n = 4)
Arguments
start_dates

Sequence of start dates.

n

number of consecutive dates.

Returns

list of start and end dates


Method get_sp500_symbols()

Get SP500 symbols from fmp cloud.

Usage
FMP$get_sp500_symbols()
Returns

Vector of SP500 symbols.


Method get_factor_files()

Create factor files for calculating adjusted prices (adjusted for splits and dividends).

Usage
FMP$get_factor_files(
  save_uri = "s3://equity-usa-factor-files",
  prices_uri = "s3://equity-usa-daily-fmpcloud"
)
Arguments
save_uri

Uri where tiledb saves files

prices_uri

Uri to import prices from.

Returns

Factor files saved to "factor-file" blob.


Method get_ipo_date()

Get IPO date from fmp cloud

Usage
FMP$get_ipo_date(ticker)
Arguments
ticker

Stock ticker

Returns

Stock IPO date.


Method get_ipo_calendar_confirmed_bulk()

Get ipo-calendar-confirmed date from fmp cloud

Usage
FMP$get_ipo_calendar_confirmed_bulk(start_date, end_date = Sys.Date())
Arguments
start_date

Start date

end_date

End date.

uri

TileDB uri argument

Returns

Stock IPO date.


Method get_fi_statement()

Get FI data.

Usage
FMP$get_fi_statement(
  symbol,
  statement = c("income-statement", "balance-sheet-statement", "cash-flow-statement"),
  period = c("annual", "quarter")
)
Arguments
symbol

Stock symbol.

statement

Stock statement.

period

Stock period.

Returns

data.table of financial reports.


Method get_financial_metrics()

Get financial ratios, company key metrics.

Usage
FMP$get_financial_metrics(
  symbol,
  type = c("ratios", "key-metrics", "financial-growth"),
  period = c("annual", "quarter")
)
Arguments
symbol

Stock symbol.

type

Type of fundamental analysis.

period

Stock period.

Returns

data.table of financial reports.


Method get_stock_splits()

Get stock splits data from FMP cloud Prep.

Usage
FMP$get_stock_splits(start_date = Sys.Date() - 5, end_date = Sys.Date())
Arguments
start_date

Start date

end_date

End date.

Returns

data.table of stock splits


Method get_market_cap()

Get market cap data from FMP cloud Prep.

Usage
FMP$get_market_cap(ticker, limit = 10)
Arguments
ticker

Ticker.

limit

Limit.

Returns

data.table with market cap data.


Method get_market_cap_bulk()

Get market cap data from FMP cloud Prep - bulk.

Usage
FMP$get_market_cap_bulk(symbols, uri)
Arguments
symbols

stock symbols.

uri

to market cap data.

Returns

data.table with market cap data.


Method get_stock_list()

Get stock list.

Usage
FMP$get_stock_list()
Returns

data.table with stock list data.


Method get_symbol_changes()

Get symbol changes.

Usage
FMP$get_symbol_changes()
Returns

data.table with symbol changes data.


Method get_delisted_companies()

Get delisted companies.

Usage
FMP$get_delisted_companies()
Returns

data.table with delisted companies data.


Method get_available_traded_list()

Get available traded list.

Usage
FMP$get_available_traded_list()
Returns

data.table with available traded list data.


Method get_sp500_constituent()

Get SP500 stocks.

Usage
FMP$get_sp500_constituent()
Returns

data.table with SP500 tocks.


Method get_fi_statement_bulk()

Get Financial Statements data

Usage
FMP$get_fi_statement_bulk(
  uri,
  years = 1999:(data.table::year(Sys.Date())),
  statement = c("income-statement-bulk", "balance-sheet-statement-bulk",
    "cash-flow-statement-bulk", "ratios-bulk", "key-metrics-bulk",
    "financial-growth-bulk", "income-statement-growth-bulk",
    "balance-sheet-statement-growth-bulk", "cash-flow-statement-growth-bulk"),
  period = c("annual", "quarter")
)
Arguments
uri

uri path to the directory.

years

Get statement for specific year.

statement

quarter or annual.

period

quarter or annual.

Returns

data.table of financial reports.


Method get_daily_v4()

Help function for getting grades and targets

Usage
FMP$get_daily_v4(symbols, tag = "price-target")
Arguments
symbols

stock symbols.

tag

url tag.

Returns

Result of GET request


Method get_grades()

Get Upgrades and Downgrades from FMP cloud.

Usage
FMP$get_grades(symbols)
Arguments
symbols

stock symbols. If tiledburi, import symbols from FMP events.

Returns

Result of GET request


Method get_targets()

Get Price Targest from FMP cloud.

Usage
FMP$get_targets(symbols)
Arguments
symbols

stock symbols. If tiledburi, import symbols from FMP events.

Returns

Result of GET request


Method get_ratings()

Get Ratings from FMP cloud.

Usage
FMP$get_ratings(
  symbols,
  uri = "ratings.parquet",
  update = FALSE,
  update_limit = 10
)
Arguments
symbols

stock symbols. If tiledburi, import symbols from FMP events.

uri

uri to save output data.

update

Should we scrape all data od jut the new one.

update_limit

how many days to retrieve if update eqtual to TRUE.

Returns

Result of GET request


Method get_historical_dividends()

Get Historical dividends from FMP cloud.

Usage
FMP$get_historical_dividends(symbols)
Arguments
symbols

Vector of stock symbols.

Returns

Data table with historical dividends for symbol.


Method get_equities_batch()

Get hour data for all history from fmp cloud and save as parquet on AWS.

Usage
FMP$get_equities_batch(
  symbols,
  uri_minute = "s3://equity-usa-minute",
  deep_scan = FALSE
)
Arguments
symbols

Symbol of the stock.

uri_minute

AWS S3 bucket uri or NAS path.

deep_scan

should we test for dates with low number od observation and try to scrap again.

save_uri_hour

AWS S3 bucket uri for hour data.

save_uri_daily

AWS S3 bucket uri for daily data.

Returns

Data saved to uri.


Method get_minute()

Get minute data for all history from FMP cloud.

Usage
FMP$get_minute(symbols, uri_minute, deep_scan = FALSE, workers = 1L)
Arguments
symbols

Symbol of the stock.

uri_minute

AWS S3 bucket uri or NAS path.

deep_scan

should we test for dates with low number od observation and try to scrap again.

workers

Number of workers.

Returns

Data saved to uri.


Method get_dividends()

Get dividend data from FMP cloud Prep.

Usage
FMP$get_dividends(ticker)
Arguments
ticker

Ticker.

Returns

data.table with dividend data.


Method beneficial_ownership()

Get beneficial ownership from FMP cloud.

Usage
FMP$beneficial_ownership(ticker)
Arguments
ticker

Ticker.

Returns

data.table with beneficial ownership data.


Method get_full_quote()

Get the latest bid and ask prices for a stock, as well as the volume and last trade price in real-time.

Usage
FMP$get_full_quote(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing the full quote for the specified stock.


Method get_quote_order()

Get a simplified quote for a stock, including the current price, volume, and last trade price.

Usage
FMP$get_quote_order(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing the quote order for the specified stock.


Method get_simple_quote()

Get a simple quote for a stock, including the price, change, and volume.

Usage
FMP$get_simple_quote(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing the simple quote for the specified stock.


Method get_otc_quote()

Get the latest bid and ask prices for an OTC stock, as well as the volume and last trade price in real-time.

Usage
FMP$get_otc_quote(symbol)
Arguments
symbol

The OTC stock symbol(s) (e.g., "BATRB,FWONB").

Returns

A data.table containing the OTC quote for the specified stock(s).


Method get_exchange_prices()

Get real-time prices for all stocks listed on a specific exchange.

Usage
FMP$get_exchange_prices(exchange = "NYSE")
Arguments
exchange

The exchange for which to retrieve prices (e.g., "NYSE").

Returns

A data.table containing real-time prices for all stocks on the specified exchange.


Method get_stock_price_change()

Get the change in a stock's price over a given period of time.

Usage
FMP$get_stock_price_change(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing the stock price change for the specified stock.


Method get_aftermarket_trades()

Get information on trades that have occurred in the aftermarket.

Usage
FMP$get_aftermarket_trades(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing aftermarket trade information for the specified stock.


Method get_aftermarket_quote()

Get the latest bid and ask prices for a stock in the aftermarket.

Usage
FMP$get_aftermarket_quote(symbol)
Arguments
symbol

The stock symbol (e.g., "AAPL").

Returns

A data.table containing aftermarket quote information for the specified stock.


Method get_batch_quote()

Get quotes for multiple stocks at once.

Usage
FMP$get_batch_quote(symbols)
Arguments
symbols

A comma-separated string of stock symbols (e.g., "AAPL,MSFT").

Returns

A data.table containing batch quote information for the specified stocks.


Method get_batch_trade()

Get trades for multiple stocks at once.

Usage
FMP$get_batch_trade(symbols)
Arguments
symbols

A comma-separated string of stock symbols (e.g., "AAPL,MSFT").

Returns

A data.table containing batch trade information for the specified stocks.


Method clone()

The objects of this class are cloneable with this method.

Usage
FMP$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


MislavSag/findata documentation built on June 2, 2025, 12:34 p.m.