knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

transactions.R extracts transactions information from the confirmations generated by Tastyworks.

To extract the transactions:

  1. Save all confirmations in one folder
  2. In the transactions.R set the path to the folder
  3. Run transactions.R

The result is a transactions dataframe, which is also saved to a file "transactions.rds".

All scripts here assume that there is "transactions.rds" file and they load transactions from it as the first step.

Check for missing transactions

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.

check_missing.R helps to identify if there are potentially any missing confirmations.

Run check_missing.R and it will report closing transactions where:

  1. there is no matching opening transaction
  2. the quantity of traded stocks/options in the closing transaction is greater than the quantity in the corresponding opening transaction.

Both are the symptoms of missing confirmations.

Parsing a confirmation file

Each transaction has 4 lines.

Currently the following transactions can be parsed:

A. Options 1. Buy-To-Open option 2. Sell-To-Open option 3. Buy-To-Close option 4. Sell-To-Close option 5. Exercised option

B. Stocks 1. Buy-To-Open stocks 2. Sell-To-Close stocks 3. Assigned stock

A. Options

A.1. Buy-To-Open option

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     B   09/05/17  09/06/17   1     0.8100000  81.00     1.00  0.04  0.10  G9902  82.14  TUA0906   1   1
[2] Desc: PUT QQQ 10/20/17 134 POWERSHARES QQQ TRUST      Interest/STTax: 0.00         CUSIP: 8H32938
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  UNSOLICITED, OPEN CONTRACT
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

A.2. Sell-To-Open option

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     B   09/05/17  09/06/17   1     1.1700000  117.00    1.00  0.06  0.10  G9799  86.84  TUA0906   1   1
[2] Desc: PUT QQQ 10/20/17 137 POWERSHARES QQQ TRUST      Interest/STTax: 0.00        CUSIP:  9H32944
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  UNSOLICITED, OPEN CONTRACT
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

A.3 Buy-To-Close option

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     B   09/18/17  09/19/17   1     0.5200000  52.00     0.00  0.04  0.10  Y8782  52.14  TUA0919   5   1
[2] Desc: PUT HD 10/20/17 150 HOME DEPOT INC              Interest/STTax: 0.00        CUSIP:  9KXZWN0
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  UNSOLICITED, CLOSING CONTRACT
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

A.4. Sell-To-Close option

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     S   09/18/17  09/19/17   1     0.1800000  18.00     0.00  0.06  0.10  Y8786  17.84  TUA0919   5   1
[2] Desc: PUT HD 10/20/17 145 HOME DEPOT INC              Interest/STTax: 0.00         CUSIP: 8KXZWM8
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  UNSOLICITED, CLOSING CONTRACT
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

A.5. Exercised option

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     S   11/15/17  11/16/17   1     1.7900000  179.00    5.00  0.00  0.00  15056  174.00 TUA1116   8   1
[2] Desc: CALL VIX 11/15/17 12 CBOE VOLATILITY INDEX      Interest/STTax: 0.00         CUSIP: 8BKQXT2
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  A/E 8BKQXT2 1 EXERCISED, CLOSING CONTRACT
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

B. Stocks

B.1. Buy-To-Open stock

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net    Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount Number  Mkt Cap
—————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     B   12/15/17  12/19/17 100 UNG 5.3100000  531.00    5.00  0.00  0.08  I2680  536.08 TUA1219   6   1
[2] Desc: UNITED STATES NATURAL GAS FUND LP UNIT USD0.001 Interest/STTax: 0.00         CUSIP: 912318201
[3] Currency: USD       ReportedPX:      MarkUp/Down:                                          
[4] Trailer:  UNSOLICITED, PRODUCT DESCRIPTION UNDER SEPARATE COVER
—————————————————————————————————————————————————————————————————————————————————————————————————————————————

B.2. Sell-To-Close stock

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net      Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount   Number  Mkt Cap
———————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     S   12/08/17  12/12/17 100 UAL 64.3801000 6,438.01  0.00  0.16  0.08  T2198  6,437.77 TUA1212   6   1
[2] Desc: UNITED CONTINENTAL HLDGS INC                    Interest/STTax: 0.00           CUSIP: 910047109
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  UNSOLICITED
———————————————————————————————————————————————————————————————————————————————————————————————————————————————

B.3. Assigned stock

    Acct  B/S Trade     Settle                                      Tran  Add’l Tag    Net      Trade
    Type      Date      Date     QTY SYM Price      Principal Comm  Fee   Fees  Number Amount   Number  Mkt Cap
———————————————————————————————————————————————————————————————————————————————————————————————————————————————
[1] 2     B   11/21/17  11/24/17 100 GE  24.0000000 2,400.00  5.00  0.00  0.00  A8103  2,405.00 TUA1124   3   1
[2] Desc: GENERAL ELECTRIC COMPANY COM                    Interest/STTax: 0.00           CUSIP: 369604103
[3] Currency: USD       ReportedPX:      MarkUp/Down:
[4] Trailer:  A/E 9GMSJJ4 1 ASSIGNED
———————————————————————————————————————————————————————————————————————————————————————————————————————————————


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