API portfolio empty?
Hello.
I am developing a desktop trader bot for a client. I need the same functionality as in the web interface - exactly 1:1, but achieved through the API.
To the best of my understanding, the website is all about buying available contracts but the web interface is a set of options built on the fly on the available contracts that are hidden from the user - so one selects the set of options and the platform decides on which contract should be purchased.
Unfortunately, I am unable to find a good explanation on how this works in details - so it will be great if there is one. As inconvenient as this is it's not the problem - it can be figured out, and I think I've developed a quite good understanding of the process after some effort and frustration.
The only function I see to buy a contract is "Buy Contract" that needs contract ID that can be retrieved from "Price Proposal" that is used to retrieve the actual price for values within the contract boundaries, which id is retrieved by the "Portfolio" function which returns an empty array for contracts in my case.
{
"echo_req": {
"portfolio": 1
},
"msg_type": "portfolio",
"portfolio": {
"contracts": [
]
}
}
Also, by calling "Price Proposal - open contract" without contract id that supposedly should return all available contracts it returns none.
{
"echo_req": {
"proposal_open_contract": 1,
"subscribe": 1
},
"msg_type": "proposal_open_contract",
"proposal_open_contract": {}
}
So why is that?
Also, why the API doesn't facilitate the functionality of the website or am I missing something?
Comments
Hi,
portfolio
lists anything that you've bought which has not yet either expired or been sold.proposal_open_contract
is similar: it streams prices for any contracts that are not yet expired, and this is typically used to monitor the price for cases where you want to sell back early.The
buy
call can be specified with either a contract ID (you'd get this from theproposal
call), or with parameters. Typically you'd make aproposal
call to stream prices, then buy with an ID returned from one of those responses.If you're looking for available contract parameters, try these calls:
Also, note that here is JS source code for the websocket API available here:
https://github.com/binary-com/binary-live-api
and this is what we use for the main website, so it should be a good starting point for a desktop port. The HTML and other static pages are available from https://github.com/binary-com/binary-static