BitShares Forum
Main => Technical Support => Topic started by: mindphlux on September 01, 2014, 04:43:54 pm
-
Hello,
I am currently trying to understand the technical details of the bitshares implementation.. I understand that shorts that are over the median of the pricefeed are not being executed, however, I'm not sure how this median value is calculated exactly. Does it just take all available price feeds, no matter how old, or is there some more advanced filtering?
I found this:
https://github.com/dacsunlimited/bitsharesx/commit/5a1a01f5931be51166f37e688cfb7eefd0ae6c4b
However, I cannot locate the function get_median_delegate_price() anywhere.
If you can point me to the right file with the function and/or answer my question, I'd be greatful.
Thank you
Best regards
mindphlux
-
I'd add:
- Isn't the accuracy the price (feed) a problem for calculating the median? Or is the median just calculated from the first x digits?
- In case of big price swings is it enough that delegates update the price feeds every 24 hours (24 hours was requirement I read)?
-
Anyone?
-
vector<price> feed_list
for all feeds
if published by active delegate in last 24 hours
feed_list.push( feed.price )
if feed_list.size >= 51
std::nth_element( feed_list.begin(), feed_list.begin() + feed_list.size(), feed_list.end() )
return feed_list[feed_list.size()/2]
-
Thank you.
I don't get quite get the std::nth_element call though, seems to be some sort of sorting,
Is the median calculated outside of this snippet? Why are you returning half of the size of the vector?
Thanks
--mindphlux
-
Thank you.
I don't get quite get the std::nth_element call though, seems to be some sort of sorting,
Is the median calculated outside of this snippet? Why are you returning half of the size of the vector?
Thanks
--mindphlux
nth_element does a partial sort because I only care that the first 50% of the items are in sorted order.
I return the item in the middle (median).