Buy contract at market price
I can’t figure out how to buy a contract at market price.
If I enter price 0, all I get back is: "The underlying market has moved too much since you priced the contract. The contract price has changed from USD0.00 to USD1.00."
So I forward the price from the proposal, which are sent just moments before. This works most of the time, but not always. (See example)
{"echo_req":
{"price":"0.69912","buy":"52FEB85E-BB13-11E5-93ED-899A7C9236A4"},
"error":{"message":"The underlying market has moved too much since you priced the contract. The contract price has changed from USD0.70 to USD1.00.", "code":"PriceMoved"},"msg_type":"buy"}
I can enter a ridiculous number like 1000, and the trade gets through, but then I can’t read at what price I got in to the market.
I've written code to re-enter the order if it fails, but it seems counter-productive when the function is there.
Is price: 0 working for enter at market price?
Comments
We were getting the same issue. And we just pass "buy amount" in price field to buy a contract. Hope this issue gets addressed.
@unoj @bsbjai Thanks for reporting this, we will check and update you accordingly.
@raunak we have already gone live with the current buy API. It would be helpful if you could give us a one day notification before rolling out a fix for this.
Thanks.
@bsbjai Thank you for confirming this
@bsbjai we will fix for current market price, can you please provide details on how you have fixed it or patched it as of now. If we fix for current price it will not break anything in your case.
@raunak As @unoj mentioned, Buy API call works only when we pass some random values other than 0 in price field. So we are passing 50, 100 etc there.
@bsbjai Please note that you don't have to pass random values, when you stream proposal call (https://developers.binary.com/api/#proposal) then you get
ask_price
so you need to send latest price that you get from that.Why are you getting that error, let me explain:
for example if you get
ask_price
at say 15 seconds with value20
and you sendbuy
request with same price at 30 seconds and in between market has moved too much i.e the current market price at 30 seconds is 25 then you will get this errorThe underlying market has moved too much since you priced the contract
and its valid as well because you are trying to purchase contract with price that is not valid anymore.@Raunak We ended up passing random values after our unsuccessful attempts with passing 0 (buy at market price). Please note that, we are subscribing to proposal streams and checking the spot price real time and then making the buy API call, so its fine with us even if market moves within those 1-2 secs of initiating the buy call and getting the transaction done. In our scenario, we never wait for more than 2-3 secs.
@Raunak I send proposal, authorize and buy order in one socket connection, so time between proposal and buy order is more or less "instant" (I haven't timed it).
As in my example, I entered the ask_price from the proposal return (0.69912) to the PUT order, and within the time from proposal to buy the price got higher, So the order failed... However, just as @bsbjai said, my intention is to get in to the market as quickly as possible and if price moves a few pips it doesn't matter. (In regards to my example, I would have gotten a better price...)
So entering 1000 for example makes sure I get in to the market, my thought is that it's higher than the price of any currency pair/stock, so price "never" exceeds current price.
So if "0 Buy at market price" means: "Get the trade trough as quickly as possible..." It would be great if it worked.
@bsbjai Tell Zio that Daniel says hi...
@unoj Just did. Zio shared a screenshot couple of weeks before and told that you are working on setting up a system to replicate signals. Didn't know unoj is Daniel. I see that you are making good progress. Keep rocking!