From f0187b9068a016b1861d4335fd1da1b3a7f37ced Mon Sep 17 00:00:00 2001 From: Augusto Hassel Date: Wed, 29 Apr 2020 22:04:31 -0300 Subject: [PATCH] Fix documentation --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/functions.R | 107 +++++++++++++++++- R/rRofex.R | 2 +- docs/404.html | 2 +- docs/CODE_OF_CONDUCT.html | 2 +- docs/LICENSE-text.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 2 +- docs/pkgdown.yml | 2 +- docs/reference/index.html | 2 +- docs/reference/rRofex-package.html | 2 +- docs/reference/rRofex_connection.html | 2 +- docs/reference/trading_account.html | 6 +- docs/reference/trading_cancel_order.html | 2 +- docs/reference/trading_currencies.html | 2 +- docs/reference/trading_instruments.html | 2 +- .../reference/trading_instruments_fronts.html | 2 +- docs/reference/trading_login.html | 2 +- docs/reference/trading_lookup.html | 2 +- docs/reference/trading_md.html | 2 +- docs/reference/trading_mdh.html | 2 +- docs/reference/trading_new_order.html | 2 +- docs/reference/trading_orders.html | 2 +- man/trading_account.Rd | 4 +- 26 files changed, 137 insertions(+), 25 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ccd06d6..d6309cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rRofex Type: Package Title: Interface to ROFEX APIs -Version: 1.5.0 +Version: 1.5.1 Authors@R: c(person("Augusto", "Hassel", role = c("aut", "cre"), email = "ahassel@primary.com.ar")) Description: Provides a convenient wrapper for consuming data from ROFEX APIs: Trading API, Risk API and BackOffice API. License: MIT diff --git a/NAMESPACE b/NAMESPACE index ae1cbc0..e9faee7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,6 +23,7 @@ importFrom(purrr,map) importFrom(purrr,map_df) importFrom(purrr,modify_depth) importFrom(purrr,pluck) +importFrom(purrr,simplify_all) importFrom(purrr,some) importFrom(rlang,is_null) importFrom(tibble,as_tibble) diff --git a/R/functions.R b/R/functions.R index bc723bb..b7b4ab7 100644 --- a/R/functions.R +++ b/R/functions.R @@ -784,7 +784,7 @@ trading_orders <- function(connection, account) { #' #' @param connection S4. \strong{Mandaroty} Formal rRofexConnection class object #' @param account String. \strong{Mandaroty} Account Number -#' @param account Logical. Expanded information. +#' @param detailed Logical. Expanded information. #' #' @return If correct, it will load a tibble. #' @@ -863,3 +863,108 @@ trading_account <- function(connection, account, detailed = FALSE) { return(data) } + +#' @title Account Report +#' +#' @description Access report about your trading account. +#' +#' @param connection S4. \strong{Mandaroty} Formal rRofexConnection class object +#' @param account String. \strong{Mandaroty} Account Number +#' +#' @return If correct, it will load a tibble. +#' +#' @family account functions +# trading_account_report <- function(connection, account) { +# +# if (missing(connection)) stop("Connection cannot be empty.") +# if (!isS4(connection) || rev(class(connection)) != "rRofexConnection" || !validObject(connection)) stop("The 'connection' must be a valid 'rRofexConnection'.") +# if (as.Date(connection@login_date_time) != Sys.Date()) stop("The 'acyRsaConnection' is no longer valid. Please log-in again.") +# +# if (missing(account)) stop("'account' parameter cannot be empty.") +# +# # Query +# query <- GET(url = glue(connection@base_url, "/rest/risk/accountReport/{account}"), +# add_headers(.headers = c("X-Auth-Token" = connection@token))) +# +# if (status_code(query) != 200) { +# +# warn_for_status(query) +# message("\r") +# data <- NULL +# +# } else { +# +# data <- fromJSON(toJSON(content(query), auto_unbox = T, null = "null")) +# +# data <- if (length(data$accountData)) { +# +# data$accountData %>% +# t() %>% +# as_tibble() %>% +# mutate_if(., .predicate = ~ class(.) == 'list', .funs = ~ replace_na(data = ., replace = NA)) %>% +# mutate_if(., .predicate = ~ length(unlist(.)) == 1, .funs = ~ unlist(x = ., recursive = F)) %>% +# mutate_at(.tbl = ., .vars = vars(matches("detailedAccountReports")), .funs = ~ list( +# unlist(x = ., recursive = F) %>% +# as_tibble() %>% +# pivot_longer(cols = everything(), names_to = "Term", values_to = "values") %>% +# mutate( +# Term = as.integer(Term), +# Names = unlist(attributes(values)) +# ) %>% +# pivot_wider(data = ., values_from = values, names_from = Names) %>% +# mutate( +# settlementDate = as.POSIXct(unlist(settlementDate)/1000, origin = "1970-01-01", tz = "America/Buenos_Aires") +# ) +# )) %>% +# select(detailedAccountReports) %>% +# pluck(1) +# +# test +# +# +# pija <- test[[1]] %>% +# mutate( +# currencyBalance = map(currencyBalance, .f = ~ unlist(., recursive = F) %>% as_tibble()) +# ) +# +# +# pija$currencyBalance[[1]] %>% +# +# +# +# +# +# +# mutate( +# currencyBalance = map(currencyBalance, .f = ~ purrr::flatten(.) %>% as_tibble()) +# ) #%>% +# mutate( +# currencyBalance = modify_depth(currencyBalance, .depth = 1, .f = ~ unnest(.)) +# ) +# +# +# +# +# +# list(unlist(. %>% pluck(1), recursive = F) %>% purrr::map_df(., .f = ~ pluck(.) %>% as_tibble()) +# +# mutate_if(., .predicate = ~ class(.[[1]]) == 'list', .funs = ~ modify_depth(.x = ., .depth = 1, ~ replace_na(data = ., replace = NA_real_))) +# +# +# t() %>% +# as_tibble() %>% +# mutate_if(., .predicate = ~ length(unlist(.)) == 1, .funs = ~ unlist(x = ., recursive = F)) %>% +# mutate_if(., .predicate = ~ any(map(.[[1]], .f = ~ length(.)) > 1), .funs = ~ list(unlist(.[[1]], recursive = F))) %>% +# mutate(report = list(unlist(report, recursive = F) %>% purrr::map_df(., .f = ~ pluck(., "detailedPositions")) %>% as_tibble())) %>% +# mutate(lastCalculation = as.POSIXct(lastCalculation/1000, origin = "1970-01-01", tz = "America/Buenos_Aires")) %>% +# mutate_at(.tbl = ., .vars = vars(matches("report")), .funs = ~ modify_depth(.x = ., .depth = 1, ~ mutate_at(.tbl = ., .vars = vars(matches("date")), .funs = ~ as.POSIXct(./1000, origin = "1970-01-01", tz = "America/Buenos_Aires")))) +# } else { +# message("No data available at the moment...") +# NULL +# } +# +# +# } +# +# return(data) +# } diff --git a/R/rRofex.R b/R/rRofex.R index 96363d7..fb45c0f 100644 --- a/R/rRofex.R +++ b/R/rRofex.R @@ -5,6 +5,6 @@ #' @importFrom tidyr separate replace_na pivot_wider #' @importFrom magrittr %>% #' @importFrom glue glue glue_collapse -#' @importFrom purrr some modify_depth map_df pluck map +#' @importFrom purrr some modify_depth map_df pluck map simplify_all #' @importFrom rlang is_null "_PACKAGE" diff --git a/docs/404.html b/docs/404.html index 1948191..f54f45a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/CODE_OF_CONDUCT.html b/docs/CODE_OF_CONDUCT.html index 6fe4073..d025abc 100644 --- a/docs/CODE_OF_CONDUCT.html +++ b/docs/CODE_OF_CONDUCT.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 7b6d282..5327fad 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/authors.html b/docs/authors.html index eb33b6c..21c2c00 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/index.html b/docs/index.html index ccd8872..ad61afb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -31,7 +31,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/news/index.html b/docs/news/index.html index 7f71703..5f9c013 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 4082ee6..ab53744 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,5 +2,5 @@ pandoc: 2.7.2 pkgdown: 1.5.1 pkgdown_sha: ~ articles: [] -last_built: 2020-04-30T00:57Z +last_built: 2020-04-30T01:03Z diff --git a/docs/reference/index.html b/docs/reference/index.html index 7c43fc9..756c579 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/rRofex-package.html b/docs/reference/rRofex-package.html index 53eae36..57e6a4b 100644 --- a/docs/reference/rRofex-package.html +++ b/docs/reference/rRofex-package.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/rRofex_connection.html b/docs/reference/rRofex_connection.html index 186bdc9..53d179f 100644 --- a/docs/reference/rRofex_connection.html +++ b/docs/reference/rRofex_connection.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_account.html b/docs/reference/trading_account.html index 541aa51..d750f86 100644 --- a/docs/reference/trading_account.html +++ b/docs/reference/trading_account.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 @@ -131,6 +131,10 @@

Arg account +

String. Mandaroty Account Number

+ + + detailed

Logical. Expanded information.

diff --git a/docs/reference/trading_cancel_order.html b/docs/reference/trading_cancel_order.html index a653b96..9ca026d 100644 --- a/docs/reference/trading_cancel_order.html +++ b/docs/reference/trading_cancel_order.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_currencies.html b/docs/reference/trading_currencies.html index f1b73b9..5a49f2b 100644 --- a/docs/reference/trading_currencies.html +++ b/docs/reference/trading_currencies.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_instruments.html b/docs/reference/trading_instruments.html index 9fb3dfe..48f2699 100644 --- a/docs/reference/trading_instruments.html +++ b/docs/reference/trading_instruments.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_instruments_fronts.html b/docs/reference/trading_instruments_fronts.html index 396f0a4..ac35546 100644 --- a/docs/reference/trading_instruments_fronts.html +++ b/docs/reference/trading_instruments_fronts.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_login.html b/docs/reference/trading_login.html index bb6feec..48a3841 100644 --- a/docs/reference/trading_login.html +++ b/docs/reference/trading_login.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_lookup.html b/docs/reference/trading_lookup.html index f1ad92d..eafecdf 100644 --- a/docs/reference/trading_lookup.html +++ b/docs/reference/trading_lookup.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_md.html b/docs/reference/trading_md.html index fba39cf..fae477b 100644 --- a/docs/reference/trading_md.html +++ b/docs/reference/trading_md.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_mdh.html b/docs/reference/trading_mdh.html index e2bf8fc..befdf8b 100644 --- a/docs/reference/trading_mdh.html +++ b/docs/reference/trading_mdh.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_new_order.html b/docs/reference/trading_new_order.html index 6a57cc4..5fa6cc2 100644 --- a/docs/reference/trading_new_order.html +++ b/docs/reference/trading_new_order.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/docs/reference/trading_orders.html b/docs/reference/trading_orders.html index 479c5a3..5d67dc2 100644 --- a/docs/reference/trading_orders.html +++ b/docs/reference/trading_orders.html @@ -72,7 +72,7 @@ rRofex - 1.5.0 + 1.5.1 diff --git a/man/trading_account.Rd b/man/trading_account.Rd index 0d1d827..13f44ae 100644 --- a/man/trading_account.Rd +++ b/man/trading_account.Rd @@ -9,7 +9,9 @@ trading_account(connection, account, detailed = FALSE) \arguments{ \item{connection}{S4. \strong{Mandaroty} Formal rRofexConnection class object} -\item{account}{Logical. Expanded information.} +\item{account}{String. \strong{Mandaroty} Account Number} + +\item{detailed}{Logical. Expanded information.} } \value{ If correct, it will load a tibble.