SPRINT API with EXCEL

4 posts / 0 new
Last post
PascalSonia
SPRINT API with EXCEL

Hi everybody,

I try to set a SPRINT with the following parameters:
epic = CS.D.EURUSD.CFD.IP
expiryPeriod = ONE_MINUTE
direction = BUY
size = 100

The result is: errorCode - error.sprintmarket.create-position.failure

I set my VBA code at the end of this post but do you have the same problem ?
And... do you have solution ?

Thank

I create the following code for SprintMarket.
' Create sprint position API
'-----------------------------------------------------
Public Function createSprintMarketPosition(SEpic As String, Direction As String, size As String, period As String) As String
' Parameters
Dim requestBodyDictionary As Dictionary
Set requestBodyDictionary = New Dictionary
Call requestBodyDictionary.Add("epic", SEpic)
Call requestBodyDictionary.Add("expiryPeriod", period)
Call requestBodyDictionary.Add("direction", Direction)
Call requestBodyDictionary.Add("size", size)
Dim requestBodyString As Variant
requestBodyString = JSON.toString(requestBodyDictionary)
' Header
Call oXMLHTTP.Open("POST", IG_API_HOST + "/positions/sprintmarkets", False)
Call oXMLHTTP.SetRequestHeader("X-SECURITY-TOKEN", m_accountToken)
Call oXMLHTTP.SetRequestHeader("CST", m_clientToken)
Call oXMLHTTP.SetRequestHeader("X-IG-API-KEY", m_apiKey)
Call oXMLHTTP.SetRequestHeader("Content-Type", "application/json; charset=utf-8")
Call oXMLHTTP.SetRequestHeader("Accept", "application/json; charset=utf-8")
Call oXMLHTTP.send(requestBodyString)
Dim Data As Dictionary
Set Data = JSON.parse(oXMLHTTP.responseText)
' Result correct
If oXMLHTTP.Status = 200 Then
createSprintMarketPosition = Data.Item("dealReference")
' Result error
Else
[APIMsg] = "createSprint: " & Data.Item("errorCode")
[APIMsg].WrapText = False
createSprintMarketPosition = ""
End If
End Function

PascalSonia
Why ?

It's good with the following epic code : FM.D.EURUSD24.EURUSD24.IP

Why this code ?

Chris
SPRINT API with EXCEL

Hi PascalSonia,

CS.D.EURUSD.CFD.IP is not a sprint market epic, which is why you are encountering this error. All our sprint market EPICs begin with "FM."

Chris

PascalSonia
Ok, that's good Thank Chris

Ok, that's good

Thank Chris

Log in or register to post comments