Merge pull request #58 from bitshares/bsip34

Add BSIP 34: Always Trigger Margin Call When Call Price Above Or At Price Feed
This commit is contained in:
Fabian Schuh 2018-02-22 12:07:36 +01:00 committed by GitHub
commit 2f45346aac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

104
bsip-0034.md Normal file
View file

@ -0,0 +1,104 @@
BSIP: 0034
Title: Always Trigger Margin Call When Call Price Above Or At Price Feed
Author: Abit More <https://github.com/abitmore>
Status: Draft
Type: Protocol
Created: 2018-02-18
Discussion: https://github.com/bitshares/bitshares-core/issues/606
Replaces: -
Worker: To be done
# Abstract
Currently, in BitShares, a short position may be margin called only when both
two requirements are met:
* call price is above or equal to median price feed
* no limit order on the book is buying collateral with price higher than the
short position's call price
This behavior has led to certain confusion and anger among market participants.
This BSIP proposes a new behavior to improve the situation: drop the second
requirement, trigger margin call when the first requirement is met.
# Motivation
To avoid ambiguity, in this article, all prices are in terms of
`debt asset / collateral asset`, aka how much debt asset per collateral
asset. A bid is an order to buy collateral asset with debt asset.
Generally, a short position may be margin called when its collateral ratio is
below or equal to maintenance collateral ratio (MCR).
However, to calculate collateral ratio, a fair collateral price is needed.
In BitShares, there are two data sources can be used to decide the fair
collateral price:
* the internal market
* the price feeds
Currently, both data sources are used. Specifically, collateral price is decided
as the higher one between the highest bid price on the internal market and the
median price feed. That said, when a short position's collateral ratio has
fallen to below or equal to MCR according to median price feed (in this case,
call price of the short position is above or equal to median price feed), if
there is a bid on the market with high price, the short position won't be margin
called.
This mechanism has led to certain confusion and anger among market participants.
* there are often orders with overlapping price on the book but didn't fill
* there are often short positions selling collaterals with low prices, but
traders are unable to buy at those prices
* it often causes borrowers to sell collaterals at a low price when have chances
to sell at higher price
* market manipulators / arbitrage traders have more chances to force borrowers
to sell collaterals at lower price
This BSIP effectively proposes a new behavior: derive the fair collateral price
only from price feeds.
# Rationale
Since price feeds are provided by a set of chosen producers, the median price
feed is usually considered trustworthy. On the other hand, instant market
price is not as reliable, especially for the markets with poor depth, so it's
a rather limited supplement for calculating collateral price.
At this moment, changing the rule to only use median price feed will clear away
the confusion the end users may have, while still keeping the derived collateral
price fair to an extent.
After this change is done, placing a new limit order will no longer trigger a
margin call, cancelling a limit order or expiring a limit order will no longer
trigger a margin call as well, that means we don't need to check for new margin
calls nor black swan events in those scenarios, so we'll gain a side benefit on
performance.
# Specifications
In `check_call_orders(...)` function of `database` class, when matching a call
order with a limit order, there is a check:
`if( match_price > ~call_itr->call_price )`, when the result is `true`,
processing will be ended and `margin_called` will be returned.
Need to skip the check and the following `return` action.
In `do_apply(...)` function of `limit_order_cancel_evaluator` class, and
similar code blocks after a limit order object is removed, no longer need to
call `check_call_orders(...)` function of `database` class.
# Discussion
[to be added if any]
# Summary for Shareholders
[to be added if any]
# Copyright
This document is placed in the public domain.
# See Also
* https://github.com/bitshares/bitshares-core/issues/606
* https://bitsharestalk.org/index.php?topic=25926.0