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

New BAIP: Dynamic price feeds based on EMAs and smartcoin metrics #7

Open
froooze opened this issue Nov 2, 2019 · 4 comments
Open

Comments

@froooze
Copy link

froooze commented Nov 2, 2019

BAIP: 0003
Title: Dynamic price feeds based on EMAs and smartcoin metrics
Authors: [bench]
Status: Draft
Type: Consensus 
Created: 2019-11-02

Abstract

The feed price is next to liquidity the most important factor of the smartcoin market.
The current feed script implementation has several limitations and drawbacks on the market performance:

  • no robustness against market manipulation
  • no consequent collateral selling in a downtrend
  • selling collateral at too low price
  • too much collateral selling in an uptrend

Motivation

The price feeds guides the debt borrowing and collateral selling through different market states.
Optimizing the price feed, increases the market performance and collateral value.

Price feeds should:

  • minimize bad debt
  • minimize low selling of collateral
  • minimize margin calls
  • be robust against market manipulation

Because simple solutions were not successful so far, a complex approach was developed.

Rationale

To ensure the best feed price performance in every market condition, the price feed calculations must be dependent on the current market state and market metrics.
A combination of different Exponential Moving Averages (EMAs) provide the feed price range and the right market state. The smartcoin metrics and other script parameters precise the price feed calculation, dependent on the current market state.

Feed price range

This proposal combines the advantages of a fast, medium and slow EMA for price feed definition.
The weighting for the different EMAs, is dependent on the state parameters, smartcoin metrics and price feed parameters.

Shorting attack on BTS, shows the advantage and disadvantage of three different EMAs:

  • fast EMA (red line), good collateral selling, but low BTS price
  • medium EMA (yellow line)
  • slow EMA (green line), bad collateral selling, but high BTS price

ema3

Specification

Price feed script is based on:

  • 3 different EMAs
  • 5 different EMA parameter
  • 5 additional price feed parameter
  • 6 different market states for price feed calculation
  • 2 different market state parameters ( state_value & transition_value)
  • 4 different market conditions for market state transition
  • smartcoin metrics (amount of collateral sell/buy)

Dynamic price feed flow

price-feed-flow

Summary for Shareholders

Feed prices based on different EMAs and smartcoin metrics is a very important upgrade to improve our smartcoin market performance.

Discussion

See also

Copyright

This document is placed in the public domain.

@grctest
Copy link

grctest commented Nov 3, 2019

The current feed script implementation has several limitations and drawbacks on the market performance:

  • no consequent collateral selling in a downtrend
  • selling collateral at too low price
  • too much collateral selling in an uptrend

Price feed scripts shouldn't be responsible for the above, they're all influenced by the collateral ratio decisions of individual debtors, no?

Selling collateral at a low price might be seen as bad for the debtor, but it's great for the market participant who is able to buy a large bag of BTS at low prices.

Why is collateral selling in an uptrend a limitation/drawback? Fair enough if it globally settles at very high prices and isn't recoverable for a long time (like silver/gold) that's not good, do you mean collateral selling through margin calls (or lowest cr position when force settled) instead of a large amount of smartcoins being issued in uptrends?

Optimizing the price feed, increases the market performance and collateral value.

Optimized price feeds improving the price of BTS is speculation.

Price feeds should:

  • minimize bad debt
  • minimize low selling of collateral

Should they? Bad debt is a symptom of bad debtors, such bad behaviour isn't influenced by price feeds. Further the selling of collateral at low prices can't be avoided through price feeds if someone force settles & you're the lowest collateralized position.

Because simple solutions were not successful so far, a complex approach was developed.

The price feed scripts were successful at providing an external market peg, there was never an original intention to avoid these issues you've raised.

You say it's been developed, are there price feed scripts we can run on testnet to evaluate their effectiveness?

To ensure the best feed price performance in every market condition, the price feed calculations must be dependent on the current market state and market metrics.

With this in mind, will this BAIP supersede & nullify BSIP76? BSIP76 is completely detached from the current market state/metrics.

This proposal combines the advantages of a fast and slow EMA for price feed definition.
[ ... ]
Price feed script is based on:

  • 3 different EMAs
  • 5 different EMA parameter

Rational mentions 2 EMA, but specification lists 3 EMAs & 5 different parameters for each EMA.

Can you elaborate more in the specifications? What's the 3rd EMA & what are the parameters?

How are these EMAs combined?

Price feed script flow

Could you elaborate with pseudocode (or script for testnet testing)?

Discussion

The discussion section is missing.

@froooze
Copy link
Author

froooze commented Nov 3, 2019

  • no consequent collateral selling in a downtrend
  • selling collateral at too low price
  • too much collateral selling in an uptrend

Price feed scripts shouldn't be responsible for the above, they're all influenced by the collateral ratio decisions of individual debtors, no?

Price feed script is responsible for collateral selling, when CR < MCR.

Selling collateral at a low price might be seen as bad for the debtor, but it's great for the market participant who is able to buy a large bag of BTS at low prices.

The market needs on the one side an opportunity to buy cheap BTS on the other side the collateral value needs a protection against shorting attacks. Feed prices are only increased, when certain market conditions (e.g. margin call volume) are meet and not before.

Why is collateral selling in an uptrend a limitation/drawback?

Static margin call walls suppress the price in an uptrend. When the market conditions have changed selling collateral has no advantage on BTS price and collateral positions.

do you mean collateral selling through margin calls (or lowest cr position when force settled) instead of a large amount of smartcoins being issued in uptrends?

Yes

Optimizing the price feed, increases the market performance and collateral value.

Optimized price feeds improving the price of BTS is speculation.

The concept is to use different TA methods for price feeds, which guides the collateral selling and debt borrowing. Improving the feed price does not increase the BTS value, but the collateral value, because margin calls and debt borrowing are optimized.

Price feeds should:

  • minimize bad debt
  • minimize low selling of collateral

Should they? Bad debt is a symptom of bad debtors, such bad behavior isn't influenced by price feeds.

Bad debt is a result of price feeds not supporting collateral sell in a downtrend and low market liquidity.

Further the selling of collateral at low prices can't be avoided through price feeds if someone force settles & you're the lowest collateralized position.

This is still possible, but the feed price can be higher/lower, than the current market price, because EMA is lagging behind the real price.

The price feed scripts were successful at providing an external market peg, there was never an original intention to avoid these issues you've raised.

This is the reason to rethink our price feed scripts.

You say it's been developed, are there price feed scripts we can run on testnet to evaluate their effectiveness?

Not yet, I work on the integration to Zapata's price feed script.

With this in mind, will this BAIP supersede & nullify BSIP76? BSIP76 is completely detached from the current market state/metrics.

The script was designed for every market condition, price feed threshold is not touched.

Rational mentions 2 EMA, but specification lists 3 EMAs & 5 different parameters for each EMA.

Yes the medium EMA, which is between the fast and slow EMA is missing. Updated start post!

How are these EMAs combined?

Combination is done through weight adjust of EMAs, which is dependent on market state_value and transition_value. transition_value is dependent on state_value, smartcoin metrics & price feed parameter.

Could you elaborate with pseudocode (or script for testnet testing)?

I can offer a working Python code, after it gets funded.

@froooze
Copy link
Author

froooze commented Nov 8, 2019

@clockworkgr
Comparison between EMA (red), LWMA (yellow) and SMA (green) with the same input settings.

clock-MA

@bitcrab
Copy link
Contributor

bitcrab commented Nov 12, 2019

reference chart for comparing EMA and MA, from huobi.

image

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

No branches or pull requests

3 participants