Вход DTWebВход DTWeb Live HelpLive Help       Език: Български




Функции на Delta Trading API

Delta Trading API е съвместим с версията 4.0.7 на платформата Delta Trading и всички други версии след нея.

Delta Trading API позволява търговия с всички инструменти, предлагани от Делтасток. С изключение на валутните двойки, другите инструменти, с които искате да търгувате през API трябва да бъдат добавени в списъка с ДЗР инструменти в интерфейса на платформата Delta Trading или чрез функцията AddInstr(String Instrument).

Пълен списък с инструментите за търговия, можете да намерите на следните страници:

За представяне на данните се използват само три основни типа:

Long – 32-bit (4-byte) цели числа със знак (+/–);
Double – 64-bit (8-byte) числа със плаваща запетая;
String – BSTRs.

Датите трябва да бъдат конвертирани към тип double с функцията на API "ConvertDateToDouble" и след това да бъдат подадени към функциите на API. Преди да се подадат към ConvertDateToDouble те трябва да се приведат във формат "dd.mm.yyyy hh:mm:ss"

Описание на функциите на Delta Trading API:

Всички функции с наставка "_S" се използват с езици за създаване на скриптове. Когато една такава функция трябва да върне като резултат повече от една стойност, тя ги капсулира в стринг, който след това трябва да бъде разделен, за да се получат отделните стойности.

Всички функции с наставка "_Async" се изпълняват асинхронно.




DELTA TRADING
Форма за бърза регистрация
*
*
Парола:*Повторете паролата:*
 
Държава:*
Защитен код:*
Въведете кода:*



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.