positions | R Documentation |
The positions API provides information about an account's current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Character values are returned as a string while integer values are returned as numeric. See Positions for details.
positions(symbols = NULL, action = "get", live = get_live())
symbols |
|
action |
|
live |
|
position
is vectorized and thus multiple arguments may be provided to symbols
and the function will perform the action
specified for each. action
is not vectorized, and only one action may be performed for a set of symbols at a given time.
Position (tibble)
Position object or array of Position objects of length 0 if no positions, otherwise with length of the number of positions, each with the following attributes:
asset_id
(character)
Asset ID.
symbol
(character)
Symbol of the asset.
exchange
(character)
Exchange name of the asset.
asset_class
(character)
Asset class name.
qty
(integer)
The number of shares.
avg_entry_price
(numeric)
Average entry price of the position.
side
(character)
long/short exposure.
market_value
(numeric)
Total dollar amount of the position.
cost_basis
(numeric)
Total cost basis in dollar.
unrealized_pl
(numeric)
Unrealized profit/loss in dollar.
unrealized_plpc
(numeric)
Unrealized profit/loss percent (by a factor of 1).
unrealized_intraday_pl
(numeric)
Unrealized profit/loss in dollar for the day.
unrealized_intraday_plpc
(numeric)
Unrealized profit/loss percent (by a factor of 1).
current_price
(numeric)
Current asset price per share.
lastday_price
(numeric)
Last day's asset price per share.
change_today
(numeric)
Percent change from last day price (by a factor of 1).
## Not run:
positions() # all paper positions
positions(live = TRUE) # all live positions
#cancel all paper positions
positions(a = "close_all")
# details for a specific position (errors if not present)
positions("GOOG")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.