Buy/Sell

Calculate the selling price to obtain a given gain

@@B@@
@@P@@ % < 100% =
@@F@@ % < 100%
@@T@@ % < 100%
@@G@@ @@S@@ @@S'@@ @@S''@@ @@S'''@@
% =

Explanations

Assume that you bought something at a price @@B@@.
You want to sell it for a gain of @@G@@%.
But you want to sell only part of it and keep @@P@@%.
Moreover there is a selling fees of @@F@@%,
and you have to pay @@T@@% tax on your gains.
You have to sell for at least @@S'''@@.

Formulas

Selling price @@S@@ to obtain gains of @@G@@% if there is no preserved part, no selling fees and no gains tax:
@@\frac{G}{100} B = S - B \quad\iff\quad S = B \frac{100\,+\,G}{100}@@
Selling price @@S'@@ to obtain gains of @@G@@% if there is @@P@@% preserved part, but no selling fees and no gains tax:
@@\frac{G}{100} B = S' \frac{100\,-\,P}{100} - B \quad\iff\quad S' = S \frac{100}{100\,-\,P} = B \frac{100\,+\,G}{100\,-\,P}@@
Selling price @@S''@@ to obtain gains of @@G@@% if there is @@P@@% preserved part and @@F@@% selling fees, but no gains tax:
@@\frac{G}{100} B = S'' \frac{100\,-\,P}{100} \frac{100\,-\,F}{100} - B \quad\iff\quad S'' = S' \frac{100}{100\,-\,F} = B \frac{100\,+\,G}{100\,-\,P} \frac{100}{100\,-\,F}@@
Selling price @@S'''@@ to obtain gains of @@G@@% if there is @@P@@% preserved part, @@F@@% selling fees and @@T@@% gains tax:
@@\frac{G}{100} B = \left(S''' \frac{100\,-\,P}{100} \frac{100\,-\,F}{100} - B\right) \frac{100\,-\,T}{100} \quad\iff\quad S''' = B \frac{100}{100\,-\,P} \frac{100}{100\,-\,F} \frac{100\,+\,G\,-\,T}{100\,-\,T}@@

Links