viabtc / viabtc_exchange_server

A trading engine with high-speed performance and real-time notification
MIT License
2.68k stars 1.48k forks source link

execute_limit_ask_order 成交价格取高的? #176

Closed lealife closed 5 years ago

lealife commented 5 years ago

https://github.com/viabtc/viabtc_exchange_server/blob/b720f56b3176142e6c39f4fb8d56a514de215819/matchengine/me_market.c#L364-L385

execute_limit_ask_order 的taker是卖, maker是买

        // 卖价>买价, 则撮合失败
        if (mpd_cmp(taker->price, maker->price, &mpd_ctx) > 0) {
            break;
        }

        // 到这里, 肯定是 卖价 <= 买价
        // 最终价格以买价为主, 即选了高的价格, 比如卖价10块, 买价11块, 结果选了买价11块的
        mpd_copy(price, maker->price, &mpd_ctx);

比如卖价10块, 买价11块, 结果成交价是11块, 不应该是10块吗?

objectt commented 5 years ago

what is your question?

lealife commented 5 years ago

@objectt 比如卖价10块, 买价11块, 结果成交价是11块, 不应该是10块吗?

objectt commented 5 years ago

When you "sell"(taker), your order is matched with the highest "buying" price(maker).

lealife commented 5 years ago

Even the seller price is less than the buyer price? And choose the buyer price which is greater than seller price as the deal price ?

objectt commented 5 years ago

@lealife Yes, that is correct. It chooses the "BEST" price. (Lowest price when buying; Highest price when selling)

lealife commented 5 years ago

Got it!