Definitions

Overview

The Math Bible should be the single source of truth for equations in the Swing Trackr backend.

Conventions

Several conventions are followed for all the formulas contained in this document.

For any given formula, we will often use a construction of “From i=1 to n”, such as the following:

$$ \textbf{For all Buy Orders of Swing type, excluding all Day Trades, and Scalps} $$

$$ \textbf{Swing Size} = \displaystyle\sum_{i=1}^n \textrm{Order Size}_i $$

In this context, n will always be for a given number of Orders in a particular Position.


Glossary of common terms

Orders

A single transaction, either a Buy or a Sell, against a given stock.

Order Size

How many shares were either bought, or sold, in a given Order

Order Price

The price at which shares were either bought, or sold, for a given Order

Journal Entry

A recorded event in a Swing.

For Swing type Journal Entries you would have one Order, either a Buy or a Sell Order.

For Day Trade type Journal Entries you have two Orders, both a Buy and a Sell order.

For Scalp type Journal Entries you have two Orders, both a Buy and a Sell order.



Miscellaneous Formulas

Swing Size

$$ \textrm{For all Buy Orders of Swing type, excluding all Day Trades, and Scalps} $$

$$ \textbf{Swing Size} = \displaystyle\sum_{i=1}^n \textrm{Order Size}_i $$

Justification

The total number of shares bought in Swing type orders in a given Position.

Used in calculation of

  • Average Entry Price
  • Realized Profit

Also Known As

  • Total Shares Bought
  • Shares Bought Quantity
  • Swing Volume

References



Swing Shares Sold

$$ \textrm{For all Sell Orders of Swing type, excluding all Day Trades, and Scalps} $$

$$ \textbf{Swing Shares Sold} = \displaystyle\sum_{i=1}^n \textrm{Order Size}_i $$

Justification

The total number of shares sold in Swing type orders in a given Position.

Used in calculation of

  • Average Close Price
  • Realized Profit

References



Swing Shares Held

$$ \textbf{Swing Shares Held} = \textrm{Swing Size} - \textrm{Swing Shares Sold} $$

Justification

The current number of shares held in a given Position.

Used in calculation of

  • TODO

References

  • TODO


Current Value

$$ \textbf{Current Value} = \textrm{Current Price} * \textrm{Swing Shares Held} $$

Justification

The current value of the shares at the current market value for a given Position

A useful value for customers to see the current value of their current positions.

Used in calculation of

  • TODO

References

  • TODO


Revenue Formulas

Swing Revenue

$$ \textrm{For all Swing Sell Orders in a position} $$

$$ \textbf{Swing Revenue} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The sum of the Order Size multiplied by the Order Price, for all Swing Sell Orders

Essentially, this is the total value of the shares sold Swing type Orders in a given Position

Used in calculation of

  • TODO

References

  • TODO


Day Trade Revenue

$$ \textrm{For all Day Trade Sell Orders in a position} $$

$$ \textbf{Day Trade Revenue} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The sum of the Order Size multiplied by the Order Price, for all Day Trade Sell Orders

Essentially, this is the total value of the shares sold Day Trade type Orders in a given Position

Used in calculation of

  • TODO

References

  • TODO


Scalp Revenue

$$ \textrm{For all Scalp Sell Orders in a position} $$

$$ \textbf{Scalp Revenue} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The sum of the Order Size multiplied by the Order Price, for all Scalp Sell Orders

Essentially, this is the total value of the shares sold Scalp type Orders in a given Position

Used in calculation of

  • TODO

References

  • TODO


Realized Revenue

$$ \textbf{Realized Revenue} = \textrm{Swing Revenue} + \textrm{Day Trade Revenue} + \textrm{Scalp Revenue} $$

Justification

The sum of the different revenue type fields.

Essentially, this is the total value of all shares sold in a given Position

Used in calculation of

  • TODO

References

  • TODO


Projected Revenue

$$ \textbf{Projected Revenue} = \textrm{Current Value} + \textrm{Realized Revenue} $$

Justification

The projected revenue for a given Position if all held shares were sold at the current market value. This value includes the revenue for Day Trades and Scalps as well.

This value isn’t directly shown to customers, but used in the calculation of the Goal Progress of a given Swing. It could be presented to them though

Used in calculation of

  • Goal Progress

References

  • TODO


Position Cost Formulas

Swing Cost

$$ \textrm{For all Swing Buy Orders in a position} $$

$$ \textbf{Swing Cost} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The cost of shares bought in Swing type Orders in a given Position. Useful for determining what the initial value of a position was.

Used in calculation of

  • TODO

References

  • TODO


Day Trade Cost

$$ \textrm{For all Day Trade Buy Orders in a position} $$

$$ \textbf{Day Trade Cost} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The cost of shares bought in Day Trade type Orders in a given Position. Useful for determining what the initial value of a position was.

Used in calculation of

  • TODO

References

  • TODO


Scalp Cost

$$ \textrm{For all Scalp Buy Orders in a position} $$

$$ \textbf{Scalp Cost} = \displaystyle\sum_{i=1}^n (\textrm{Order Size}_i \times \textrm{Order Price}_i) $$

Justification

The cost of shares bought in Scalp type Orders in a given Position. Useful for determining what the initial value of a position was.

Used in calculation of

  • TODO

References

  • TODO


Total Cost

$$ \textbf{Total Cost} = \textrm{Swing Cost} + \textrm{Day Trade Cost} + \textrm{Scalp Cost} $$

Justification

The total cost of all shares bought across all Orders in a given position, including Swings, Day Trades, and Scalps.

  • TODO

References

  • TODO


Rolling Cost Basis

$$ \textbf{Total Cost} = \textrm{Average Entry Price} \times \textrm{Swing Shares Held} $$

Justification

The approximate cost basis of the remaining shares held in a given Position. With Cost Basis for holdings in stocks, the two most common methods are averages or FIFO (First In/First Out). Using FIFO can be useful in some cases, but requires concerted effort to track which shares sold and bought correspond to which buckets. One can also selectively choose which buys correspond to which sells, in order to optimize their tax burden across multiple years for example.

Given that the averages method is the one used by default the IRS/CRA/Revenu Quebec, we opt to use it here.

  • TODO

References

  • TODO


Average Price Formulas

Average Entry Price

$$ \textbf{Average Entry Price} = \frac{\textrm{Swing Cost}}{\textrm{Swing Size}} $$

Justification

A key value in Swing analysis. Allows you to easily get an idea of price point at which you entered a Position.

Used in calculation of

  • Cost Basis
  • Realized Profit
  • Unrealized Profit

References



Average Close Price

$$ \textrm{For all Sell Orders of Swing type, excluding all Day Trades, and Scalps} $$

$$ \textbf{Average Close Price} = \frac{\textrm{Swing Revenue}}{\textrm{Swing Shares Sold}} $$

Justification

A key value in Swing analysis. Allows you to easily get an idea of price point at which you sold your positions for a Swing.

Used in calculation of

  • Analytics


Profit Formulas


Swing Profit

$$ \textbf{Swing Profit} = \textrm{Swing Revenue} - (\textrm{Average Entry Price} \times \textrm{Swing Shares Sold}) $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Day Trade Profit

$$ \textbf{Day Trade Profit} = \textrm{Day Trade Revenue} - \textrm{Day Trade Cost} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Scalp Profit

$$ \textbf{Scalp Profit} = \textrm{Scalp Revenue} - \textrm{Scalp Cost} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Realized Profit

(I’m debating if we should just rename this to Profit, since the current profit field is actually projected values)

$$ \textbf{Realized Profit} = \textrm{Swing Profit} + \textrm{Day Trade Profit} + \textrm{Scalp Profit} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Unrealized Profit

$$ \textbf{Unrealized Profit} = \textrm{Current Value} + \textrm{Rolling Cost Basis} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Profit

(Equally debating renaming this to Projected Profit, since this includes the Unrealized Profit, which is a project value, might be overthinking this though)

$$ \textbf{Profit} = \textrm{Realized Profit} + \textrm{Unrealized Profit} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Breakeven and Goal Formulas


Breakeven Total

  This is not the existing breakeven total. This is a new field showing the
  total extra revenue needed in order to break even on our initial costs.
  We're basically just doing this calculation in the API without naming it
  as a variable. I think it'd be helpful to name it.

$$ \textbf{Breakeven Total} = \textrm{Total Cost} - \textrm{Realized Revenue} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Breakeven Share Price

  I thought we could rename this to Breakeven Share Price so it's more clear what this value is at a glance

$$ \textbf{Breakeven Share Price} = \left(\frac{\textrm{Breakeven Total}}{\textrm{Swing Shares Held}}\right)^+ $$

This can also be written as

$$ \textbf{Breakeven Share Price} = \textrm{Max}\left((\frac{\textrm{Breakeven Total}}{\textrm{Swing Shares Held}}), 0\right) $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Goal Profit

$$ \textbf{Goal Profit} = \textrm{Swing Cost} \times \textrm{Goal Percentage} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Goal Progress

$$ \textbf{Goal Progress} = \frac{\textrm{Profit}}{\textrm{Goal Profit}} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO


Price Target

(Please note that this refers to the NEW Breakeven Total, not the current value)

$$ \textbf{Price Target} = \frac{\textrm{Goal Profit} + \textrm{Breakeven Total}}{\textrm{Swing Shares Held}} $$

Justification

TODO

Used in calculation of

  • TODO

References

  • TODO