Author Topic: market engine: execute rule about short order  (Read 1589 times)

0 Members and 1 Guest are viewing this topic.

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
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 );
                }
            }

Offline Markus

  • Sr. Member
  • ****
  • Posts: 366
    • View Profile
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!
« Last Edit: December 03, 2014, 12:03:11 pm by Markus »

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
sorry, bid order is c1,c2.
from the source code,when c1 is less than feed price, short order will execute first.
and short order is sort by interest rate.
so b2 is the first order to execute

来自我的 HUAWEI P7-L00 上的 Tapatalk


Offline Markus

  • Sr. Member
  • ****
  • Posts: 366
    • View Profile
Why would b2 get executed at all? Its limit is below the feed.
Also it's a bit confusing that a1 refers to two different orders :)
« Last Edit: December 03, 2014, 07:27:18 am by Markus »

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
let's assume current feed price is 0.02USD/BTS
the ask order:
a1. 0.019
a2. 0.02
....

the short order:
b1. interest 10%, limit 0.025
b2. interest 30%, limit 0.019

the bid order:
c1. 0.0195
c2. 0.018

which two orders will execute first?
from the source code, looks like a1 match b2 first, am I wrong?
« Last Edit: December 03, 2014, 01:03:57 pm by alt »