BitShares Forum

Main => General Discussion => Topic started by: botfund on October 15, 2015, 07:22:32 am

Title: API call to buy fixed amount of BTS?
Post by: botfund on October 15, 2015, 07:22:32 am
I noticed that there's only sell_asset on wallet_api. This is fine because I can sell USD for BTS if I want to buy BTS.
But the issue is when I want to buy BTS at best price, I can't accurately specify amount of BTS I want.
Say I want to buy 1000 BTS and the lowest ask price is [100,0.005]. I want to buy 1000 BTS with highest price 0.006. What I can do is to call
sell_asset xxx 6 USD 1000 BTS .....
Now it will buy 1000+ BTS with 6 USD. But my purpose is to buy 1000 BTS using USD <= 6. It's counter-intuitive and quite different with most exchanges.

Is my understanding wrong? If not, I strongly recommend to allow a way to specify what amount I want to be fixed (BTS or USD) or add a buy_asset API.
Title: Re: API call to buy fixed amount of BTS?
Post by: xeroc on October 15, 2015, 10:06:29 am
This documentation may help you:

http://docs.bitshares.eu/api/cli_wallet.html#grapheneclassgraphene_1_1wallet_1_1wallet__api_1aeb0d71a0ed4c6d05a003e48c3a0cb6d3
Title: Re: API call to buy fixed amount of BTS?
Post by: botfund on October 15, 2015, 10:25:16 am
This documentation may help you:

http://docs.bitshares.eu/api/cli_wallet.html#grapheneclassgraphene_1_1wallet_1_1wallet__api_1aeb0d71a0ed4c6d05a003e48c3a0cb6d3

Thanks for the reply and this confirms my understanding and I can't do things like "to buy 1000 BTS with best price". What I can do is "to buy as many BTS with 5 USD".

I think we need to add a feature so that I can do things like "to buy 1000 BTS with best price <= 0.006". We have 2 choices:
1. add buy_asset api call.
2. add a parameter in sell_asset to specify which asset amount should be fixed ( sell asset or receive asset).