Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: market engine: execute rule about short order  (Read 238 times)

Offline alt

market engine: execute rule about short order
« on: December 03, 2014, 04:57:00 AM »

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 »

Offline Markus

  • Sr. Member
  • ****
  • Posts: 366
    • View Profile
Re: market engine: execute rule about short order
« Reply #1 on: December 03, 2014, 07:18:10 AM »
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

Re: market engine: execute rule about short order
« Reply #2 on: December 03, 2014, 10:44:30 AM »
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
Re: market engine: execute rule about short order
« Reply #3 on: December 03, 2014, 11:59:19 AM »
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

Re: market engine: execute rule about short order
« Reply #4 on: December 03, 2014, 01:07:27 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 );
                }
            }

 

Google+