Calculating loss in an orderbook [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-3
down vote

favorite












Here´s an edited version of the original question. I guess I was not so clear in the first place.



If I use bitcoins (BTC) to buy as much of another altcoin - let´s say its named LTB - how do I make sure that I only buy so much that the max loss I can experience is x percent, let´s say 8,1?



I need to have a look at the orderbook on the bid side, first of all. We assume that the price I buy at is 0,00001999.
This is the orderbook:



0,00001846 82,12
0,00001836 498,07
0,00001822 54,77


The first column is the bidprice, the 2nd one is the volume of LTB available for sale at that price.



The BTC value of all the coins at the first orderbook entry is 0,00001846 * 82,12 = 0,0015159352.
If I had bought 82,12 of LTB at 0,00001999 it would have costed me 0,0016415788.
So, at this point the loss would be (0,0016415788 - 0,0015159352) / (0,0016415788 * 0,01) = 7,653826913456728 pct.



This means that we can move on to the next entry, but at this point I have bought what was at previous entry,
hence it needs to be taken into account:



The BTC value of all the coins at the second orderbook entry is 0,00001836 * 498,07 = 0,0091445652. Add then the
value of our previous purchase: 0,0015159352 and the 82,12 + 498,07 = 580,19 LTB are worth 0,0106605004 if sold to buyers.
If we bought 580,19 LTB at a price of 0,00001999 this would have costed us 0,0115979981 BTC. The loss would now have been
(0,0115979981 - 0,0106605004) / (0,0115979981 * 0.01) = 8,083271715659274 pct.
That´s all good: We have not yet reached the threshold of 8,1 pct.



Now we get to the final entry and do the same:



54,77 * 0,00001822 = 0,0009979094 + the btc sum of 0,0106605004 from the earlier bid entries = 0,0116584098.
The cost to buy all LTB volume up till this point at the buyprice of 0,00001999 is (82,12 + 498,07 + 54,77 = 634,96) * 0,00001999 =
0,0126928504.
We check again how much we would lose at this point, having bought 634,96 LTB:



(0,0126928504 - 0,0116584098) / (0,0126928504 * 0.01) = 8,149789585481918 pct.
So here we went above the threshold for the loss we can accept of 8,1 pct.
Obviously, the amount of coins I can buy is somewhere between 580,19 and 634,96 but what´s the formula used to determine
exactly how many? For every order book entry that does not go above the threshold it´s easy, but how about the last part?



I hope I have made myself much more clear this time :)







share|cite|improve this question













closed as unclear what you're asking by Leucippus, Xander Henderson, amWhy, Siong Thye Goh, Piyush Divyanakar Aug 2 at 4:15


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
    – Arnaud Mortier
    Aug 2 at 0:45










  • Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
    – Corey Hart
    Aug 2 at 1:29










  • Consider attempting to formulate this in terms of linear programming.
    – RHowe
    Aug 2 at 3:01










  • @Arnaud Mortier Ok, I have given my question a big makeover!
    – Corey Hart
    Aug 2 at 11:37










  • @Geronimo I get what you´re saying, is it better now?
    – Corey Hart
    Aug 3 at 1:53














up vote
-3
down vote

favorite












Here´s an edited version of the original question. I guess I was not so clear in the first place.



If I use bitcoins (BTC) to buy as much of another altcoin - let´s say its named LTB - how do I make sure that I only buy so much that the max loss I can experience is x percent, let´s say 8,1?



I need to have a look at the orderbook on the bid side, first of all. We assume that the price I buy at is 0,00001999.
This is the orderbook:



0,00001846 82,12
0,00001836 498,07
0,00001822 54,77


The first column is the bidprice, the 2nd one is the volume of LTB available for sale at that price.



The BTC value of all the coins at the first orderbook entry is 0,00001846 * 82,12 = 0,0015159352.
If I had bought 82,12 of LTB at 0,00001999 it would have costed me 0,0016415788.
So, at this point the loss would be (0,0016415788 - 0,0015159352) / (0,0016415788 * 0,01) = 7,653826913456728 pct.



This means that we can move on to the next entry, but at this point I have bought what was at previous entry,
hence it needs to be taken into account:



The BTC value of all the coins at the second orderbook entry is 0,00001836 * 498,07 = 0,0091445652. Add then the
value of our previous purchase: 0,0015159352 and the 82,12 + 498,07 = 580,19 LTB are worth 0,0106605004 if sold to buyers.
If we bought 580,19 LTB at a price of 0,00001999 this would have costed us 0,0115979981 BTC. The loss would now have been
(0,0115979981 - 0,0106605004) / (0,0115979981 * 0.01) = 8,083271715659274 pct.
That´s all good: We have not yet reached the threshold of 8,1 pct.



Now we get to the final entry and do the same:



54,77 * 0,00001822 = 0,0009979094 + the btc sum of 0,0106605004 from the earlier bid entries = 0,0116584098.
The cost to buy all LTB volume up till this point at the buyprice of 0,00001999 is (82,12 + 498,07 + 54,77 = 634,96) * 0,00001999 =
0,0126928504.
We check again how much we would lose at this point, having bought 634,96 LTB:



(0,0126928504 - 0,0116584098) / (0,0126928504 * 0.01) = 8,149789585481918 pct.
So here we went above the threshold for the loss we can accept of 8,1 pct.
Obviously, the amount of coins I can buy is somewhere between 580,19 and 634,96 but what´s the formula used to determine
exactly how many? For every order book entry that does not go above the threshold it´s easy, but how about the last part?



I hope I have made myself much more clear this time :)







share|cite|improve this question













closed as unclear what you're asking by Leucippus, Xander Henderson, amWhy, Siong Thye Goh, Piyush Divyanakar Aug 2 at 4:15


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
    – Arnaud Mortier
    Aug 2 at 0:45










  • Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
    – Corey Hart
    Aug 2 at 1:29










  • Consider attempting to formulate this in terms of linear programming.
    – RHowe
    Aug 2 at 3:01










  • @Arnaud Mortier Ok, I have given my question a big makeover!
    – Corey Hart
    Aug 2 at 11:37










  • @Geronimo I get what you´re saying, is it better now?
    – Corey Hart
    Aug 3 at 1:53












up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











Here´s an edited version of the original question. I guess I was not so clear in the first place.



If I use bitcoins (BTC) to buy as much of another altcoin - let´s say its named LTB - how do I make sure that I only buy so much that the max loss I can experience is x percent, let´s say 8,1?



I need to have a look at the orderbook on the bid side, first of all. We assume that the price I buy at is 0,00001999.
This is the orderbook:



0,00001846 82,12
0,00001836 498,07
0,00001822 54,77


The first column is the bidprice, the 2nd one is the volume of LTB available for sale at that price.



The BTC value of all the coins at the first orderbook entry is 0,00001846 * 82,12 = 0,0015159352.
If I had bought 82,12 of LTB at 0,00001999 it would have costed me 0,0016415788.
So, at this point the loss would be (0,0016415788 - 0,0015159352) / (0,0016415788 * 0,01) = 7,653826913456728 pct.



This means that we can move on to the next entry, but at this point I have bought what was at previous entry,
hence it needs to be taken into account:



The BTC value of all the coins at the second orderbook entry is 0,00001836 * 498,07 = 0,0091445652. Add then the
value of our previous purchase: 0,0015159352 and the 82,12 + 498,07 = 580,19 LTB are worth 0,0106605004 if sold to buyers.
If we bought 580,19 LTB at a price of 0,00001999 this would have costed us 0,0115979981 BTC. The loss would now have been
(0,0115979981 - 0,0106605004) / (0,0115979981 * 0.01) = 8,083271715659274 pct.
That´s all good: We have not yet reached the threshold of 8,1 pct.



Now we get to the final entry and do the same:



54,77 * 0,00001822 = 0,0009979094 + the btc sum of 0,0106605004 from the earlier bid entries = 0,0116584098.
The cost to buy all LTB volume up till this point at the buyprice of 0,00001999 is (82,12 + 498,07 + 54,77 = 634,96) * 0,00001999 =
0,0126928504.
We check again how much we would lose at this point, having bought 634,96 LTB:



(0,0126928504 - 0,0116584098) / (0,0126928504 * 0.01) = 8,149789585481918 pct.
So here we went above the threshold for the loss we can accept of 8,1 pct.
Obviously, the amount of coins I can buy is somewhere between 580,19 and 634,96 but what´s the formula used to determine
exactly how many? For every order book entry that does not go above the threshold it´s easy, but how about the last part?



I hope I have made myself much more clear this time :)







share|cite|improve this question













Here´s an edited version of the original question. I guess I was not so clear in the first place.



If I use bitcoins (BTC) to buy as much of another altcoin - let´s say its named LTB - how do I make sure that I only buy so much that the max loss I can experience is x percent, let´s say 8,1?



I need to have a look at the orderbook on the bid side, first of all. We assume that the price I buy at is 0,00001999.
This is the orderbook:



0,00001846 82,12
0,00001836 498,07
0,00001822 54,77


The first column is the bidprice, the 2nd one is the volume of LTB available for sale at that price.



The BTC value of all the coins at the first orderbook entry is 0,00001846 * 82,12 = 0,0015159352.
If I had bought 82,12 of LTB at 0,00001999 it would have costed me 0,0016415788.
So, at this point the loss would be (0,0016415788 - 0,0015159352) / (0,0016415788 * 0,01) = 7,653826913456728 pct.



This means that we can move on to the next entry, but at this point I have bought what was at previous entry,
hence it needs to be taken into account:



The BTC value of all the coins at the second orderbook entry is 0,00001836 * 498,07 = 0,0091445652. Add then the
value of our previous purchase: 0,0015159352 and the 82,12 + 498,07 = 580,19 LTB are worth 0,0106605004 if sold to buyers.
If we bought 580,19 LTB at a price of 0,00001999 this would have costed us 0,0115979981 BTC. The loss would now have been
(0,0115979981 - 0,0106605004) / (0,0115979981 * 0.01) = 8,083271715659274 pct.
That´s all good: We have not yet reached the threshold of 8,1 pct.



Now we get to the final entry and do the same:



54,77 * 0,00001822 = 0,0009979094 + the btc sum of 0,0106605004 from the earlier bid entries = 0,0116584098.
The cost to buy all LTB volume up till this point at the buyprice of 0,00001999 is (82,12 + 498,07 + 54,77 = 634,96) * 0,00001999 =
0,0126928504.
We check again how much we would lose at this point, having bought 634,96 LTB:



(0,0126928504 - 0,0116584098) / (0,0126928504 * 0.01) = 8,149789585481918 pct.
So here we went above the threshold for the loss we can accept of 8,1 pct.
Obviously, the amount of coins I can buy is somewhere between 580,19 and 634,96 but what´s the formula used to determine
exactly how many? For every order book entry that does not go above the threshold it´s easy, but how about the last part?



I hope I have made myself much more clear this time :)









share|cite|improve this question












share|cite|improve this question




share|cite|improve this question








edited Aug 2 at 11:36
























asked Aug 2 at 0:12









Corey Hart

12




12




closed as unclear what you're asking by Leucippus, Xander Henderson, amWhy, Siong Thye Goh, Piyush Divyanakar Aug 2 at 4:15


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Leucippus, Xander Henderson, amWhy, Siong Thye Goh, Piyush Divyanakar Aug 2 at 4:15


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2




    Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
    – Arnaud Mortier
    Aug 2 at 0:45










  • Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
    – Corey Hart
    Aug 2 at 1:29










  • Consider attempting to formulate this in terms of linear programming.
    – RHowe
    Aug 2 at 3:01










  • @Arnaud Mortier Ok, I have given my question a big makeover!
    – Corey Hart
    Aug 2 at 11:37










  • @Geronimo I get what you´re saying, is it better now?
    – Corey Hart
    Aug 3 at 1:53












  • 2




    Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
    – Arnaud Mortier
    Aug 2 at 0:45










  • Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
    – Corey Hart
    Aug 2 at 1:29










  • Consider attempting to formulate this in terms of linear programming.
    – RHowe
    Aug 2 at 3:01










  • @Arnaud Mortier Ok, I have given my question a big makeover!
    – Corey Hart
    Aug 2 at 11:37










  • @Geronimo I get what you´re saying, is it better now?
    – Corey Hart
    Aug 3 at 1:53







2




2




Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
– Arnaud Mortier
Aug 2 at 0:45




Seriously, I would suggest extracting the math from your question to make it shorter and more readable. Even with good will, I don't get parts such as "Column 3 is the price of all coins at that price in bitcoins."
– Arnaud Mortier
Aug 2 at 0:45












Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
– Corey Hart
Aug 2 at 1:29




Ok, it seems that both comments derive from me not being clear enough about what´s going on here. Particular cryptocoin is NOT bitcoin, but another cryptocurrency. So when it says that column 1 shows the bitcoin price, then yes: That´s the price in bitcoins for one another cryptocurrency.. The one used in the example was LTB, but could´ve been any other one. So it´s: 1 price in BTC, 2. volume in LTB, 3. volume in BTC for column 2, 4. total of LTB volume so far, 5. total LTB volume so far, 6. total BTC volume at the buyprice, 7. difference in % between column 7 and 6 = loss.
– Corey Hart
Aug 2 at 1:29












Consider attempting to formulate this in terms of linear programming.
– RHowe
Aug 2 at 3:01




Consider attempting to formulate this in terms of linear programming.
– RHowe
Aug 2 at 3:01












@Arnaud Mortier Ok, I have given my question a big makeover!
– Corey Hart
Aug 2 at 11:37




@Arnaud Mortier Ok, I have given my question a big makeover!
– Corey Hart
Aug 2 at 11:37












@Geronimo I get what you´re saying, is it better now?
– Corey Hart
Aug 3 at 1:53




@Geronimo I get what you´re saying, is it better now?
– Corey Hart
Aug 3 at 1:53















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Comments

Popular posts from this blog

What is the equation of a 3D cone with generalised tilt?

Color the edges and diagonals of a regular polygon

Relationship between determinant of matrix and determinant of adjoint?