#' Calculate IB's stock order commission.
#'
#' @param qty Order quantity.
#' @param price Entry price.
#'
#' @return IB's commission.
#' @export
calcIBCommission <- function(qty, price) {
# Shares * 0.005 (min $1, max 1% of trade value)
comm_lot <- -0.005
comm_min <- -1
comm_max <- qty * price * -0.01
comm <- qty * comm_lot
comm <- ifelse(comm > comm_min, comm_min,
ifelse(comm < comm_max, comm_max, comm))
comm <- round(comm, 2)
return(comm)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.