Account Positions
List Account Positions
A position with a quantity of 0 is considered closed. We purge these positions overnight.
Equity option positions will also include an expires-at timestamp.
For profit/loss calculations, you should rely on the live quote data as much as possible to ensure up-to-date calculations (see Streaming Market Data).
{
"data": {
"items": [
{
"account-number": "5WT00000",
"symbol": "AAPL",
"instrument-type": "Equity",
"underlying-symbol": "AAPL",
"quantity": "100",
"quantity-direction": "Long",
"close-price": "282.48",
"average-open-price": "288.7",
"average-yearly-market-close-price": "123.18",
"average-daily-market-close-price": "282.48",
"multiplier": 1,
"cost-effect": "Credit",
"is-suppressed": false,
"is-frozen": false,
"restricted-quantity": "0.0",
"realized-day-gain": "0.0",
"realized-day-gain-effect": "None",
"realized-day-gain-date": "2022-11-01",
"realized-today": "0.0",
"realized-today-effect": "None",
"realized-today-date": "2022-11-01",
"created-at": "2022-08-22T17:56:51.872+00:00",
"updated-at": "2022-11-01T21:49:54.095+00:00"
}
]
},
"context": "/accounts/5WT00000/positions"
}
Profit/Loss Calculations
The following are some high-level calculations you can do to see the profit/loss of your positions. These are not intended to be a copy-paste answer to all your P/L questions. The numbers you see may be slightly different from what you see when using the tastytrade application. This may be due to many factors, including which language you are using, the speed of your internet connection, the interval at which you receive quote data, etc. Please understand that the formulas we provide below are very basic, but will fit most people's needs.
You'll also find the terms realized and unrealized in the sections below. Realized profit/loss occurs when you close a position. Unrealized profit/loss occurs on any open positions. For example, suppose you are long 100 shares of ABCD stock that you bought for $10 each, and the current price of ABCD is $11. This means you have $100 of unrealized gain on the position ($1 per share). You haven't sold the shares yet, so you haven't realized the profit. Once you sell the shares, your realized gain on the position will be $100 and your unrealized gain will be $0. In other words, the unrealized gain becomes realized gain once you close some or all of the position.
In the previous example, if you were to sell only 25 of your shares at $11, your realized gain would be $25 and your unrealized gain would be $75.
Basic Formula
The basic math behind a profit/loss calculation is as follows:
(mark - cost basis) * quantity * multiplier
(mark - cost basis) * quantity * multiplier
The cost basis of the formula will differ depending on what type of gain you are calculating. Continue reading below for a description of each of these terms and a few helpful profit/loss formulas.
Mark
This is the current market value of a single unit of your position. You can think of this as the market value per unit. For long positions, you can use the quote.bid
. For short positions, you can use the quote.ask
. If you don't want to worry about long or short, you can use the mid price, which is calculated by (quote.bid + quote.ask) / 2
. The quote.last
price works too if you can't get a bid or ask.
You can get bidPrice & askPrice from the DXLink Quote
market event (see Streaming Market Data).
Cost Basis
The cost basis will differ depending on what you are calculating. There are several cost basis values that tasty provides:
position.average-open-price - Cost basis for one unit of your position since it was opened. This is used in the Unrealized Gain calculation.
For example, if you buy 100 shares of ABCD for $10 each, your average-open-price
would be $10. If you then bought 100 more shares for $11 each, your average-open-price
would increase to $10.50.
position.average-daily-market-close-price - Cost basis for one unit of your position since yesterday. This is used in the Unrealized Day Gain calculation.
position.average-yearly-market-close-price - Cost basis for one unit of your position since the end of last year. This is used in the Unrealized Year Gain calculation.
Unrealized Gain
The unrealized profit/loss on the position since it was opened.
(mark - position.average-open-price) * position.quantity * position.multiplier
(position.average-open-price - mark) * position.quantity * position.multiplier
Unrealized Day Gain
The unrealized profit/loss on the position today.
(mark - position.average-daily-market-close-price) * position.quantity * position.multiplier
(position.average-daily-market-close-price - mark) * position.quantity * position.multiplier
Realized Gain
The profit/loss made from closing some or all of the position since it was opened.
position.realized-today
realized-today-date is the date any profit/loss was realized. If it is not today's date, you can ignore the realized-today
value.
Realized Day Gain
The profit/loss from closing some or all of a position today.
position.realized-day-gain
realized-day-gain-date is the date any profit/loss was realized. If it is not today's date, you can ignore the realized-day-gain
value.
P/L Open
The total (realized + unrealized) profit/loss on the position since it was opened.
unrealized gain since position open + realized gain since position open
P/L Day
The total (realized + unrealized) profit/loss on the position today.
unrealized day gain + realized day gain
Position Current Value
The net liquidating value of the position, or the value you'd receive/pay if you closed it.
mark * position.quantity * multiplier