make_sell: Make Sell Trade Execution function

Description Usage Arguments Details Value Examples

View source: R/Trades.R

Description

Function executions a sell trade

Usage

1
2
make_sell(pobj, id, date = Sys.Date(), quantity, price, desc = "",
  trans_cost = 0.05)

Arguments

pobj

portfolio object

id

holding id to sell

date

date of transaction. Date type

quantity

number of shares. numeric type

price

price of shares. numeric type

desc

trade description. string type

trans_cost

transaction cost (dollars per share)

Details

add trade amount to cash balance, updates portfolio internal trade history and holdings

Value

updated portfolio object

Examples

1
2
3
4
5
library(tidyverse)
 p1 <- portfolio("new_port") %>%
       make_deposit(Sys.Date(), amount = 2000) %>%
       make_buy(Sys.Date()-1, symbol = "SPY", quantity = 10, price = 100) %>%
       make_sell(id = 1, quantity = 5, price = 105)

chrishaarstick/madstork documentation built on Jan. 3, 2022, 8:34 p.m.