Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFDs: partial matches don't move proportionally less #191

Closed
adamkrellenstein opened this issue Jul 17, 2014 · 22 comments
Closed

CFDs: partial matches don't move proportionally less #191

adamkrellenstein opened this issue Jul 17, 2014 · 22 comments
Assignees
Labels

Comments

@adamkrellenstein
Copy link
Member

The way that credits and debits are calculated now, a whole bet and 1/10th of that bet both have the same exposure to movements in the value of the broadcast it tracks. The latter, then, will liquidate well before the former, instead of at the same time, as it probably should.

The naive solution is to make the leverage proportional to the fraction of the bet that was matched. Then, however, the two bets don't experience the same leverage. (This problem may be worked around with something like this: 0229f63.)

It's possible that the only way around this is to forbid partial matches.

See #190, and branch cfd2.

@adamkrellenstein
Copy link
Member Author

We'll need extensive testing of any new algorithm we implement.

It's not an option to make the price movement equal to the proportional change in the price feed's value, I don't think: that wouldn't be a CFD.

It's also not an option to match two [whole] CFDs with different (effective) leverages.

I'm not sure that partial matches for CFDs are very valuable.

@adamkrellenstein
Copy link
Member Author

You can't have asymmetric leverages, or you could troll the book with very low leverage CFDs, I think.

@adamkrellenstein
Copy link
Member Author

@JahPowerBit and @xnova, thoughts?

@adamkrellenstein adamkrellenstein self-assigned this Jul 22, 2014
@adamkrellenstein
Copy link
Member Author

Ouziel: 'We should probably force wager and counterwager to be equal for CFDs, as the ratio isn't really the same as the odds for a bet. If we do this, then there will be no more partial matches.'

@MattCounterparty
Copy link

Not allowing partial matches is far from ideal and would have fairly dire consequences to liquidity. Hopefully there is a way around that.

@adamkrellenstein
Copy link
Member Author

@MattCounterparty, I think that 0229f63 would make it possible. Not sure, though. (Ouziel can check.)

@evanwagner1
Copy link

Could one do this:

bet(1): --wager=WAGER --counterwager=COUNTERWAGER --leverage=LEVERAGE
--counterleverage=COUNTERLEVERAGE

and two bets are matched if:

for bet2, --leverage(bet2) >= counterleverage(bet1), and
wager(bet2)/counterwager(bet2) >= wager(bet1)/counterwager(bet1)

and

whatever wager in the bet match is the lesser of the two wagers determines the total possible gains on the bet match?

This last part in particular seems unnecessary to me, however given the p2p, fully collateralized nature of CFDs in Counterparty (as opposed to margin-based CFDs with a market maker, as in traditional finance) it may be for the best?

@ghost
Copy link

ghost commented Jul 24, 2014

I haven't posted on here because there is nothing technical to respond to.
I've already explained that this 'fix' 0229f63 causes sanity errors.Please, re-read the email discussion.

@adamkrellenstein
Copy link
Member Author

@cityglut, that's an incomplete solution.

@ouziel-slama
Copy link
Contributor

If we consider that wager is always equals to counterwager, then after thought, we can make the matching even better, because all bets on the same feed_address and and same leverage can partial matches with others.. and the exposure will be the same for both side (bear_escrow=bull_escrow).
We can also add the notion of "initial_quantity" like porqup1ne proposed, but I'am not convinced that bring something (see my last comment on #190).

@ghost
Copy link

ghost commented Jul 24, 2014

@JahPowerBit I did not propose any such thing like initial_quantity. You are misunderstanding entirely.

@PhantomPhreak please quit wasting time with patches that are basically more broken than the original, and answer my question regarding CFD's it seems to me that you have a mathematically inadequate notion of what a CFD is and this is preventing the discussion from making headway.

@adamkrellenstein
Copy link
Member Author

@MattCounterparty, partial matches for CFDs are much less important than they are for Binary Bets, because, as Ouziel points out, wager and counterwager work totally differently here. (The price discovery for the odds is much weaker.)

@JahPowerBit, that sounds right! Very nice. (Then can we just force leverage * wager == counterwager * counterleverage, for a bit more flexibility? @cityglut, that condition is very different from what you proposed.)

@MattCounterparty
Copy link

I'll leave it to you guys as you're the experts. My only concern when looking at this thread was that bets matching less frequently in a young p2p ecosystem will be bad for overall liquidity making it harder to get a feed site up to critical mass, which is going to prove to be fairly difficult under the best circumstances anyway.

Thanks for all the work you guys do.

@adamkrellenstein
Copy link
Member Author

@matt, liquidity is probably our number one concern after just getting the thing to work. ;)

@ouziel-slama
Copy link
Contributor

@PhantomPhreak , leverage * wager == counterwager * counterleverage, hum.. not sure but I think no, because everybody will want to put a little wager with a big leverage and win against a big counterwager.. I think the concept of odds should bet used only in binary bet. For contract I would say to keep risk equal on the both sides.

@adamkrellenstein
Copy link
Member Author

I've temporarily disabled CFDs on mainnet while this issue remains open.

@ouziel-slama
Copy link
Contributor

I read more closely you first fix: 0229f63
In fact, if I understand well, I think, is 'exactly' what I proposed: Instead to make match only CFD with wager==counterwager, you compensate the difference between them when you calculate the credit. I think it's a very economical and smart way in term of code to reach the goal! but it's like say "not not" instead "yes" ;-) but also less risky because is a lot less of code modification, and also largely preferable than no CFD at all.

@Frozenlock
Copy link
Contributor

The first fix seems sensible (but I'm in no way an expert).

I mostly want to chip in on this little comment by @JahPowerBit:
" I think the concept of odds should bet used only in binary bet. For contract I would say to keep risk equal on the both sides."

Odds are necessary to allow a market maker to make a profit.
The MM is necessary to bring the required liquidity for bootstrapping the market, but also to keep it alive in periods of low activity.

@PhantomPhreak: Any ETA for CFDs on the mainnet?

@ghost
Copy link

ghost commented Sep 5, 2014

@Frozenlock I his statement would sound better if instead of "risk" he said "value at risk".

If you place a 20-unit bet @ leverage of 1 (=5040 in CP speak) and I place a bet of 1 unit @ leverage of 20, I shouldn't be able to win your 20 units, but only 1 (because that's how much I put at risk).
So if underlying moves by 0.05 in my favor, I would win 0.05*20 (my leverage) = 1 unit and you'd lose 1 unit. (Credit: this approach is what a friend who used to work with CfDs suggested to me few weeks ago).

This also seems to be what @citiglut argued for above.

@Frozenlock
Copy link
Contributor

Ah! My mistake then.

@Frozenlock
Copy link
Contributor

Turns out I completely misunderstood how wager and counterwager were currently used in the CFDs. I opened #277 as a possible way to use them.

@adamkrellenstein
Copy link
Member Author

This is something that would best be handled by the new contracts system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants