Author Topic: price feeding review  (Read 17292 times)

0 Members and 1 Guest are viewing this topic.

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
If we have a discount and need to increase demand, effective MCR needs to be increased so that people ARE called and their margins BUY bitUSD from the market thus increasing demand.

If we stop this from happening or those margin calls are way too far from the market price, the effect is lost... this is why BSIP 42 worked well so far when we had a premium against a ranging market, but completely failed to keep the peg on discount on a dropping market (just look at the charts).

It is not nice for those with lower CR but it IS the way to keep a tight peg. And hopefully peopel will learn to keep their CRs high enough.

some factors need to be taken into account while considering this.

as we know, BSIP42 is not completely applied on bitUSD, a compromise is finally reached that witnesses can select to or not to apply BSIP42 on bitUSD.

even though, I believe bitUSD behave much better with BSIP42 than without it.

Email:bitcrab@qq.com

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I agree with @clockwork.
It seems to be an art to find a balance. Certainly we've learned alot from
BSIP42 even though some people in the community declare it a failure
already.

Maybe we can learn the lessons in such a way that it tells us how to use
a dynamic MCR once we have the backend fixed.

Offline zhouxiaobao

gdex planned to apply the "max premium" rule in feed price algorithm, also we'd like to show some relevant data in a webpage.

the main concept is to get the highest premium of smartcoin in the market, and the calculate out the feed price according to the negative feedback logic.

what sense does "highest premium" make?

there are 2 purposes before us: (maybe there are more, now we focus on these 2)

A: make the smartcoin pegging accurate enough.

B. provide some operation space to the market, make the smartcoin ecosystem grow rapidly.

obviously BSIP42 contributed greatly to A, however, it seems what the BSIP42 policy slow purpose B, recently there are a lot of discussion and complaints in Chinese community, mainly the voice focus on:

BSIP42 narrowed the market space of BTS, in DEX, while trading pushed up the price in bitCNY, the feed price always go down as responding according to the negative feedback logic, BTS price in DEX have to follow BTS price in CEX, these discouraged more money to come.

reducing feed price cause more margin calling so need to be careful, increasing feed price do not bring direct hurt to traders.

all these are demanding us to optimize the price feeding after understanding the market, I'd like to try some change on the calculation of premium, the point is, calculate several premium out from different routes, finally select the highest one to feed.

for example, as shown below we calculated out premiums of bitCNY from 3 routes and finally adopt the highest one - 0.97%





as shown below we calculated out premiums of bitUSD from 2 routes and finally adopt the highest one - 1.6%





later we will publish this page, hope it can help BTSers to evaluate witnesses' work.

verygood.希望一个点的折价容忍也一起推啊,这很重要,允许cny有波动范围,可以保持喂价稳定,减少过多的喂价上调和下调,就减少了爆仓风险呀。目前可以是一个点,下一步爆仓单消失了,建议可以放到-2%到+1%。

Offline clockwork

  • Committee member
  • Sr. Member
  • *
  • Posts: 376
    • View Profile
  • BitShares: clockwork

reducing feed price cause more margin calling so need to be careful, increasing feed price do not bring direct hurt to traders.


That is the whole point though.

We are changing the feed price in order to essentially change the effective MCR.

If we have a discount and need to increase demand, effective MCR needs to be increased so that people ARE called and their margins BUY bitUSD from the market thus increasing demand.

If we stop this from happening or those margin calls are way too far from the market price, the effect is lost... this is why BSIP 42 worked well so far when we had a premium against a ranging market, but completely failed to keep the peg on discount on a dropping market (just look at the charts).

It is not nice for those with lower CR but it IS the way to keep a tight peg. And hopefully peopel will learn to keep their CRs high enough.

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
gdex planned to apply the "max premium" rule in feed price algorithm, also we'd like to show some relevant data in a webpage.

the main concept is to get the highest premium of smartcoin in the market, and calculate out the feed price according to the negative feedback logic.

what sense does "highest premium" make?

there are 2 purposes before us: (maybe there are more, now we focus on these 2)

A: make the smartcoin pegging accurate enough.

B. provide some operation space to the market, make the smartcoin ecosystem grow rapidly.

obviously BSIP42 contributed greatly to A, however, it seems what the BSIP42 policy slow purpose B, recently there are a lot of discussion and complaints in Chinese community, mainly the voice focus on:

BSIP42 narrowed the market space of BTS, in DEX, while trading pushed up the price in bitCNY, the feed price always go down as responding according to the negative feedback logic, BTS price in DEX have to follow BTS price in CEX, these discouraged more money to come.

reducing feed price cause more margin calling so need to be careful, increasing feed price do not bring direct hurt to traders.

all these are demanding us to optimize the price feeding after understanding the market, I'd like to try some change on the calculation of premium, the point is, calculate several premium out from different routes, finally select the highest one to feed.

for example, as shown below we calculated out premiums of bitCNY from 3 routes and finally adopt the highest one - 0.97%





as shown below we calculated out premiums of bitUSD from 2 routes and finally adopt the highest one - 1.6%





later we will publish this page, hope it can help BTSers to evaluate witnesses' work.
« Last Edit: November 22, 2018, 12:03:50 pm by bitcrab »
Email:bitcrab@qq.com

Offline clockwork

  • Committee member
  • Sr. Member
  • *
  • Posts: 376
    • View Profile
  • BitShares: clockwork
@clockwork Since you are witness and you have the POWER to feed price, my advice is you can feed price based on your interpretation of BSIP42 and then other witnesses can observe your price feed and follow you if it work better.  8)


And I will once I have some time to rewrite the script appropriately. In the meantime I'm putting thoughts up for discussion so we can cut out suggestions that are fundamentally wrong rather than experiment blindly.

 So I would appreciate any comments on the thought process above seeing as it is what stopped me feeding until I could figure it out.

We all saw how the "try it and we'll see how it goes" attitude worked (didn't) during this market turn.

Offline Bangzi

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
    • Steemit: Bangzi
  • BitShares: bangzi
@clockwork Since you are witness and you have the POWER to feed price, my advice is you can feed price based on your interpretation of BSIP42 and then other witnesses can observe your price feed and follow you if it work better.  8)
Bitshares DEX - Over 1000 Coins, Buy, Sell, Transfer & List Any Coins |Free Signup Today: https://wallet.bitshares.org/?r=bangzi

Offline clockwork

  • Committee member
  • Sr. Member
  • *
  • Posts: 376
    • View Profile
  • BitShares: clockwork
last one is too slow to respond to downward movements...

maybe it protects from sudden/big margin calls but peg goes to hell

need to keep a state of market price and factor the market movement into those equations

Quick example:

Let's assume bitUSD  is at premium and negative feedback has brought feed price to 15-20% above market price.

Suddenly, we have a big drop. BTS drops sharply.

People start selling bitUSD to buy BTS. Now bitUSD becomes oversupplied and moves to discount territory.

The algorithms above do not take reversals into account. Especially with that discount protection, the feed price will respond VERY VERY slowly, leading to:

 a) lost peg. A sudden 5% drop in the market with the feed price at +15% will only bring a tiny move downwards from the previous feed price. Thus market to feed price distance will increase which will FURTHER increase discount

b)  as squeeze protection kicks in, margins will pile up and not get eaten. Perhaps some of them shouldn't (by design) but not all of them.

In fact, we saw this during this downtrend with bitUSD going into discount. This means that bitUSD was oversupplied. Which means that effective MCR should be increased to tighten the peg, yet we had positions with a CR of 1.1 with their margins not being eaten.

Pure negative feedback does NOT work. it deals terribly with reversals and is way too slow to respond to sudden market moves.

We need a stateful feed algorithm that ALSO applies the market movement to the price.

e.g. if we're feeding 10% above market and still have a premium, this means that we should feed a bit higher than 10% over market.But if market has also dropped 5%, we need to take that into account and feed LOWER than what we were or completely overshoot.

Offline clockwork

  • Committee member
  • Sr. Member
  • *
  • Posts: 376
    • View Profile
  • BitShares: clockwork
last one is too slow to respond to downward movements...

maybe it protects from sudden/big margin calls but peg goes to hell

need to keep a state of market price and factor the market movement into those equations

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
My algorithm:

* get BTC trading price from Kraken (BTC/fiatUSD), Bittrex (BTC/fiatUSD), AEX (USDT,CNC), ZB (USDT,QC), calculate USD/CNY price from these data
* get USDT/USD price from Kraken, Bittrex
* manually set ZB's QC price according to https://vip.zb.com/otc/trade/qc_cny?type=1, currently it's 1
* also got bitcny/fiatCNY price from magicwallet, AEX and ZB, but not using them

* get BTS trading price and volume from ZB(USDT,QC,BTC), AEX(USDT,CNC), Poloniex(BTC), Binance(BTC), Huobi(BTC,USDT), GDEX(BTC), CryptoBridge(BTC), Openledger(BTC), convert the price to CNY as well as USD using above data
* adjust BTS trading volume, currently, Poloniex_volume *0.2, ZB_volume *0.08, AEX_volume * 0.6, OpenLedger_volume *0.01
* calculate average BTS price weighted by adjusted volume

* get BTS/bitcny and BTS/bitusd price from DEX,
bitcny_premium = volume weighted average BTS price in CNY / price(BTS/bitcny) - 1
bitusd_premium = volume weighted average BTS price in USD / price(BTS/bitusd) - 1

* get current median feed price

* if premium > 0, new_feed_price = current_feed * (1+premium*1.2)
* if premium <=0 and premium >=-0.01, new_feed_price = current_feed
* if premium < -0.01, new_feed_price = current_feed * (1+premium*0.3)

Considering adding a blackswan protection to the algorithm.
« Last Edit: November 20, 2018, 04:24:41 pm by abit »
BitShares committee member: abit
BitShares witness: in.abit

Offline clockwork

  • Committee member
  • Sr. Member
  • *
  • Posts: 376
    • View Profile
  • BitShares: clockwork
so noone is actually using the fucking markets price anywhere? even though abit specifically said that it's DANGEROUS for everyone to use the lazy formula and it was just a stopgap measure?

good job guys...seriously...good job /s

Offline Bangzi

  • Sr. Member
  • ****
  • Posts: 321
    • View Profile
    • Steemit: Bangzi
  • BitShares: bangzi
Bangzi and winex.witness:

1) Premium:  1 - (TotalFiat / TotalBitCNY) from MagicWallet 24Hours Data

2) Threshold:
if 0.3% > Premium > -1%:
    Premium = 0
else:
    Premium = Premium

3) Feed Price = QuoteSettlementPrice * (1 + Premium)
Bitshares DEX - Over 1000 Coins, Buy, Sell, Transfer & List Any Coins |Free Signup Today: https://wallet.bitshares.org/?r=bangzi

Offline Bhuz

  • Committee member
  • Sr. Member
  • *
  • Posts: 467
    • View Profile
  • BitShares: bhuz
I am using my own script for bsip42:
  • premium = (real_price / dex_price) - 1
  • feedprice = settlement_price * (1 + premium)  // having been one of the first to start applying bsip42 to bitusd this formula was pretty ok
  • main sources are AEX and ZB, both adjusted
  • usdt/usd ratio from Bittrex and Kraken
  • everything is volume weighted

Offline Fox

Using Zapata's script to provide feeds in a similar way he documented here with the following differences:
 - do NOT use ZB as a source
 - do NOT provide feed for AMAZONCOM
 - do source additional pricing data from paid subscriptions: Currency Layer

« Last Edit: November 19, 2018, 08:35:15 pm by Fox »
Witness: fox

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
Witness sahkan-bitshares is using Zapata's script to provide the bsip price feeds. In addition to the script I utilize paid services from currencylayer and bitcoinaverage for more reliable currency pricing and increased api availability with closer to real time market pricing.

Please be aware that bitcoinaverage's BTC price is not good since it consider USDT as 1:1 peg to USD. But actually USDT now is trading around 0.98 USD and it's volatile. See http://www.untether.space/ for more info.
BitShares committee member: abit
BitShares witness: in.abit