FMP | R Documentation |
Get data data from FMP Cloud.
findata::DataAbstract
-> FMP
api_key
API KEY for FMP Cloud
base_url
Base URL for the FMP Cloud API.
new()
Create a new FMP object.
FMP$new(api_key = NULL, context_with_config = NULL, base_url = NULL)
api_key
API KEY for FMP cloud data.
context_with_config
AWS S3 Tiledb config
base_url
Base URL for the FMP Cloud API.
A new 'FMP' object.
get_earning_announcements()
Create a new FMP object.
FMP$get_earning_announcements(path, start_date = NULL)
path
to save reulst data.table
start_date
First date to scrape from.If NULL, date is 2010-01-01.
Earning announcements data.
get_earnings_suprises()
Get earnings suprises data from FMP cloud Prep.
FMP$get_earnings_suprises(year = format(Sys.Date(), "%Y"))
year
Year.
data.table with earnings surprises data.
get_transcripts()
Get Earning Call Transcript from FMP cloud.
FMP$get_transcripts(symbols, uri)
symbols
stock symbols. If tiledburi, import symbols from FMP events.
uri
to save transcripts data for every symbol.
Result of GET request
get_daily_tiledb()
get daily data from FMP cloud for all stocks
FMP$get_daily_tiledb(uri)
uri
to save daily data for every date.
Scrap all daily data
get_intraday_equities()
retrieving intraday market data from FMP cloud.
FMP$get_intraday_equities( symbol, multiply = 1, time = "day", from = as.character(Sys.Date() - 3), to = as.character(Sys.Date()) )
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.
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') ,
create_start_end_dates()
Help function for calculating start and end dates
FMP$create_start_end_dates(start_dates, n = 4)
start_dates
Sequence of start dates.
n
number of consecutive dates.
list of start and end dates
get_sp500_symbols()
Get SP500 symbols from fmp cloud.
FMP$get_sp500_symbols()
Vector of SP500 symbols.
get_factor_files()
Create factor files for calculating adjusted prices (adjusted for splits and dividends).
FMP$get_factor_files( save_uri = "s3://equity-usa-factor-files", prices_uri = "s3://equity-usa-daily-fmpcloud" )
save_uri
Uri where tiledb saves files
prices_uri
Uri to import prices from.
Factor files saved to "factor-file" blob.
get_ipo_date()
Get IPO date from fmp cloud
FMP$get_ipo_date(ticker)
ticker
Stock ticker
Stock IPO date.
get_ipo_calendar_confirmed_bulk()
Get ipo-calendar-confirmed date from fmp cloud
FMP$get_ipo_calendar_confirmed_bulk(start_date, end_date = Sys.Date())
start_date
Start date
end_date
End date.
uri
TileDB uri argument
Stock IPO date.
get_fi_statement()
Get FI data.
FMP$get_fi_statement( symbol, statement = c("income-statement", "balance-sheet-statement", "cash-flow-statement"), period = c("annual", "quarter") )
symbol
Stock symbol.
statement
Stock statement.
period
Stock period.
data.table of financial reports.
get_financial_metrics()
Get financial ratios, company key metrics.
FMP$get_financial_metrics( symbol, type = c("ratios", "key-metrics", "financial-growth"), period = c("annual", "quarter") )
symbol
Stock symbol.
type
Type of fundamental analysis.
period
Stock period.
data.table of financial reports.
get_stock_splits()
Get stock splits data from FMP cloud Prep.
FMP$get_stock_splits(start_date = Sys.Date() - 5, end_date = Sys.Date())
start_date
Start date
end_date
End date.
data.table of stock splits
get_market_cap()
Get market cap data from FMP cloud Prep.
FMP$get_market_cap(ticker, limit = 10)
ticker
Ticker.
limit
Limit.
data.table with market cap data.
get_market_cap_bulk()
Get market cap data from FMP cloud Prep - bulk.
FMP$get_market_cap_bulk(symbols, uri)
symbols
stock symbols.
uri
to market cap data.
data.table with market cap data.
get_stock_list()
Get stock list.
FMP$get_stock_list()
data.table with stock list data.
get_symbol_changes()
Get symbol changes.
FMP$get_symbol_changes()
data.table with symbol changes data.
get_delisted_companies()
Get delisted companies.
FMP$get_delisted_companies()
data.table with delisted companies data.
get_available_traded_list()
Get available traded list.
FMP$get_available_traded_list()
data.table with available traded list data.
get_sp500_constituent()
Get SP500 stocks.
FMP$get_sp500_constituent()
data.table with SP500 tocks.
get_fi_statement_bulk()
Get Financial Statements data
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") )
uri
uri path to the directory.
years
Get statement for specific year.
statement
quarter or annual.
period
quarter or annual.
data.table of financial reports.
get_daily_v4()
Help function for getting grades and targets
FMP$get_daily_v4(symbols, tag = "price-target")
symbols
stock symbols.
tag
url tag.
Result of GET request
get_grades()
Get Upgrades and Downgrades from FMP cloud.
FMP$get_grades(symbols)
symbols
stock symbols. If tiledburi, import symbols from FMP events.
Result of GET request
get_targets()
Get Price Targest from FMP cloud.
FMP$get_targets(symbols)
symbols
stock symbols. If tiledburi, import symbols from FMP events.
Result of GET request
get_ratings()
Get Ratings from FMP cloud.
FMP$get_ratings( symbols, uri = "ratings.parquet", update = FALSE, update_limit = 10 )
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.
Result of GET request
get_historical_dividends()
Get Historical dividends from FMP cloud.
FMP$get_historical_dividends(symbols)
symbols
Vector of stock symbols.
Data table with historical dividends for symbol.
get_equities_batch()
Get hour data for all history from fmp cloud and save as parquet on AWS.
FMP$get_equities_batch( symbols, uri_minute = "s3://equity-usa-minute", deep_scan = FALSE )
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.
Data saved to uri.
get_minute()
Get minute data for all history from FMP cloud.
FMP$get_minute(symbols, uri_minute, deep_scan = FALSE, workers = 1L)
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.
Data saved to uri.
get_dividends()
Get dividend data from FMP cloud Prep.
FMP$get_dividends(ticker)
ticker
Ticker.
data.table with dividend data.
beneficial_ownership()
Get beneficial ownership from FMP cloud.
FMP$beneficial_ownership(ticker)
ticker
Ticker.
data.table with beneficial ownership data.
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.
FMP$get_full_quote(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing the full quote for the specified stock.
get_quote_order()
Get a simplified quote for a stock, including the current price, volume, and last trade price.
FMP$get_quote_order(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing the quote order for the specified stock.
get_simple_quote()
Get a simple quote for a stock, including the price, change, and volume.
FMP$get_simple_quote(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing the simple quote for the specified stock.
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.
FMP$get_otc_quote(symbol)
symbol
The OTC stock symbol(s) (e.g., "BATRB,FWONB").
A data.table containing the OTC quote for the specified stock(s).
get_exchange_prices()
Get real-time prices for all stocks listed on a specific exchange.
FMP$get_exchange_prices(exchange = "NYSE")
exchange
The exchange for which to retrieve prices (e.g., "NYSE").
A data.table containing real-time prices for all stocks on the specified exchange.
get_stock_price_change()
Get the change in a stock's price over a given period of time.
FMP$get_stock_price_change(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing the stock price change for the specified stock.
get_aftermarket_trades()
Get information on trades that have occurred in the aftermarket.
FMP$get_aftermarket_trades(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing aftermarket trade information for the specified stock.
get_aftermarket_quote()
Get the latest bid and ask prices for a stock in the aftermarket.
FMP$get_aftermarket_quote(symbol)
symbol
The stock symbol (e.g., "AAPL").
A data.table containing aftermarket quote information for the specified stock.
get_batch_quote()
Get quotes for multiple stocks at once.
FMP$get_batch_quote(symbols)
symbols
A comma-separated string of stock symbols (e.g., "AAPL,MSFT").
A data.table containing batch quote information for the specified stocks.
get_batch_trade()
Get trades for multiple stocks at once.
FMP$get_batch_trade(symbols)
symbols
A comma-separated string of stock symbols (e.g., "AAPL,MSFT").
A data.table containing batch trade information for the specified stocks.
clone()
The objects of this class are cloneable with this method.
FMP$clone(deep = FALSE)
deep
Whether to make a deep clone.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.