DeltaStock - Global Forex and CFD Broker

Open a FREE Demo Account
Open a Live Account
Live HelpLive Help Language: English


Deltastock API Reference

The API can be used with Delta Trading versions 4.0.7 and higher

Deltastock API allows you to trade all the instruments offered by Deltastock, but appart from the currency pairs, any other instrument that will used with the API, should be added either to the CFD instrument list in the Delta Trading interface or through the function AddInstr(String Instrument).

A complete list of all trading instrument can be found on the following pages:

Method parameters can be of three basic types:

Long - 32 bit integers
Double - 64 bit floating point numbers
String - BSTRs;

Dates should be converted to doubles with the API function "ConvertDateToDouble" and then passed to the API functions. The format of the date to be passed to ConvertDateToDouble should be "dd.mm.yyyy hh:mm:ss"

Description of the API functions:

All functions with the "_S" suffix are to be used with scripting languages. Multiple parameters are returned in a single string, which then has to be parsed to obtain each individual value.

All functions with the "_Async" suffix are executed asynchronously.



DELTA TRADING
QUICK DEMO REGISTRATION
*
*
Password:*Repeat password:*
 
Country:*
Security Code:*
Enter Security Code:*



Error Description table

Error number Description
-1 The instrument code not found in DeltaTrading platform.
-2 Order's quantity must be positive number and divisible by 1000.
-3 ordPriceReq1/ordPriceReq2 the price is less than 0 or not a double
-4 Unknown order type - should be 1-market; 2-limit; 3-stop; 4-OCO.
-5 Wrong Buy/Sell parameter. Only 'B' - Buy / 'S' - Sell.
-6 Not available funds for the order's execution.
-7 Not available funds for the order's execution.
-8 Market is closed.
-9 Forex trading not authorized.
-10 CFD trading not authorized.
-11 Precious Metal trading not authorized.
-12 Commodity trading not authorized.
-13 DSAPI_Client Object not set.
-14 Unexpected Error: DSAPI_Client.ClientAPI/NewOrder.
-15 Unexpected Error: DSAPI_Client.ClientAPI/myApp1Events.RiseClientEvent.
-16 ReqID_NWE < 1 No Request ID.
-17 ordID_NOE < 1 No order ID.
-18 Wrong order status specified - should be 1, 2, 3, 4 or 5.
-19 DSAPI_Client.internalAPI Object not set.
-20 Unexpected Error: DSAPI_Client.internalAPI/NewOrderExecuted.
-21 Unexpected Error: DSAPI_Client.internalAPI/myApp2Events.RiseClientEvent.
-22 The operation can not be executed - the API is busy with another operation.
-23 The operation can not be executed by the API. The spesified Logical Order cannot close the position.
-24 The operation can not be executed - the requested price is not a valid market price.
-25 the API has placed the order for execution, but the order status not returned from the server.
-26 OCO order - The first price must be higher than the second price.
-27 Delta Trading can not execute the requested operation. Check the status of the operation.
-28 Unexpected Error: DSAPI_Client.internalAPI/GetCommonOper.
-29 Unknown currency symbol.
-30 Unexpected Error: DSAPI_Client.internalAPI/GetQuote.
-31 Unexpected Error: DeltaTrading/frmDSAPI/internalAPI_GetQuoteAPI.
-32 Unexpected Error: DeltaTrading/frmDSAPI/internalAPI_GetOrdStatusAPI.
-33 No open position on specified instrument.
-34 Wrong parameters.
-35 Order List Is Not Complete.
-36 Unexpected Error: DSAPI_Client.ClientAPI/SendMssg.
-37 Unexpected Error: DSAPI_Client.ClientAPI/GetPosition.
-38 Unexpected Error: DSAPI_Client.ClientAPI/GetOrdList_Async.
-39 Unexpected Error: DSAPI_Client.ClientAPI/ClosePosition.
-40 Unexpected Error: DSAPI_Client.ClientAPI/GetChartData.
-41 Unexpected Error: DSAPI_Client.ClientAPI/GetOrdStatus.
-42 Unexpected Error: DSAPI_Client.ClientAPI/GetOrdParams.
-43 Unexpected Error: DSAPI_Client.ClientAPI/GetAccNum.
-44 Unexpected Error: DSAPI_Client.ClientAPI/GetFreeMargin.
-45 Unexpected Error: DSAPI_Client.ClientAPI/GetUsedMargin.
-46 Unexpected Error: DSAPI_Client.ClientAPI/GetAccSum.
-47 Unexpected Error: DSAPI_Client.ClientAPI/GetPositionRes.
-48 Unexpected Error: DSAPI_Client.ClientAPI/GetQuote.
-49 Unexpected Error: DSAPI_Client.ClientAPI/GetPositionsRes..
-50 Unexpected Error: DSAPI_Client.ClientAPI/CancelOrder_ASync.
-51 Unexpected Error: DSAPI_Client.ClientAPI/CancelOrder.
-52 Unexpected Error: DSAPI_Client.ClientAPI/NewOrder_Async.
-53 Unexpected Error: DSAPI_Client.internalAPI/GetClnNumExecuted.
-54 Unexpected Error: DSAPI_Client.internalAPI/GetOrdParamsExecuted.
-55 Unexpected Error: DSAPI_Client.internalAPI/CancelOrderExecuted.
-56 Unexpected Error: DSAPI_Client.internalAPI/Error_DSAPI.
-57 Unexpected Error: DSAPI_Client.internalAPI/SetResValueExecuted.
-58 Unexpected Error: DSAPI_Client.internalAPI/GetPositionExecuted.
-59 Unexpected Error: DSAPI_Client.internalAPI/GetOrdListExecuted.
-240 Delta Trading has not been started with the specified account
-241 There is API connected to Delta Trading with the same account.
-242 Account number is not found in DSAPI_Client.exe.
-243 Unexpected Error: DSAPI_Client.internalAPI.

Examples

Windows Script Host:

  1. Use Notepad or any other text editor to enter the code.
    VBScript:
    dim o, retVal, err2
    Set o = CreateObject ("DSAPI_Client.clientAPI")
    err2 = o.CreateClientAPI()
    if err.Number = 0 and err2 <> 0 Then
        retVal = o.NewOrder("EUR/USD",1000,1.3444,0,1,"B","1")
        msgbox o.GetErrDescription(retval)
    else
        msgbox (cstr(err.number) & " " & err.Description)
    end if
    Save file as NewOrder.vbs - extension .vbs is mandatory.

    JScript:
    var obj;
    var retval;
    var retval1 = 0;
    try
    {
      obj = new ActiveXObject("DSAPI_Client.clientAPI");
      retval1 = obj.CreateClientAPI();
      retval = 0 + obj.NewOrder("EUR/USD",1000,1.3444,0,1,"B","1");
      if (retval > 0)
      {
       WScript.Echo("The order ID is " + retval);
      }
      else
      {
       WScript.Echo("Execution fail. " + obj.GetErrDescription(retval));
      };
    }
    catch(e)
    {
       WScript.Echo("Object not set." + e.description);
    }

    Save the file as NewOrder.js - the extension .js is mandatory.

  2. To run the script double-click on the file or run it from the Windows Start/Run menu.

Microsoft Visual Basic 6.0

  1. Open a blank project "Standart Exe";
  2. Save the project as "NewOrder";
  3. Go to Project/References and from the list of Available References select DSAPI_Client;
  4. Add the following code in Form1
    Dim obj As New DSAPI_Client.clientAPI
    Private Sub Form_Load()
       Dim retval As Long, err2 as Long
       err2 = o.CreateClientAPI()
       On Error Resume Next
       retval = obj.NewOrder("EUR/USD", 1000, 1.3444, 0, 1, "B", "1")
       If retval > 0 Then
          MsgBox "The order ID is " & CStr(retval)
       Else
          MsgBox "Execution fail. " & obj.GetErrDescription(retval)
       End If
    End Sub
  5. Press F5.

Microsoft VB.NET 2005

  1. Start a new project from "File/New/Project...";
  2. Choose Visual Basic/Windows as Project Type, and from "Templates" choose "Windows Application". Enter "NewOrder" as a name for your project and save it. Press OK;
  3. Go to "Solution Explorer - NewOrder". Right-click on "NewOrder" and select "Add Reference". and from the available COM objects list choose "DSAPI_Client";
  4. Enter the following code in "Form1.vb" :
    Public Class Form1
    Private Sub Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim obj As New DSAPI_Client.clientAPI
      Dim retval As Long, err2 As Long = 0
       err2 = o.CreateClientAPI()
      retval = obj.NewOrder("EUR/USD", 10000, 0, 0, 1, "B", "1")
      If retval > 0 Then
        MsgBox("The order ID is " & CStr(retval))
      Else
        MsgBox("Execution fail. " & CStr(obj.GetErrDescription(retval)))
      End If
    End Sub
    End Class
  5. Press F5.

Microsoft Visual C# 2005

  1. Start a new project from "File/New/Project";
  2. Select "Visual C#/Windows" as project type and from "Templates" - "Windows Application". Enter "NewOrder," as a name of the project and save it. Press OK;
  3. In "Solution Explorer - NewOrder" right-click on "NewOrder" and select "Add Reference". From the available COM objects choose "DSAPI_Client";
  4. Add the following code in "Form1.cs"
    namespace NewOrder
    {
      public partial class Form1 : Form
      {
        public Form1()
        {
         InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        DSAPI_Client.clientAPI obj = new DSAPI_Client.clientAPI();
        int retval = 0;
        retval = 0 + obj.NewOrder("EUR/USD",1000,1.3444,0,1,"B","1");
         if (retval > 0)
         {
          MessageBox.Show("The order ID is " + retval.ToString());
         }
         else
         {
          MessageBox.Show("Execution fail. " + obj.GetErrDescription(retval));
         };
        }
      }
    }
  5. Press F5.