The Deltastock Application Program Interface (API) ensures access to some of the most important applications of the trading platform Delta Trading. It can be used to connect the trading platform to automated trading systems. There are several requirements that you must meet before the API starts working. First, the software needs to be compatible with ActiveX component DSAPI_Client.exe and instancing of the DSAPI_Client.clientAPI. DSAPI_Client.exe is available in Delta Trading version 4.0.7 and higher

There are three basic types to enter the data:

Long - 32-bit (4-byte) integers, positive or negative;
Double - IEEE 64-bit (8-byte) numbers with floating decimal point;
String - Unicode character set, 2 bytes per character;

The Date type (8-byte) has to be converted 1:1 to Double type (8-byte). The DeltaStock server's datetime format is "dd.mm.yyyy hh:mm:ss"

The other requirement is the Delta Trading platform has to be started.


Client need to report to Deltastock AD that he wants to use the interface DSAPI_Client.

DSAPI_Client has all the following functions:

  1. CancelOrder - Cancels an order.
  2. CancelOrder_Async - Cancels an order using a filter.
  3. ClosePosition - Closes a position at market price.
  4. GetAccSum - Returns the available money from the account.
  5. GetAccSum_S - Returns the available money from the account.
  6. GetChartData - Exports data from charts for a given financial instrument.
  7. GetChartData_S - Exports data from charts for a given financial instrument.
  8. GetErrDescription - Returns a description of the error.
  9. GetUsedMargin - Returns the money, locked in margins for the current open positions.
  10. GetUsedMargin_S - Returns the money, locked in margins for the current open positions.
  11. GetFreeMargin - Returns the free money (not used for margin) from the account.
  12. GetFreeMargin_S - Returns the free money (not used for margin) from the account.
  13. GetOrdList_Async - Displays list of orders using a filter.
  14. GetOrdStatus - Displays order status.
  15. GetOrdStatus_S - Displays order status.
  16. GetPosition - Displays size and average price of a position.
  17. GetPosition_S - Displays size and average price of a position.
  18. GetPositionRes - Displays the current result of a position.
  19. GetPositionRes_S - Displays the current result of a position.
  20. GetPositionsRes - Displays the current result of all open positions.
  21. GetPositionsRes_S - Displays the current result of all open positions.
  22. GetQuote - Displays current market quotes (Bid, Ask, Hi, Low).
  23. GetQuote_S - Displays current market quotes (Bid, Ask, Hi, Low).
  24. GetTotalResult - Displays the total result of trading.
  25. GetTotalResult_S - Displays the total result of trading.
  26. NewOrder - Enters a new order.
  27. NewOrder_Async - Enters a new order using a filter.
  28. GetOrdParams - Displays the instrument ID, price, status and the type of an order - Buy/Sell.
  29. GetOrdParams_S - Displays the instrument ID, price, status and the type of an order - Buy/Sell.
  30. GetClnNum - Displays the client number.
  31. GetApiVersion - Displays the version of the Delta Trading API.
  32. GetDTVersion - Displays the version of the Delta Trading platform.
  33. GetParam - Displays the parameters on the result from a specified function.
  34. CreateClientAPI - Creates Delta Trading ClientAPI for the specified account.
  35. DestroyClientAPI - Turns off the Delta Trading ClientAPI.

Input financial instruments in DSAPI_Client API using their tickers.

Currencies (as of 14-JUN-2007):

AUD/CAD AUD/CHF AUD/JPY AUD/NZD AUD/USD
CAD/CHF CAD/JPY CHF/BGN CHF/JPY EUR/AUD
EUR/CAD EUR/CHF EUR/GBP EUR/JPY EUR/NOK
EUR/CAD EUR/CHF EUR/GBP EUR/JPY EUR/NOK
EUR/NZD EUR/RON EUR/SEK EUR/USD EUR/ZAR
GBP/AUD GBP/BGN GBP/CAD GBP/CHF GBP/JPY
GBP/NOK GBP/NZD GBP/USD GBP/ZAR NZD/CAD
NZD/CHF NZD/JPY NZD/USD USD/BGN USD/CAD
USD/CHF USD/DKK USD/JPY USD/NOK USD/RON
USD/RUB USD/SEK USD/TRY USD/ZAR

Stocks, indexes, gold, and oil can be accessed from the menu of the platform Delta Trading (Trading -> Instruments). Instruments that you want to use in DSAPI_Client API must be loaded in advance in the Delta Trading platform.

To refer to different Currencies (input: InCurrency) use their standard tickers:

AUD BGN CAD CHF EUR GBP JPY
NOK NZD RON RUB SEK ZAR USD

Description of DSAPI_Client functions

1. CancelOrder (OrdID As Long) As Long

Cancels an order.

Inputs: OrdID - # of the order you want to cancel.

Result:

If the displayed result equals OrdID, then the order has been cancelled.

If the displayed result is less than zero - an error occurred and the displayed result indicates the error's number. (see Error Table).

Example: CancelOrder (12345678) - 12345678 (order is cancelled).

CancelOrder (12345678) - (-8). Error: Market is closed

2. CancelOrder_ASync (OrdID As Long, RequestID As Long, errNumber As Long)

Places an order for Cancellation. You need to enter two different inputs because the filter is not synchronized (asynchronized processing). It displays two results - RequestID and errNumber, that is why these two must be set as variables.

RequestID - an Identification Number (ID) which is unique for the order in DSAPI_Client.clientAPI. This ID allows you to follow your order status.

errNumber - the number of the error that took place.

Inputs:

OrdID - the IN of the order that you want to cancel.

RequestID - unique number of the order in DSAPI_Client.clientAPI

errNumber - variable, which returns a description if an error occurrs (see Error Table).

Result:

RequestID - unique number of the order in DSAPI_Client.clientAPI

errNumber - returns error number (see Error Table).

Example: CancelOrder_ASync (12345678, RequestID1, errNumber1)

RequestID1 - 453628

errNumber1 - 0

...

Getting a result from the order is executed by the command: CancelOrderExecuted (RequestID As Long, OrdID As Long)

Instance_CancelOrderExecuted (RequestID As Long, OrdID As Long) - the order is cancelled by the command RequestID order number OrdID.

3. ClosePosition (Instrument As String) As Long

Closes position of the Instrument.

Input:

Instrument - currency cross code (Example: "EUR/USD")

Output:

1 - position is closed;

0 - no result;

if negative number (-1, -2, -3 etc.) - explaining the number of the error (see Error Table).

Example: ClosePosition("EUR/USD") - 1 (position is closed)

4. GetAccSum (InCurrency As String, errNumber As Long) as Double

Returns the current balance in the account of the specified currency, or it returns 0 if an error exists.

The error number is displayed by the command errNumber. It must be a variable defined in advance which is valued by the reference to the function GetAccSum.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR").

errNumber - variable, which displays the number of the error (see Error Table).

Example:

GetAccSum ("USD", errNumber1) - 2345.33 (in USD)

errNumber1 - 0; therefore there is no error.

5. GetAccSum_S (InCurrency As String)

Returns the current balance in the account of the specified currency, or it returns 0 if an error exists.

The error number is displayed by the command errNumber. It must be a variable defined in advance which is valued by the reference to the function GetAccSum.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR").

Example:

GetAccSum_S ("USD") - Result - RES2345.33 *ERR0*

GetParam("RES", Result) - Result 2345.33

GetParam("ERR", Result) - Result ErrorNumber - 0

6. GetChartData (Instrument As String, iTypeInter As String, fname As String, DateFrom As Double, DateTo As Double, errNumber As Long) As Long

Displays 0/1 - false/true exporting chart data to another file.

Inputs:

Instrument - instrument code

iTypeInter - time period:

"1" - 1 min. "5" - 5 min. "30" - 30 min. "60" - 1 hour
"4" - 4 hours "24" - 1 day "7" - 1 week "33" - 1 month


Fname - file name - example: C:\chart\eurusd5.txt (file path needs to be created in advance!);

DateFrom - Date (Not Datetime) marks the start of export period (converted in Double);

DateTo - Date (Not Datetime) marks the end of the export period (converted in Double);

errNumber - variable which displays the number of the error (see Error Table)

Example:

GetChartData("EUR/USD", "24", "C:\chart\eurusd5.txt", 234242.2246, 353535.666, errNumber1) - 1

errNumber1 - 0; therefore no error exists

The Result has been saved into a file with the following (.csv- comma delimited) pattern:
<date>, <open>, <hi>, <low>, <close>, <volume> crlf

7. GetChartData_S (Instrument As String, iTypeInter As String, fname As String, DateFrom As Double, DateTo As Double) As Long

Displays 0/1 - false/true exporting chart data to another file.

Inputs:

Instrument - instrument code

iTypeInter - time period:

"1" - 1 min. "5" - 5 min. "30" - 30 min. "60" - 1 hour
"4" - 4 hours "24" - 1 day "7" - 1 week "33" - 1 month


Fname - file name - example: C:\chart\eurusd5.txt (file path needs to be created in advance!);

DateFrom - Date (Not Datetime) marks the start of export period (converted in Double);

DateTo - Date (Not Datetime) marks the end of the export period (converted in Double);

errNumber - variable which displays the number of the error (see Error Table)

Example:

GetChartData_S("EUR/USD", "24", "C:\chart\eurusd5.txt", 234242.2246, 353535.666) – result RES1*ERR0

GetParam("RES", Result) = 1

GetParam("ERR", Result) = 0

The Result has been saved into a file with the following (.csv- comma delimited) pattern:
<date>, <open>, <hi>, <low>, <close>, <volume> crlf

8. GetErrDescription (ErrorNumber As Long) As String

Displays error description after an error number is entered.

Digit 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 < 1 or not a double format number.
-4 Unknown ordType 1-market; 2-limit; 3-stop; 4-OCO.
-5 Unknown ordBuySell 'B' - Buy / 'S' - Sell. Unknown ordBuySell '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 ordStatus_NOE <> 1, 2, 3, 4, 5. Order Status not Specified.
-19 DSAPI_Client.internalAPI Object not set.
-20 Unexpected Error: DSAPI_Client.internalAPI/NewOrderExecuted.
-21 Unexpected Error: DSAPI_Client.internalAPI/myApp2Events.RiseClientEvent.
-22 Operation's execution declined! DT-Client busy with another operation.
-23 Operation's execution declined by DT-Client! This Logical Order cannot close the position.
-24 Operation's execution declined by DT-Client! The requested price is not a valid market price.
-25 DT-Client 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 currently position of 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 with the required account has not been started..
-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.

Example: GetErrDescription (-10) - "-10 - CFD trading not authorized."

9. GetUsedMargin (InCurrency As String, errNumber As Long) As Double

Displays the money locked in margin.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR");

errNumber - 0 or negative number (see Error Table)

Example:

GetUsedMargin ("USD", errNumber) - 1403.34 USD

errNumber - 0

10. GetUsedMargin_S (InCurrency As String) As String

Displays the money locked in margin.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR");

Example:

GetUsedMargin ("USD") - Result - RES1403.34 *ERR0*

GetParam("RES", Result) - 1403.34

GetParam("ERR", Result) - 0

11. GetFreeMargin (InCurrency As String, errNumber As Long) as Double

Withdraws the free margin of the desired currency.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR")

errNumber - variable which displays the number of the error (see Error Table).

Example:

GetFreeMargin ("USD", errNumbe1) - 5431. 31 (in USD)

errNumbe1 - 0

12. GetFreeMargin_S (InCurrency As String)

Withdraws the free margin of the desired currency.

Inputs:

InCurrency - currency code (Example: InCurrency = "EUR")

Example:

GetFreeMargin_S("USD", errNumbe1) - Result - RES5431.31 *ERR0*

GetParam("RES", Result) - Result 34324.44 USD

GetParam("ERR", Result) - Result ErrorNumber - 0

13. GetOrdList_Async (Instrument As String, ordStatus As Long, ordType As Long, ordBuySell As String, ordDate1 As Double, ordDate2 As Double, RequestID As Long, errNumber As Long)

Displays list of orders after the data is filtered. Filter is asynchronized. It displays two values - RequestID and errNumber which is the reason for these two inputs to be set as variables in advance.

Inputs:

Instrument - Instrument cross code (Example: "EUR/USD");

ordStatus - order status 1 - ordered, 2 - confirmed, 3 - completed, 4 - cancelled, 5 - placed for cancellation;

ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - One-Cancels-Other (OCO);

ordBuySell - buy - 'B' or sell - 'S';

ordDate1 - Date; from:

ordDate2 - Date; To:

RequestID - unique ID of the order to DSAPI_Client.clientAPI;

errNumber - error number (see Error Table).

Result:

RequestID - unique ID of the order to DSAPI_Client.clientAPI

errNumber - variable which displays the error number (see Error Table)

Example:

GetOrdList_Async ("EUR/USD", 3, 2, "B", 01.05.2007, 30.05.2007, RequestID1, errNumber1)

RequestID1 - 242334

errNumber1 - 0

...

The result is displayed through the following message:

Instance_GetOrdListExecuted

(RequestID As Long, OrdID As Long, Instrument As String,
ordStatus As Long, ordType As Long, ordBuySell As String,
ordDate1 As Double, ordDate2 As Double, ordCount As Double,
ordPrice As Double, ordPrice1 As Double, errNumber As Long)

RequestID - ID of the order received in GetOrdList_Async;

OrdID - order ID;

Instrument - instrument cross code;

ordStatus - order status: 1 - ordered, 2 - confirmed, 3 - completed, 4 - canceled, 5 - asked to cancel;

ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - One-Cancels-Other (OCO);

ordBuySell - buy - 'B' or sell - 'S';

ordDate1 - date of order converted in Double (8-byte);

ordDate2 - date of last status change converted in Double (8-byte);

оrdCount - order quantity;

ordPrice - order price;

ordPrice1 - order price as asked;

errNumber - error number, (see Error Table), if there is an error, that means that there is data missing.

15. GetOrdStatus (OrdID As Long) As Long

Asks the serer about the order status.

Inputs:

OrdID - ID of the order which you aim to check.

Result:

1 - ordered, 2 - confirmed, 3 - completed, 4 - canceled, 5 - asked to cancel;

< 0 - error number (see Error Number).

Example: GetOrdStatus (12345678) - 3 (completed).

16. GetOrdStatus_S(OrdID As Long)

Asks the serer about the order status.

Inputs:

OrdID - ID of the order which you aim to check.

Result:

1 - ordered, 2 - confirmed, 3 - completed, 4 - canceled, 5 - asked to cancel;

< 0 - error number (see Error Number).

Example: GetOrdStatus_S (12345678) - 3 (completed).

17. GetPosition (Instrument As String, Count As Double, Price As Double, errNumber As Long)

Displays the current status of a position.

Inputs:

Instrument - instrument cross code (Example: "EUR/USD");

Count - variable which displays the quantity of the position using a reference;

Price - variable which displays the average price of the position using a reference;

errNumber - error number (see Error Table), if there is an error, that means that there is data missing from in the inputs.

Example:

GetPosition ("USD/JPY", "USD", errNumber1)

errNumber1 - 0

Result:

Count - quantity;

Price - price;

errNumber - error number.

18. GetPosition_S (Instrument As String) as String

Displays the current status of a position.

Inputs:

Instrument – instrument cross code (Example: "EUR/USD");

Example:

GetPosition_S ("USD/JPY")

Result: CNT1000*PR1.2567*ERR0

CNT – variable which displays the quantity of the position using a reference;

PR – variable which displays the average price of the position using a reference;

ERR – variable, which displays the number of the error (see Error Table).

GetParam("CNT", "CNT1000*PR1.2567*ERR0") - 1000

GetParam("PR", "CNT1000*PR1.2567*ERR0") - 1.2567

GetParam("ERR", "CNT1000*PR1.2567*ERR0") - 0

19. GetPositionRes (Instrument As String, InCurrency As String, errNumber As Long) As Double

Displays the result from open positions on the given instrument.

Inputs:

Instrument - instrument code (Example: InCurrency = "EUR/USD");c

InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR");

errNumber - displays the error number (see Error Table),

Result:

Result from open positions.

Example:

GetPositionRes ("EUR/USD", "EUR", errNumber1) - 34324.44 (in "EUR")

errNumber1 - 0

20. GetPositionRes_S (Instrument As String, InCurrency As String) As String

Displays the result from open positions on the given instrument.

Inputs:

Instrument - instrument code (Example: "EUR/USD");

InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR");

Result:

Result from open positions.

Example:

GetPositionRes_S ("EUR/USD", "EUR") - RES34324.44 *ERR0*

GetParam("RES", "RES34324.44 *ERR0*") - Result 34324.44 EUR

GetParam("ERR", "RES34324.44 *ERR0*") - Result ErrorNumber - 0

21. GetPositionsRes (InCurrency As String, errNumber As Long) As Double

Displays the total result from all the open positions.

Inputs:

InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR");

errNumber - displays the error number (see Error Table),

Result:

Result of all the open positions displayed in the given currency.

Example:

GetPositionRes ("EUR" , errNumber1) - 34114.44 (in "EUR")

errNumber1 - 0

22. GetPositionsRes_S (InCurrency As String) As String

Displays the total result from all the open positions.

Inputs

:

InCurrency - currency in which the result is calculated (Example: InCurrency = "EUR")

Result:

Result of all the open positions displayed in the given currency.

Example:

GetPositionsRes ("EUR") - Result RES34114.44*ERR0*

GetParam("RES", "RES34114.44*ERR0*") - Result 34114.44 EUR

GetParam("ERR", "RES34114.44*ERR0*") - Result ErrorNumber - 0

23. GetQuote (Instrument As String QBid As Double, QAsk As Double, QHi As Double, QLow As Double, errNumber As Long)

Displays the quote of the Instrument.

Inputs:

Instrument - instrument ticker code (Example: "EUR/USD")

QBid, QAsk, QHi, QLow, ErrNumber - Buy, sell, high, low, error. These inputs must be variables because the result is displayed after a reference to them.

Result:

QBid, QAsk, QHi, QLow, ErrNumber

Example:

GetQuote ("USD/GBP", QBid1, QAsk1, QHi1, QLow1, ErrNumber1)

QBid1 - 1.3681

QAsk1 - 1.3684

QHi1 - 1.3689

QLow1 - 1.3680

ErrNumber1 - 0

24. GetQuote_S (Instrument As String)

Displays the quote of the Instrument.

Inputs:

Instrument - instrument ticker code (Example: "EUR/USD")

Example:

GetQuote ("USD/GBP") - Result = BID1.3681*ASK1.3684*HI1.3689*LOW1.3680*ERR0*

GetParam("BID", Result) - 1.3681

GetParam("ASK", Result) - 1.3684

GetParam("HI", Result) - 1.3689

GetParam("LOW", Result) - 1.3680

GetParam("ERR", Result) - 0

25. GetTotalResult (InCurrency As String, errNumber As Long) As Double

Displays the total result of the specified currency.

Inputs:

InCurrency - currency (Example: InCurrency = "EUR");

errNumber - 0 or negative number (see Error Table).

Example:

GetTotalResult ("USD" , errNumber1) - 5307.23

errNumber1 - 0

26. GetTotalResult_S(InCurrency As String) As String

Displays the total result of the specified currency.

Inputs:

InCurrency - currency (Example: InCurrency = "EUR");

Example:

GetTotalResult ("USD") - Result - RES5307.23 *ERR0*

GetParam("RES", Result) - 5307.23

GetParam("ERR", Result) - 0

27. NewOrder (Instrument As String, ordCount As Long, ordPriceReq1 As Double, ordPriceReq2 As Double, ordType As Long, ordBuySell As String, ordValidity As String) As Long

Places a new order.

Inputs:

Instrument - instrument cross code (Example: "EUR/USD");

ordCount - quantity;

ordPriceReq1 - price;

ordPriceReq2 - price2 (concerning OCO orders);

ordType - order type: 1 - market, 2 - limit, 3 - stop, 4 - OCO;

ordBuySell - buy- 'B' or sell - 'S';

ordValidity - for the day - '1' until cancelled - '2'.

Result:

Displays OrdID - the order ID. If the result is a negative number, then an error exists.

Example:

NewOrder ("EUR/USD", 10000, 0, 0, 1, "B", 2) - market order buys 10 lots (10000) "EUR/USD" validity: until cancelled

NewOrder ("EUR/USD", 10000, 1.3680, 0, 2, "S", 2) - limit order sells 10 lots (10000) "EUR/USD" at 1.3680, validity: until cancelled

28. NewOrder_Async (Instrument As String, ordCount As Long, ordPriceReq1 As Double, ordPriceReq2 As Double, ordType As Long, ordBuySell As String, ordValidity As String, RequestID As Long, errNumber As Long)

Inputs:

Instrument - instrument cross code (Example: "EUR/USD");

ordCount - quantity;

ordPriceReq1 - price;

ordPriceReq2 - price2 (concerning OCO orders);

ordType - rder type: 1 - market, 2 - limit, 3 - stop, 4 - OCO;

ordBuySell - Buy - 'B' or Sell - 'S';

ordValidity - for the day - '1'; until cancelled - '2'.

Result:

RequestID As Long

If an error exists then the error number = ErrNumber.

Example:

NewOrder ("EUR/USD", 10000, 0, 0, 1, "B", 2) - Market price order buys 10 lots(10000) "EUR/USD" validity: until cancelled;

NewOrder ("EUR/USD", 10000, 1.3680, 0, 2, "S", 2) - limit sells 10 lots(10000) "EUR/USD" at 1.3680, validity: until cancelled.

...

The result is displayed through the following result:

Instance_NewOrder_Async (InstrDispCode As String, ordCount As Long, ordPriceReq1 As Double, ordPriceReq2 As Double, ordType As Long, ordBuySell As String, ordValidity As String, RequestID As Long, errNumber As Long)

29. GetOrdParams (OrdID As Long, errNumber As Long) As String

Displays the instrument ID, price, status and the type of an order - Buy/Sell.

Inputs:

OrdID - order number.

errNumber - 0 or negative number (see Error Table)

Example:

GetOrdParams("467298", errNumber)

Result - *IAUD/NZD*CNT1000*PR1.23424*ST3*BSB

GetParam("I", Result) - Instrument: AUD/NZD

GetParam("CNT", Result) - Quantity: 1000

GetParam("PR", Result) - Price: 1.23424

GetParam("ST", Result) - Status: 3

GetParam("BS", Result) - Buy/Sell: B

30. GetOrdParams_S(OrdID As Long) As String

Displays the instrument ID, price, status and the type of an order - Buy/Sell.

Inputs:

OrdID - order number.

Example:

GetOrdParams_S("467298", errNumber)

Result - *IAUD/NZD*CNT1000*PR1.23424*ST3*BSB*ERR0

GetParam("I", Result) - Instrument: AUD/NZD

GetParam("CNT", Result) - Quantity: 1000

GetParam("PR", Result) - Price: 1.23424

GetParam("ST", Result) - Status: 3

GetParam("BS", Result) - Buy/Sell: B

GetParam("ERR", Result) - Error: 0

31. GetClnNum() As String

Displays the client number.

Example:

GetClnNum() - Result - "000102310"

32. GetApiVersion() As String

Displays the version of the Delta Trading API.

Example:

GetApiVersion() - Result - "1.0.41"

33. GetDTVersion() As String

Displays the version of the Delta Trading platform.

Example:

GetDTVersion() - Result - "4.0.12"

34. GetParam(strKey as String, strExpr as String) As String

Displays the parameters on the result from a specified function.

Inputs:

strKey - index;

strExpr - result from a specified function.

Example:

GetParam("CNT", "*IAUD/NZD*CNT1000*PR1.23424*ST3*BSB*ERR0") - Result - 1000

35. CreateClientAPI(Optional ByVal strExtNumber As String = "") As Long

Creates Delta Trading ClientAPI for the specified account.

Inputs:

strExtNumber - client number.

Example:

CreateClientAPI() - If an error exists then the error number = ErrNumber.

CreateClientAPI("000123456") - If an error exists then the error number = ErrNumber.

36. DestroyClientAPI() As Long

Turns off the Delta Trading ClientAPI.


More examples.

Windows Script Host:

  1. Open Notepad.exe (Start/Programs/Accessories) or start Notepad.exe from the window Run (Start.Run);
  2. Enter the following test:
    2.1. If you want a 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.

    2.2 If you want 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 file as NewOrder.js - the extension .js is mandatory.

  3. To run the scripts above double-click on file name or run it from the window Run (Start/Run).

Microsoft Visual Basic 6.0

  1. Open a blank project Standart Exe;
  2. Under Name in "Project properties" enter NewOrder;
  3. Save the project;
  4. From the menuProject/References from the list Available References choose DSAPI_Clien;
  5. In the format code Form1 enter the following program code:
    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
  6. Push F5.

Microsoft VB.NET 2005

  1. Start a new project "File/New/Project...";
  2. From Project Type choose Visual Basic/Windows, and from "Tempaltes" choose "Windows Application". Under Name enter NewOrder, under "Location" choose where to save your project. Push OK;
  3. In "Solution Explorer - NewOrder" right-click at "NewOrder". From the flying menu choose "Add Reference…". From the list "COM" choose "DSAPI_Client";
  4. In the format code "Forma1.vb" enter the following code:
    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. Push F5.

Microsoft Visual C# 2005

  1. Start a new project "File/New/Project…";
  2. From "Project Type" choose "Visual C#/Windows", and from "Tempaltes" - "Windows Application". Under Name enter NewOrder, under "Location" choose where you want to save your project. Press OK;
  3. In "Solution Explorer - NewOrder" right-click at "NewOrder". From the flying menu choose "Add Reference…". From list "COM" choose "DSAPI_Client";
  4. In the format code "Forma1.cs" add the following code:
    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. Push F5.