ghfd_get_HF_data: Downloads and aggregates high frequency trading data directly...

Description Usage Arguments Value Examples

View source: R/ghfd_get_HF_data.R

Description

This function downloads zip files containing trades from Bovespa's ftp (ftp://ftp.bmf.com.br/MarketData/) and imports it into R. See the vignette and examples for more details on how to use the function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
ghfd_get_HF_data(
  my.assets = NULL,
  type.matching = "exact",
  type.market = "equity",
  type.data = "trades",
  first.date = "2016-01-01",
  last.date = "2016-01-05",
  first.time = NULL,
  last.time = NULL,
  type.output = "agg",
  agg.diff = "15 min",
  dl.dir = "ftp files",
  max.dl.tries = 10,
  clean.files = FALSE,
  only.dl = FALSE
)

Arguments

my.assets

The tickers (symbols) of the derised assets to import data (e.g. c('PETR4', 'VALE5')). The function allow for partial patching (e.g. 'PETR' for all assets related to Petrobras). Default is set to NULL (download all available tickers)

type.matching

Type of matching for asset names in data ('exact' or 'partial')

type.market

The type of market to download data from ('equity', 'equity-odds','options', 'BMF' ).

type.data

The type of financial data to download and aggregate ('trades' or 'orders').

first.date

The first date of the imported data (e.g. '2016-01-01')

last.date

The last date of the imported data (e.g. '2016-01-05')

first.time

The first intraday period to import the data. All trades/orders before this time of day are ignored. As character, e.g. '10:00:00'.

last.time

The last intraday period to import the data. All trades/orders after this time of day are ignored. As character, e.g. '18:00:00'.

type.output

Defines the type of output of the data. The choice 'agg' outputs aggregated data for time intervals defined in agg.diff. The choice 'raw' outputs the raw, tick by tick/order by order, data from the zip files.

agg.diff

The time interval used in the aggregation of data. Only used for type.output='agg'. It should contain a integer followed by a time unit ('sec' or 'secs', 'min' or 'mins', 'hour' or 'hours', 'day' or 'days'). Example: agg.diff = '15 mins', agg.diff = '1 hour'.

dl.dir

The folder to download the zip files (default = 'ftp files')

max.dl.tries

Maximum attempts to download the files from ftp

clean.files

Logical. Should the files be removed after reading it? (TRUE or FALSE)

only.dl

Logical. Should the function only download the files? (TRUE or FALSE). This is usefull if you just want the file for later analysis

Value

A dataframe with the financial data in the raw format (tick by tick) or aggregated

Examples

1
2
3
4
5
6
7
8
9
my.assets <- 'ABEVA69'
type.market <- 'options'
first.date <- as.Date('2015-12-29')
last.date <- as.Date('2015-12-29')

## Not run: 
df.out <- ghfd_get_HF_data(my.assets, type.market, first.date,  last.date)

## End(Not run)

msperlin/GetHFData documentation built on July 4, 2020, 11:48 a.m.