R/ghfd_read_file.R
ghfd_read_file.Rd
Reads zip file downloaded from Bovespa ftp (trades or orders)
ghfd_read_file(out.file, my.assets = NULL, type.matching = "exact", type.data = "trades", first.time = "10:00:00", last.time = "17:00:00", type.output = "agg", agg.diff = "15 min")
out.file | Name of zip file |
---|---|
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.data | The type of financial data to download and aggregate ('trades' or 'orders'). |
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'. |
A dataframe with the raw (tick by tick/order by order) dataset
my.assets <- c('ABEVA20', 'PETRL78') ## getting data from local file (in practice it would be downloaded from ftp) out.file <- system.file("extdata", 'NEG_OPCOES_20151126.zip', package = "GetHFData") df.out <- ghfd_read_file(out.file, my.assets)#> - Imported 18301 lines, 770 unique tickers #> -> Processing file - Found 123 lines for 2 selected tickers #> -> Aggregation resulted in dataframe with 13 rowsprint(head(df.out))#> # A tibble: 6 x 13 #> # Groups: InstrumentSymbol, SessionDate [1] #> InstrumentSymbol SessionDate TradeDateTime n.trades last.price #> <chr> <date> <dttm> <int> <dbl> #> 1 PETRL78 2015-11-26 2015-11-26 10:00:00 7 0.570 #> 2 PETRL78 2015-11-26 2015-11-26 10:15:00 23 0.54 #> 3 PETRL78 2015-11-26 2015-11-26 11:00:00 4 0.52 #> 4 PETRL78 2015-11-26 2015-11-26 12:00:00 10 0.49 #> 5 PETRL78 2015-11-26 2015-11-26 12:15:00 3 0.5 #> 6 PETRL78 2015-11-26 2015-11-26 12:30:00 8 0.48 #> # ... with 8 more variables: weighted.price <dbl>, period.ret <dbl>, #> # period.ret.volat <dbl>, sum.qtd <dbl>, sum.vol <dbl>, n.buys <int>, #> # n.sells <int>, Tradetime <chr>