read_confirmations: Read transactions from the Tastywork's confirmations

Description Usage Arguments Details Value Examples

Description

This function reads Tastywork's confirmation files, which are in PDF format, extracts transactions from each file and merges them together into a single data frame.

Usage

1
read_confirmations(files, add.expired = FALSE, check.integrity = FALSE)

Arguments

files

a vector of path names to the files.

add.expired

logical that controls whether bogus transactions for expired options should be added.

check.integrity

logical that controls whether to check transactions integrity.

Details

Tastyworks generates a confirmation only if there was any trading activity druring the day. That makes it difficult to detect any missing confirmations. And there are known cases when confirmations were missing.

Specifying check.integrity = TRUE helps to identify if there are potentially any missing transactions. It checks whether the quantity of traded stocks/options in the closing transaction is greater than the quantity in the corresponding opening transaction. This is the symptom of the missing confirmations.

Value

The output is a data frame, where each record represents one transaction. The data frame has the following variables:

trade_date : Date, format "YYYY-MM-DD"

Date, when the transaction was executed

reason : Factor w/ 5 levels "UNSOLICITED", "ASSIGNED", "EXERCISED", "EXPIRED", "SPLIT"

Reason for the transaction:

  • UNSOLICITED - the transaction was initiated by a customer

  • ASSIGNED - stock assignment due to exercised short option

  • EXERCISED - stock assignment due to long option expiring in the money

  • EXPIRED - option expired out of the money

  • SPLIT - stock split

action : Factor w/ 3 levels "BUY", "SELL", "REMOVE"

Action that created the transaction:

  • BUY - purchase of stock or option

  • SELL - sell of stock or option

  • REMOVE - option was removed because it has expired

position : Factor w/ 2 levels "OPEN", "CLOSE"

Position indicates whether it is an OPEN or a CLOSE transaction

symbol : chr

Ticker symbol of the instrument

instrument : Factor w/ 2 levels "STOCK", "OPTION"

Instrument type - either STOCK or OPTION

quantity : int

A positive integer indicating the quantity of the traded stock/option

option_type : Factor w/ 2 levels "CALL", "PUT"

Option type - either CALL or PUT or NA for the stock

strike : num

Optin strike or NA for the stock

expiration_date : Date, format "YYYY-MM-DD"

Expiration date of the option or NA for the stock

price : num

Price in USD of one unit of the trading instrument

principal : num

Principal is the quntity multiplied by the price, i.e. transaction amount in USD excluding commission and fees

commission : num

Commission in USD paid to Tastyworks

transaction_fee : num

Transaction fees in USD

additional_fee : num

Additional fees in USD

net_amount : num

Transaction amount in USD including commission and fees

cusip : chr

CUSIP numbers that identify the transaction's financial security

tag_number : chr

Tag number uniquely identifies the transaction

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 
## Read a single confimation file:
transactions <- read_confirmations("2017-08-30-1NE23456-confirmation.pdf")

## End(Not run)

## Not run: 
## Read several confirmation files:
files <- c("2017-08-30-1NE23456-confirmation.pdf",
           "2017-08-30-1NE23456-confirmation.pdf")
transactions <- read_confirmations(files)

## End(Not run)

## Not run: 
## Read all confimation files in a "confirmations":
# A template for confirmation file name (YYYY-MM-DD-xxxxxxxx-confirmation.pdf)
confirmation_pattern <-
 START %R% YMD %R% "-" %R%
 repeated(ALNUM, 8) %R% "-confirmation" %R%
 DOT %R% "pdf" %R% END

# Get a list of confirmation files
files <- list.files(path = path.expand("confirmations"),
                    pattern = confirmation_pattern,
                    full.names = TRUE)

# Read the files
transactions <- read_confirmations(files)

## End(Not run)

tourko/tastyworks documentation built on May 17, 2019, 4:33 p.m.