Author Topic: Newbie Shorting Questions  (Read 5268 times)

0 Members and 1 Guest are viewing this topic.

Offline arhag

  • Hero Member
  • *****
  • Posts: 1214
    • View Profile
    • My posts on Steem
  • BitShares: arhag
  • GitHub: arhag
I think a plot would really help. So check it out. I made the assumption that the short was created with the minimum 200% collateral. The x-axis is the percentage change in the price of BTSX (with respect to the BitAsset being shorted) since the short was created. The y-axis represents the percentage gain/loss of the user's BTSX stake if the short was covered. The first curve (blue curve) corresponds to the case where ALL of the user's BTSX stake was put into the collateral of the short (meaning the short cannot be covered at all without bringing in additional funds). The third curve (yellow curve) corresponds to the case where enough BTSX is left over to cover the short at any time before margin call. The middle curve corresponds to the case where half of the user's BTSX stake is used for the collateral of the short  (meaning the short cannot be covered in the negative x-axis portion of the curve without bringing in additional funds).

Hope these plots help the less math-inclined.
« Last Edit: September 21, 2014, 08:41:18 pm by arhag »

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
n is a positive integer.
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline arhag

  • Hero Member
  • *****
  • Posts: 1214
    • View Profile
    • My posts on Steem
  • BitShares: arhag
  • GitHub: arhag
it is done on purpose, btw, and serves as a kind of 'soft' collateral.

Sure, I am not saying it is a bad idea.


PS the problem is you can reduce s to:
s = (1 + m/(p1*x))/1.5    * (1+f*(n-1))/(n^2-1)+f  where f is the transaction fee currently 0.1 BTSX

Wait, what problem are you talking about? And what is the variable n?

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
. This is the problem with using s = 1. If the price goes down, you have no ability to cover unless you put more money into the system (convert fiat into BTSX for example).


it is done on purpose, btw, and serves as a kind of 'soft' collateral.


PS the problem is you can reduce s to:
s = (1 + m/(p1*x))/1.5    * (1+f*(n-1))/(n^2-1)+f  where f is the transaction fee currently 0.1 BTSX

s = (1 + m/(p1*x))/1.5    * (1/(n^2-1)+f*n 
« Last Edit: September 21, 2014, 07:25:11 pm by tonyk »
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline arhag

  • Hero Member
  • *****
  • Posts: 1214
    • View Profile
    • My posts on Steem
  • BitShares: arhag
  • GitHub: arhag
(p1  -  p2)     *       x         +        c           = BTSX in possession after covering
(30 – 0.1)      *     100       +     6,000       = 8,990 BTSX in possession, gain of 2,990 BTSX (49.8% gain, close to max theoretical gain of 50%)
(30 – 40 )      *     100       +     6,000       = 5,000 BTSX in possession, loss of 1,000 BTSX (16.66% loss)

First, a minor nitpick. The BTSX in your possession would not be (p1 - p2) * x + c after covering. It would be (p1 - p2) * x + (whatever you had in your wallet before you did the short & cover). The fact that c happens to be equal to what you had in your wallet is a result of being able to short with 200% reserve in collateral (m/(p1*x) = 1) and using half of your BTSX stake to put up the margin for the short (s = 1).

Second, your calculation in case of a loss has some problems. Let us say you covered right before the margin call (meaning right before the price went to 40 BTSX/BitUSD). That would require you to buy 100 BitUSD at a cost of 4,000 BTSX. But the problem is that you had 6,000 BTSX in your wallet and used 3,000 BTSX for the margin for the short. Meaning you only have 3,000 BTSX to buy the BitUSD to cover. Because BitShares X has no mechanism to bid on BitUSD using the collateral of the short, you are forced to have enough BTSX to buy the BitUSD to cover. This is the problem with using s = 1. If the price goes down, you have no ability to cover unless you put more money into the system (convert fiat into BTSX for example). This is why I say that if you want to be safe you should pick at least an s = (1 + m/(p1*x))/1.5, because then you know you have enough BTSX in your wallet to buy BitUSD to cover before the margin call. You can pick a smaller s that is still greater than 1 of course, but that just puts a limit to how low the price of BTSX can drop after your short before you are forced to cover.

Now if you decide to let the margin call just happen, then you are correct that the collateral would pay the difference and you don't need any BTSX kept around. But your calculation neglects the 5% fee that will be charged by the network on the remaining BTSX. So, your last line should actually read:
Quote
(3,000 + (30 – 40)  *  100)  *  0.95       +     3,000   = 4,900 BTSX in possession, loss of 1,100 BTSX (18.33% loss)
« Last Edit: September 21, 2014, 07:08:19 pm by arhag »

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
btw do not forget the Big assumption that the price is not moving... if it does you can loose the whole collateral

Hmm...I guess I'm not positive what this means. If BitUSD price goes up, you get margin called, if it goes down, you cover with a gain. How would you lose the whole collateral?

That's why it is not good to short with 100% of the money in your account... do you want to learn it by experiencing it with all of your money?
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline nomoreheroes7

  • Hero Member
  • *****
  • Posts: 756
  • King of all the land
    • View Profile
  • BitShares: nomoreheroes7
btw do not forget the Big assumption that the price is not moving... if it does you can loose the whole collateral

Hmm...I guess I'm not positive what this means. If BitUSD price goes up, you get margin called, if it goes down, you cover with a gain. How would you lose the whole collateral?

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
worst case for the sell bitUSD order .can be anything in the 1 to 1.1 in practice.


btw do not forget the Big assumption that the price is not moving... if it does you can loose the whole collateral
« Last Edit: September 21, 2014, 06:19:07 pm by tonyk »
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline nomoreheroes7

  • Hero Member
  • *****
  • Posts: 756
  • King of all the land
    • View Profile
  • BitShares: nomoreheroes7
Okay, final scenario using simple numbers as an example. Say I want to determine my maximum risk of loss in case a margin call is triggered. From my calculations below, it appears that the maximum loss is only 16.66% before you get margin called, but I feel like there must be something wrong with my numbers. Can anyone point me in the right direction? Also, what would be so risky about shorting say 49% of your wallet balance (thus having the remaining 49% tied up as collateral)? If you get margin called, wouldn't the collateral go towards paying the difference, and thus you wouldn't have a need to hold additional BTSX beyond that (the "s" variable in arhag's math)? I feel like I'm still missing something fundamental here...

p1 = 30 BTSX/BitUSD
p2 = 0.1 BTSX/BitUSD
x = 100 BitUSD
m = 3,000 BTSX
wallet = 6,005 BTSX

p1  *     x     +      m     = collateral (c)
30  *   100   +   3,000   = 6,000 BTSX tied up as collateral

(p1  -  p2)     *       x         +        c           = BTSX in possession after covering
(30 – 0.1)      *     100       +     6,000       = 8,990 BTSX in possession, gain of 2,990 BTSX (49.8% gain, close to max theoretical gain of 50%)
(30 – 40 )      *     100       +     6,000       = 5,000 BTSX in possession, loss of 1,000 BTSX (16.66% loss)

max
(((30 – 45*1.1 )      *     100 )     +     6,000)*0.95       = ...

Okay, I see the 30, 100, & 6,000...I imagine the 0.95 is including the 5% margin call fee. But where does the "45*1.1" come into play? Isn't the margin call price p1 * 1.33? That's the margin price for any shorts I've executed so far...

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
Okay, final scenario using simple numbers as an example. Say I want to determine my maximum risk of loss in case a margin call is triggered. From my calculations below, it appears that the maximum loss is only 16.66% before you get margin called, but I feel like there must be something wrong with my numbers. Can anyone point me in the right direction? Also, what would be so risky about shorting say 49% of your wallet balance (thus having the remaining 49% tied up as collateral)? If you get margin called, wouldn't the collateral go towards paying the difference, and thus you wouldn't have a need to hold additional BTSX beyond that (the "s" variable in arhag's math)? I feel like I'm still missing something fundamental here...

p1 = 30 BTSX/BitUSD
p2 = 0.1 BTSX/BitUSD
x = 100 BitUSD
m = 3,000 BTSX
wallet = 6,005 BTSX

p1  *     x     +      m     = collateral (c)
30  *   100   +   3,000   = 6,000 BTSX tied up as collateral

(p1  -  p2)     *       x         +        c           = BTSX in possession after covering
(30 – 0.1)      *     100       +     6,000       = 8,990 BTSX in possession, gain of 2,990 BTSX (49.8% gain, close to max theoretical gain of 50%)
(30 – 40 )      *     100       +     6,000       = 5,000 BTSX in possession, loss of 1,000 BTSX (16.66% loss)

max
(((30 – 45*1.1 )      *     100 )     +     6,000)*0.95       = ...
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Offline nomoreheroes7

  • Hero Member
  • *****
  • Posts: 756
  • King of all the land
    • View Profile
  • BitShares: nomoreheroes7
Okay, final scenario using simple numbers as an example. Say I want to determine my maximum risk of loss in case a margin call is triggered. From my calculations below, it appears that the maximum loss is only 16.66% before you get margin called, but I feel like there must be something wrong with my numbers. Can anyone point me in the right direction? Also, what would be so risky about shorting say 49% of your wallet balance (thus having the remaining 49% tied up as collateral)? If you get margin called, wouldn't the collateral go towards paying the difference, and thus you wouldn't have a need to hold additional BTSX beyond that (the "s" variable in arhag's math)? I feel like I'm still missing something fundamental here...

p1 = 30 BTSX/BitUSD
p2 = 0.1 BTSX/BitUSD
x = 100 BitUSD
m = 3,000 BTSX
wallet = 6,005 BTSX

p1  *     x     +      m     = collateral (c)
30  *   100   +   3,000   = 6,000 BTSX tied up as collateral

(p1  -  p2)     *       x         +        c           = BTSX in possession after covering
(30 – 0.1)      *     100       +     6,000       = 8,990 BTSX in possession, gain of 2,990 BTSX (49.8% gain, close to max theoretical gain of 50%)
(30 – 40 )      *     100       +     6,000       = 5,000 BTSX in possession, loss of 1,000 BTSX (16.66% loss)

Offline tonyk

  • Hero Member
  • *****
  • Posts: 3308
    • View Profile
Lack of arbitrage is the problem, isn't it. And this 'should' solves it.

Tuck Fheman

  • Guest

Offline jernau

  • Full Member
  • ***
  • Posts: 78
    • View Profile
Math time! Let's generalize this with algebra rather than using specific numbers. Note that this may not be super accurate with the recent changes to the market rules regarding shorts prioritized by collateral.

I want to short x BitUSD at a price of p1 BTSX per BitUSD. I provide m BTSX margin as part of the collateral. This means if my short is fully matched, there will be c = (p1 * x + m) BTSX held in collateral in the short position which owes the network x BitUSD. Now let's say the price of BTSX changes and I want to cover. I purchase x BitUSD at a new price of p2 BTSX per BitUSD (meaning I pay p2 * x BTSX). I use the x BitUSD to cover my short position and that gives me the c BTSX held in collateral. I originally had (m + p2 * x) BTSX in my possession, now I have (p1 * x + m) BTSX in my possession. The net change in BTSX through this process is (p1 - p2) * x BTSX.

I had to keep some amount of BTSX sitting around in order to do this short. I had m BTSX locked up in collateral that I could not touch. But I also had to keep some amount of BTSX around to buy BitUSD to cover; I will define this amount to be s * p1 * x BTSX. Let us say I was fairly confident in the value of BTSX rising with respect to BitUSD. In that case I would be fine with s = 1 since it would be more than the p2 * x BTSX needed to buy the BitUSD to cover. If I want to be more conservative, I should choose s > 1, so that I can afford to cover if the value of BTSX with respect to BitUSD falls. The largest value of s should be (1 + m/(p1*x))/1.5, since if p2 rises high enough that I would need even more BTSX than that to buy BitUSD it would already be too late (the network would do a margin call since the collateral would become less than 150% of the value of the BitUSD debt owed). If BitShares X was modified to allow shorts to cover by bidding for BitUSD on the exchange, I wouldn't need to hold any extra BTSX (meaning s = 0). Whatever my choice, we can claim that I have (m + s * p1 * x) sitting around for the purposes of gaining from my short position. If the value of BTSX does rise with respect to BitUSD (meaning p2 < p1), then in terms of the fractional gain relative to the amount of BTSX I had to hold I gain f = [(p1-p2)*x]/[m + s*p1*x] = [1 - p2/p1]/[m/(p1*x) + s].

Let's define r to be the fractional increase over this period in the price of BTSX in terms of BitUSD. The price of BTSX was first 1/p1 BitUSD and then later became 1/p2 BitUSD. Therefore, r = (1/p2 - 1/p1)/(1/p1) = p1/p2 - 1. I can use this to simplify f above: f = r/[(1+r) * (s + m/(p1*x)]. Let's take the very conservative estimate for s, just to simplify the variables a little more: f = r/[(1+r) * ((2/3) + (5/3) * (m/(p1*x)))]. Finally, let us assume that you can get your short matched at the bare minimum collateral so that we can replace m/(p1*x) with 1. Then f = (3*r)/(7*(1+r)).

And there you have it. Under the above assumptions, if I short and the price of BTSX goes up by 10%, I can cover and increase my BTSX holdings by up to 3.9% (f = (3*0.1)/(7*(1+0.1)) = 0.03896). Notice that even if the value of the dollar drops to zero (meaning r approaches infinity), I can still only increase my BTSX holdings by up to 43% (again assuming I am using the more conservative assumption above).


I would really appreciate it if someone checks my math for errors.

Exercise for the reader :): Given an average steady rate of increase, a, in the price of BTSX with respect to BitUSD (or USD), what is my return on investment with compounding (meaning I short, cover, use gained BTSX to short again, repeat) as a function of a regular short-cover time period T (assuming the price at the moment of each short/cover instance falls on the average steady increase curve)? Solve for both linear and exponential growth curves.
This is really good. Thank you. I've been looking for a more rigour. I appreciate the generality. You should put this on the wiki. I'm sure I'm not the only one looking for this.
PTS: PgiEykg2RATYwWYhFtyNRqwSxQyEApLSmW

Offline nomoreheroes7

  • Hero Member
  • *****
  • Posts: 756
  • King of all the land
    • View Profile
  • BitShares: nomoreheroes7
If you cover and re short you can compound your gains.  In theory you should do this as often as possible.

Wow bm, I never would've thought of that! So it's like buying low and selling high...only in reverse: shorting high then covering low, right? That's pretty awesome.

Arhag: I appreciate the math lesson, but I'll be damned if I understand a word you're saying lol. Appreciate the input; hopefully it helps others who are more math inclined.

Thanks all for your input! But I'm still curious what would happen if I were to try shorting my entire wallet balance...the order goes to market, but there wouldn't be enough collateral to support it...would the order just not place or something?