Author Topic: [Witness Proposal] gdex-witnness  (Read 15535 times)

0 Members and 1 Guest are viewing this topic.

Offline j.galt

  • Newbie
  • *
  • Posts: 8
    • View Profile
Has a consensus emerged yet to set parameters for this PID algorithm? What results have been published? Does the author of BSIP42 expect all 27 / 29 witnesses to code their own versions of this or are open source versions available to witnesses they can tweak?

All PID process control algorithms rely on getting the feedback tuned in for the specific characteristics (inherent latency) of the system being controlled. That latency almost certainly is affected by the feed sources used. I suspect it is also affected by network latency, and we know that varies widely between western and far eastern API nodes.

If the point of BSIP42 is a tighter peg and not just a subsidy for traders, from what I observed the "experimentation" which BSIP42 allowed for (based on what I saw on Telegram it was treated like an absolute and urgent requirement on par with security patches!) was rushed into production without much planning and coordination at all. From the time BSIP42 was approved to when some were practically demanding witnesses to produce "conforming" CNY feeds was only a few days.

If a large percentage of witness participation in this CNY PID price feed experimentation was necessary it should have been announced in the BTS Witness Alerts Telegram channel. 

If the goal is a tighter CNY peg it seems to me a common reference implementation we can all tweak based on our preferred price sources used in various places around the globe would be a necessary starting point. Without that (for example if every witness or most of them wrote their own PID script) it will take longer for all witnesses to get on same page as they optimize their script's parameters and feedback to be in harmony with other witnesses and the median feed price.

I found it troubling this experimentation as conducted could trigger a black swan event, and this wasn't discussed much. In general I have zero objections to refine and improve our feed algorithms, but we shouldn't rush into it as it seems we're doing.

Water under the bridge so they say if a consensus for a new CNY feed algorithm has now been determined. Has it? If so, now all the non-coding witnesses need is a report or program they can tweak and they too can join in. Even if it has for the current market conditions, that doesn't mean all hell can't break loose if the market volatility gets to wild.

Abit's concern for feeds too far away from the median that leads to an abrupt (and catastrophic) price changes was always a potential risk with how BSIP42 was conducted. Fortunately that didn't happen, even with several witnesses not using (or not having the PID tuned well) a PID feed algorithm. The median / indirect manor feed prices are published works well. Outliers could be a problem if the market became more volatile though. However the parameters used to control the PID feedback set in a non-volatile market may not be tuned properly for changes in a volatile market, and if feedback is too sensitive could lead to some vary wide price swings.







 

Offline bench

Why didn't you agree on a collectiv refferal program which would bring massivly new members to DEX ?
This would be a good solution

Where can I find information about the collective referral program? 
Be part of the change and vote for the bitshares-vision proxy!

Offline Thul3

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
What will be the next proposal to cancel black swan events ?

you are right, I am considering to cancel black swan events.

Why didn't you agree on a collectiv refferal program which would bring massivly new members to DEX ?
This would be a good solution

Maybe you should focus on adoption instead of manipulation ?

I'm just helping Bitshares to evolve. I cannot persuade more people to adopt bitCNY if it is always in serious shortage and high premium.

Why didn't you agree on a collectiv refferal program which would bring massivly new members to DEX ?
This would be a good solution?

I'm really not here to attack you personly but i'm trading a lot and for me there is a high possibility we will see a BTS price of0.25-0.3 BitCNY and lowering the margin call security makes it in my eyes way more probable to cause a global settlement if margin calls won't be filled anymore.
« Last Edit: September 13, 2018, 12:36:10 pm by Thul3 »

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
What will be the next proposal to cancel black swan events ?

you are right, I am considering to cancel black swan events.


Maybe you should focus on adoption instead of manipulation ?

I'm just helping Bitshares to evolve. I cannot persuade more people to adopt bitCNY if it is always in serious shortage and high premium.
Email:bitcrab@qq.com

Offline Thul3

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
What will be the next proposal to cancel black swan events ?

you are right, I am considering to cancel black swan events.


Maybe you should focus on adoption instead of manipulation ?

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
What will be the next proposal to cancel black swan events ?

you are right, I am considering to cancel black swan events.
Email:bitcrab@qq.com

Offline Thul3

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
BTS price on bitCNY is nearly 10% under margin call price which has already a premium of 10% under feed price.
When checking the reason i realised you just destroyed the function to arbitrage these margin calls even the current price on DEX is 10% lower than the margin call price.


People stopped buying margin called assets and BTS price is now 10% under margin call which means once the downtrend starts these margin walls will get bigger and bigger.

You just increased massivly the risk for a black swan event


What will be the next proposal to cancel black swan events ?
« Last Edit: September 13, 2018, 07:55:38 am by Thul3 »

Offline abit

  • Committee member
  • Hero Member
  • *
  • Posts: 4664
    • View Profile
    • Abit's Hive Blog
  • BitShares: abit
  • GitHub: abitmore
1. due to the median mechanism, not like traditional PID system, in BitShares individual witness's feed affects the result only indirectly. We need more witnesses to adopt a feedback algorithm like this one. Before majority of witnesses started using a feedback algorithm, it's doesn't make sense to adjust one's feed far away from median. It's even dangerous since it may lead to potential unnecessary big swings when the trend changes.

2. IMHO it's not good to arbitrarily set a limit/cap on "i" since it may prevent the factor from effectively developing, especially when Ti is playing a key role.
BitShares committee member: abit
BitShares witness: in.abit

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
updated version:

Pdex:BTS price in DEX in bitCNY
Pf: current feed price
premium: current premium
Premium0: premium in the last period

Tp=4;Ti=10; Td=1; ##parameters for PID control, here the Ti plays a key role, it should fit the update period

get Pdex, Pf, premium;
premium0=premium;
p=Tp*premium;
i= Pf/Pdex-p-1; ##set initial value for p,i,d to make the initial calculated feed price equal to the current feed price in system.
d=0;

while True:
   
   get Pdex, Pf, premium;

   i+=premium/Ti;
   if i>0.4: ##set limit to i, to speed up the backward adjustment if premium change to cross 0
       i=0.4;
    if i<-0.3:
       i=-0.3;
    d=Td*(premium-premium0);
    premium0=premium;
           
   p=Tp*premium;
   
   if p+i+d>0:
     feed price = Pdex*min(1+p+i+d, 1.5, 1.03*Pf/Pdex) ##limit the feed price comparing to Pdex and current feed price while the adjustment is upward.
   else:
     feed price = Pdex*max(1+p+i+d, 0.98*Pf/Pdex)##limit the feed price comparing to current feed price while the adjustment is downward.
   time.sleep(120) ##update every 2 minutes.
« Last Edit: September 13, 2018, 02:29:39 am by bitcrab »
Email:bitcrab@qq.com

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
gdex-witness plan to adopt below algorithm for bitCNY price feeding, the core idea comes from PID control theory.

Pdex:BTS price in DEX in bitCNY
Pf: current feed price
premium: current premium
Premium0: premium in the last period

Tp=4;Ti=6; Td=1; ##parameters for PID control, here the Ti plays a key role, setting it to 6 will make i reach maximum in 20 hours if the premium keeps 2% or higher.

get Pdex, Pf, premium;
premium0=premium;
p=Tp*premium;
i= Pf/Pdex-p-1; ##set initial value for p,i,d to make the initial calculated feed price equal to the current feed price in system.
d=0;

while True:
   
   get Pdex, Pf, premium;

   while (10 minutes passed after the last execution):
         i+=premium/Ti;
         if i>0.4: ##set limit to i, to speed up the backward adjustment if premium change to cross 0
            i=0.4;
         if i<-0.3:
            i=-0.3;
         d=Td*(premium-premium0);
         premium0=premium;
           
   p=Tp*premium;
   
   if p+i+d>0:
     feed price = Pdex*min(1+p+i+d, 1.5, 1.2*Pf/Pdex) ##limit the feed price not higher than 1.5 times Pdex or 1.2 times current feed price while the adjustment is upward.
   else:
     feed price = Pdex*max(1+p+i+d, 0.91*Pf/Pdex)##limit the feed price no less than 0.91 times current feed price while the adjustment is downward.
Email:bitcrab@qq.com

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
updated gdex-witness bitCNY feed price algorithm:

Pdex:BTS price in bitCNY in DEX
premium: calculated from magicwallet bitCNY deposit/withdraw fee and BTS price difference in bitCNY & fiat CNY.

if 0<premium<1%:
feed price = Pdex*(1+9.6*premium)

if 1%<premium<2.4%:
feed price = Pdex*(1+9.6%)

if 2.4%<premium:
feed price = Pdex*(1+4*premium)
Email:bitcrab@qq.com

Offline gghi

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
  • BitShares: ttt888
gdex-witness now adopt a new algorithm to feed bitCNY price, the new algorithm is based on BSIP42.

1.get a market price in fiat CNY which is the max from referenced exchange.
market price = max(Pdex, Pcex1,Pcex2...)
2.calculate the bitCNY premium in percent from BTS price difference between DEX and CEX, and the deposit fee in magicwallet.
3.set a limit to restrict the max percent for adjusting the feed price, initially let limit=10%
feed price = market price*[1+min(premium, limit)]
feed price = market price*1.05*[1+min(premium, limit)]      feed price = market price*1.03*[1+min(premium, limit)] 

feed price = market price*1.02*[1+min(premium, limit)] 
   

 

we understand that although BSIP42 worker proposal is active, we need more time for community to review and decide. we now begin to adopt the new algorithm is to do some experiment, to do some controllable change to show the result to the public and help the voters to decide whether to support this kind of change. if finally the BSIP42 is rejected, we'll return to the old feed algorithm immediately.

any comments on the new algorithm are welcome.

Offline sschiessl

  • Administrator
  • Hero Member
  • *****
  • Posts: 662
    • View Profile
  • BitShares: sschiessl
https://github.com/bitshares/bsips/pull/105

Please consider this, and please to also honor it if accepted.

Offline sschiessl

  • Administrator
  • Hero Member
  • *****
  • Posts: 662
    • View Profile
  • BitShares: sschiessl

Offline bitcrab

  • Committee member
  • Hero Member
  • *
  • Posts: 1928
    • View Profile
  • BitShares: bitcrab
  • GitHub: bitcrab
gdex-witness now adopt a new algorithm to feed bitCNY price, the new algorithm is based on BSIP42.

1.get a market price in fiat CNY which is the max from referenced exchange.
market price = max(Pdex, Pcex1,Pcex2...)
2.calculate the bitCNY premium in percent from BTS price difference between DEX and CEX, and the deposit fee in magicwallet.
3.set a limit to restrict the max percent for adjusting the feed price, initially let limit=10%
feed price = market price*[1+min(premium, limit)]

we understand that although BSIP42 worker proposal is active, we need more time for community to review and decide. we now begin to adopt the new algorithm is to do some experiment, to do some controllable change to show the result to the public and help the voters to decide whether to support this kind of change. if finally the BSIP42 is rejected, we'll return to the old feed algorithm immediately.

any comments on the new algorithm are welcome.
Email:bitcrab@qq.com