BitShares Forum

Main => General Discussion => Topic started by: biophil on December 03, 2014, 07:16:46 pm

Title: Do shorts fill below the price feed?
Post by: biophil on December 03, 2014, 07:16:46 pm
For a brief period today, BitCNY was trading at a huge premium to real CNY. I entered a couple small shorts to try to take advantage of the opportunity, and it looks like it worked, but I wanted to get it from a dev:

When a bitAsset trades at a premium, do shorts fill at the price feed, or do they fill at the ask price (which is below the price feed)? Obviously, it is absolutely crucial that the answer be the latter. It's not usually been an issue for BTS because most of the time, BitAssets trade at a discount. But if they suddenly start trading at a premium, it's essential that people can profit by short selling.
Title: Re: Do shorts fill below the price feed?
Post by: zerosum on December 03, 2014, 09:16:33 pm
They should fill at the shorts min. price (i.e price limit), according to Agent86.
https://bitsharestalk.org/index.php?topic=11674.msg157545#msg157545
Title: Re: Do shorts fill below the price feed?
Post by: Markus on December 03, 2014, 09:24:33 pm
I don't know if this is related to your problem but I experienced a situation I would call a bug as well:

Imagine the feed is 0.02 USD/BTS
There are no open short orders and no relevant open bids.
There is one open ask at 0.019 (so on the far side of the peg, something happening not often in the current market).

Now I post a short order limited at 0.019.

What happens is that the trade is executed because it matches an ask. BUT because shorts are always executed at the feed I actually pay 0.02 even though this is above my limit!

short will execute at price of min(feed price, limit price)
Code: [Select]
                // Always execute shorts at the feed price
                mtrx.bid_price = *_feed_price;

                // Skip shorts that are over the price limit.
                if( _current_bid->state.short_price_limit.valid() )
                {
                  if( *_current_bid->state.short_price_limit < mtrx.ask_price )
                  {
                      _current_bid.reset(); continue;
                  }
                  mtrx.bid_price = std::min( *_current_bid->state.short_price_limit, mtrx.bid_price );
                }
            }
Title: Re: Do shorts fill below the price feed?
Post by: toast on December 03, 2014, 09:30:19 pm
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

So you should be able to profit from shorting.
Title: Re: Do shorts fill below the price feed?
Post by: arhag on December 03, 2014, 10:12:28 pm
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

And apparently the code is written in this backwards way! Thanks for the clarification. It took me half a minute after reading Markus's post to realize the code didn't have a huge bug.

It just doesn't make sense. It is one thing to say the price of BTS is X BitUSD. But saying the price of BTS is Y BitOil (in other words, the price of 1 BTS is Y barrels of light sweet crude oil) is just weird.
Title: Re: Do shorts fill below the price feed?
Post by: toast on December 03, 2014, 10:20:23 pm
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

And apparently the code is written in this backwards way! Thanks for the clarification. It took me half a minute after reading Markus's post to realize the code didn't have a huge bug.

It just doesn't make sense. It is one thing to say the price of BTS is X BitUSD. But saying the price of BTS is Y BitOil (in other words, the price of 1 BTS is Y barrels of light sweet crude oil) is just weird.

Not to mention that every single UIA market is "asset per dollar"... Apparently it was more logical to make USD the last reserved asset to maximize number of "correct" market orientations in backwards-land than it was to have a normal orientation and order assets by importance (BTS > USD > BTC > all later assets)
Title: Re: Do shorts fill below the price feed?
Post by: zerosum on December 03, 2014, 10:35:36 pm

You guys are too picky... My local store is regularly selling me 0.42 2-liter bottles of coke per dollar and my local car dealer even offered me 0.000045 cars per dollar just last week.

Title: Re: Do shorts fill below the price feed?
Post by: arhag on December 03, 2014, 11:52:51 pm

You guys are too picky... My local store is regularly selling me 0.42 2-liter bottles of coke per dollar and my local car dealer even offered me 0.000045 cars per dollar just last week.

 :P  +5%
Title: Re: Do shorts fill below the price feed?
Post by: biophil on December 04, 2014, 12:00:14 am
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

And apparently the code is written in this backwards way! Thanks for the clarification. It took me half a minute after reading Markus's post to realize the code didn't have a huge bug.

It just doesn't make sense. It is one thing to say the price of BTS is X BitUSD. But saying the price of BTS is Y BitOil (in other words, the price of 1 BTS is Y barrels of light sweet crude oil) is just weird.

Not to mention that every single UIA market is "asset per dollar"... Apparently it was more logical to make USD the last reserved asset to maximize number of "correct" market orientations in backwards-land than it was to have a normal orientation and order assets by importance (BTS > USD > BTC > all later assets)

I know how design decisions go; you don't always think them through as well as you should, and then they're set in stone. But how BM ever thought this would be better is a complete mystery to me. This is probably the best evidence we have that "bytemaster is only human." :)
Title: Re: Do shorts fill below the price feed?
Post by: bytemaster on December 04, 2014, 12:24:22 am
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

And apparently the code is written in this backwards way! Thanks for the clarification. It took me half a minute after reading Markus's post to realize the code didn't have a huge bug.

It just doesn't make sense. It is one thing to say the price of BTS is X BitUSD. But saying the price of BTS is Y BitOil (in other words, the price of 1 BTS is Y barrels of light sweet crude oil) is just weird.

Not to mention that every single UIA market is "asset per dollar"... Apparently it was more logical to make USD the last reserved asset to maximize number of "correct" market orientations in backwards-land than it was to have a normal orientation and order assets by importance (BTS > USD > BTC > all later assets)

I know how design decisions go; you don't always think them through as well as you should, and then they're set in stone. But how BM ever thought this would be better is a complete mystery to me. This is probably the best evidence we have that "bytemaster is only human." :)

Well it happened because I coded everything as if the BitAsset were USD so that I could THINK in terms of USD and thus eliminate bugs caused by getting the order backwards all the time.  I picked a standard I could reason in and stuck with it. 

As far as the order of the assets I knew there was no "right way" and that we would have to let the user pick how they wanted to view it in the GUI.

Title: Re: Do shorts fill below the price feed?
Post by: biophil on December 05, 2014, 03:22:18 pm
Remember BM thinks backwards so actually it is

max(feed_price, ask_price)

And apparently the code is written in this backwards way! Thanks for the clarification. It took me half a minute after reading Markus's post to realize the code didn't have a huge bug.

It just doesn't make sense. It is one thing to say the price of BTS is X BitUSD. But saying the price of BTS is Y BitOil (in other words, the price of 1 BTS is Y barrels of light sweet crude oil) is just weird.

Not to mention that every single UIA market is "asset per dollar"... Apparently it was more logical to make USD the last reserved asset to maximize number of "correct" market orientations in backwards-land than it was to have a normal orientation and order assets by importance (BTS > USD > BTC > all later assets)

I know how design decisions go; you don't always think them through as well as you should, and then they're set in stone. But how BM ever thought this would be better is a complete mystery to me. This is probably the best evidence we have that "bytemaster is only human." :)

Well it happened because I coded everything as if the BitAsset were USD so that I could THINK in terms of USD and thus eliminate bugs caused by getting the order backwards all the time.  I picked a standard I could reason in and stuck with it. 

As far as the order of the assets I knew there was no "right way" and that we would have to let the user pick how they wanted to view it in the GUI.

Yeah, I get it. I'm not really complaining. Making choices like that is just part of the design process, and since you were the guy with the vision, you got to make the choices.

Sent from my SCH-S720C using Tapatalk 2