Jump to content

ItsPeter

Members
  • Posts

    2
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ItsPeter's Achievements

New Contributor

New Contributor (1/10)

0

Reputation

  1. Hi, I figured it out, here's the code for BUY position if anyone else struggles with the same problem, amend values relevant to your open positions: $data = '{ "dealId": "'.$deal_id.'", "epic": null, "expiry": null, "direction": "SELL", "size": "'.$size.'", "level": null, "orderType": "MARKET", "timeInForce": "FILL_OR_KILL", "quoteId": null }'; $url_requests = 'https://demo-api.ig.com/gateway/deal/'; $connection_url = $url_requests.'///positions/otc'; $ch = curl_init($connection_url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_HTTPHEADER, array( '_method: DELETE', 'Content-Type: application/json; charset=UTF-8', 'Accept: application/json; charset=UTF-8', 'X-IG-API-KEY: '.$key.'', 'Version: 1', "Authorization: Bearer $access_token", 'IG-ACCOUNT-ID: '.$account_id.'', )); $tokens = curl_exec($ch);
  2. Hi. I'm trying to figure out how to close the order via API on my demo account and I'm stuck. From what I was able to research, I have to use "_method: DELETE" header with POST, but doing so results with no response at all or invalid.request.format.line-2.column-51, depending on the approach. Here's the cURL part of the code: No response: $ch = curl_init($connection_url); curl_setopt($ch,CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=UTF-8', 'Accept: application/json; charset=UTF-8', 'X-IG-API-KEY: '.$key.'', 'Version: 1', 'Authorization: Bearer '.$access_token.'', 'IG-ACCOUNT-ID: '.$account_id.'', '_method: DELETE' )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $tokens = curl_exec($ch); 'Invalid request' response: $ch = curl_init($connection_url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=UTF-8', 'Accept: application/json; charset=UTF-8', 'X-IG-API-KEY: '.$key.'', 'Version: 1', "Authorization: Bearer $access_token", 'IG-ACCOUNT-ID: '.$account_id.'', '_method: DELETE', )); $tokens = curl_exec($ch); Any help would be greatly appreciated.
×
×
  • Create New...
us