Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
augustohassel committed Apr 30, 2020
1 parent cb36a05 commit f0187b9
Show file tree
Hide file tree
Showing 26 changed files with 137 additions and 25 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
107 changes: 106 additions & 1 deletion R/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#'
Expand Down Expand Up @@ -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)
# }
2 changes: 1 addition & 1 deletion R/rRofex.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/rRofex-package.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/rRofex_connection.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion docs/reference/trading_account.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_cancel_order.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_currencies.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_instruments.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_instruments_fronts.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_login.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_lookup.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_md.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_mdh.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_new_order.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/trading_orders.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/trading_account.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0187b9

Please sign in to comment.