ArjunVachhani / order-matcher

simple, fast and feature rich order matching engine supports limit, market, stop-loss, iceberg, IOC, FOK, GTD orders
MIT License
137 stars 70 forks source link

possibility of price in market sell #28

Closed omidmoradzadeh closed 3 years ago

omidmoradzadeh commented 3 years ago

Hi Is it possible to define only the requested price in the market sell ( not with asset count)?

for example :

{ "Price": 2005 }

ArjunVachhani commented 3 years ago

Price is the amount seller is willing to accept for one unit. Market orders are orders which instruct to sell/buy at any price for requested quantity. If you don't want to sell at lower then certain limit then you should use limit order. For example if you want to sell 10 shares for price upward of $125 then you should place limit order. Price should be $125 and quantity should be 10. if you want to sell 10 shares at any price right now then you should place market order. In case of market order, price must be 0 and quantity should be 10.

omidmoradzadeh commented 3 years ago

Thanks for your guidance, but my problem is with buy/sell in market method not limit orders. For example, if I want to sell all my assets in the market method, the system must calculate my assets based on the crypto. On the other, if I want to buy some asset in the market method the system must calculate my assets based on the fiat.

But in both cases, the system calculates based on crypto Which is right for the selling and no problem, but the problem is with buying.

To illustrate, if I want to buy 10,000 USD of BTC and the price is no matter,I will use the market buying method and fill the box of amount 10,000 USD and the system will fill 10,000 USD based on the seller orderbook.

I sent you some pictures that related Binance buy/sell in market method:

photo_2021-08-24_20-14-06 photo_2021-08-24_20-14-11

ArjunVachhani commented 3 years ago

Binance supports specifying Quantity(in BTC) and Total(in USD) in case of market buying and selling.

We support

  1. Quantity(in BTC) for market buy and sell
  2. Total(in USD, we call it OrderAmount) for market buy. check https://github.com/ArjunVachhani/order-matcher/wiki/2.-Order#orderamount
ArjunVachhani commented 3 years ago

Market sell specifying just amount(in USD) is not supported at the moment. but you could calculate USD amount from using buyer side quantity * rate. before placing order you could set quantity accordingly.