parse_historical_csv: Parse csv file containing historical OHLCV data

parse_historical_csvR Documentation

Parse csv file containing historical OHLCV data

Description

Helper function to parse a 'csv' file obtained from the 'PredictIt' website, containing historical 'OHLCV' (Open, High, Low, Close, Volume) data, into an object of class xts.

Usage

parse_historical_csv(csv_path, filename = NA)

Arguments

csv_path

Path to a 'csv' file containing historical 'OHLCV' data for a specific contract. Expected format is the same schema as the 'csv' file downloaded from the 'PredictIt' website.

filename

Optional name to give the 'csv' file when the filepath is derived from a temporary directory.

Value

A named list containing the following elements:

data

An S3 object of class xts. Time series containing the 'close' price data for the contract provided.

contract

A character representing the contract name, derived from the input file name. If a filename argument is provided, the contract name will be assigned to that value.

Examples

filename <- "What_will_be_the_balance_of_power_in_Congress_after_the_2020_election.csv"
csv_path <- system.file("extdata", filename, package = "rpredictit")
parse_historical_csv(csv_path)


danielkovtun/predictit documentation built on July 23, 2022, 9:28 p.m.