Author Topic: price feeding review  (Read 2128 times)

0 Members and 1 Guest are viewing this topic.

Offline Bhuz

  • Committee member
  • Sr. Member
  • *
  • Posts: 424
    • View Profile
  • BitShares: bhuz
Re: price feeding review
« Reply #30 on: November 19, 2018, 11:23:45 pm »
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

Online Bangzi

  • Full Member
  • ***
  • Posts: 182
    • View Profile
    • Steemit: Bangzi
  • BitShares: bangzi
Re: price feeding review
« Reply #31 on: November 20, 2018, 12:12:20 am »
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)
Please Vote for My Witness: Bangzi
My Blog: https://steemit.com/@bangzi
请投票支持比特股见证人: Bangzi

Offline clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #32 on: November 20, 2018, 08:09:48 am »
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 abit

  • Committee member
  • Hero Member
  • *
  • Posts: 3482
    • View Profile
    • Steemit Blog
  • BitShares: abit
  • GitHub: abitmore
Re: price feeding review
« Reply #33 on: November 20, 2018, 04:21:05 pm »
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 »
BTS account: abit
BTS committee member: abit
BTS witness: in.abit

Offline clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #34 on: November 20, 2018, 09:29:37 pm »
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 clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #35 on: November 22, 2018, 09:38:47 am »
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.

Online Bangzi

  • Full Member
  • ***
  • Posts: 182
    • View Profile
    • Steemit: Bangzi
  • BitShares: bangzi
Re: price feeding review
« Reply #36 on: November 22, 2018, 10:19:14 am »
@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)
Please Vote for My Witness: Bangzi
My Blog: https://steemit.com/@bangzi
请投票支持比特股见证人: Bangzi

Offline clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #37 on: November 22, 2018, 10:29:05 am »
@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 bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1067
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
Re: price feeding review
« Reply #38 on: November 22, 2018, 11:20:23 am »
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 »

Offline clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #39 on: November 22, 2018, 11:48:20 am »

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 zhouxiaobao

Re: price feeding review
« Reply #40 on: November 22, 2018, 12:02:11 pm »
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 xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12722
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Re: price feeding review
« Reply #41 on: November 22, 2018, 12:17:36 pm »
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.
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1067
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
Re: price feeding review
« Reply #42 on: November 22, 2018, 01:12:12 pm »
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.


Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1067
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
Re: price feeding review
« Reply #43 on: November 23, 2018, 10:39:53 am »
https://www.gdex.io/price here to check the premium data of bitCNY and bitUSD.

Offline clockwork

  • Committee member
  • Full Member
  • *
  • Posts: 188
    • View Profile
  • BitShares: clockwork
Re: price feeding review
« Reply #44 on: November 23, 2018, 11:04:41 am »
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.

Sure...

My suggestion for dynamic adjustment once the backend is fixed is the following:


Set a range and centerpoint for MSSR..

Obviously, MSSR can't go below 100% so if we keep 110 as the "centerpoint", we allow witnesses to manipulate MSSR up to 120%.

This is our first, go to weapon when fighting a premium or discount.

If premium, we reduce MSSR down to 100 to reduce sell pressure and allow DEX price to climb and close premium

If discount, we increase up to 120 to increase bitUSD supply and close discount.

If we reach either of the limits and STILL in premium or discount, then and ONLY then do we start adjusting the MCR.

Again, let's keep something like 175 as a centerpoint and a range within which we can increase or decrease (say 150-200).

This means that if you keep your collateral above the max end of the range , you know you're safe making the adjustments predictable.

If we go beyond those ranges again, just leave it at those maxiumums or minimums. Behaviour will be the same as we used to have when it comes to premium or discount (sans adjustment) but will happen much less often and within a smaller range.

When "returning" from those maximums or minimums, we do it reversely... bring MCR back to centerpoint and then adjust MSSR afterwards (if still needed)