Directa SIM's Trading API allows your trading application to easily connect to the dAPI (Directa's Application Programming Interface)

Introduction

Abstract

This page is meant to make possible to anyone who wants to plug-in personally developed or third party software into the information flow, and the trading systems of Directa S.I.M.p.A. The services are essentially three:

  • API

    The method used is the typical one of the server socket, that is the connection to a port via the own local host (127.0.0.1). Three channels are available:

    PORT SERVICE
    10001 DATAFEED connection
    10002 TRADING connection
    10003 HISTORICAL CALLS connection

    To have the sockets receiving, it is necessary to open Darwin and to be enabled to the Prices Service.
    In the TUTORIAL section an example is available to test the connection directly from the command line, and connection examples using different programming languages. Each service has its own commands that will generate one or more answers. In the COMMON FUNCTIONALITIES section the available uses are specified.
    The commands must be used in the way described in the examples below, punctuation and spaces must be taken into account, if the command syntax is incorrect, an error message will be generated; in this section all the errors are listed. To access the TRADING, this service has to be enabled.


  • PROXIMITY

    It is in structuring phase the offer to the retail customers to run their own or third parties' software in proximity, that is within the network of the same infrastructure in which Directa's servers connected to markets are located.This service is subject to legal and technical compliance assessments, made to make sure the respect of the current regulations;its cost and timing can greatly vary, depending on the user requests.
    Note that, apart from the significant advantage of cutting the internet times in the round trip owing to the distance between the server and the user location, this arrangement does not provide an alternative channel and/or a preferential one in the order placement. For further information about this option, please refer to the contacts below:

    011 53.01.01



  • DARWIN TILE

    It is in structuring phase the possibility to create a Darwin tile. The user, according to his own system, can interact with the current Darwin interface. For further information on this option, please refer to the contacts below:

    011 53.01.01



Terms of Service

Acceptance of the Darwin API service policy

As usual, Directa asks people interested in implementing external programs to comply with certain rules and to sign an agreement to use the APIs and other related tools.

Preliminary Information

How to access Darwin's API service

The service is free of charge for TRADING while subject to a monthly fee of € 20 for DATAFEED. The service is controlled by Directa. For qualifications it is necessary to switch from the account on the "Scoreboard" page and click on info> 5a> 3h.

Available services

  • Documentation – The programmer is enabled to reach a wiki website containing the technical API's documentation. For now he is not allowed to modify the contents of this page; this possibility will be considered only for future website updates or for specific needs.

The test account

The current regulations do not allow in any circumstances the access to the services provided
by the Exchange Markets without the appropriate credentials,
and without agreeing to comply with some, very precise, disciplinary norms.
This is why Directa provides no trial account for the purpose of developing external applications:
it is necessary, first of all, that the programmer interested in using the interfaces and Darwin's API
to have a regular account number at Directa.

Developed programs' distribution

As mentioned above, the redistribution of the software developed through the APIs must be explicitly approved by Directa. Directa doesn't aim to take any economic advantage in the distribution of plugins and programs developed by thirds, but of course it cannot allow that a third party's software to make Darwin or its servers services inefficient or unsafe, for both the plugin end-users themselves and the other customers. Technical or commercial collaboration may also emerge from the agreement between Directa and the developer, which must be assessed from time to time on case-by-case basis.

Project progress status

Price flow receiving

Service currently available

An external program can be connected to a specific local IP port of Darwin. By giving the appropriate subscription commands for the desired financial instruments, it will be possible to obtain from the program the realtime prices' data.


Orders' placement

Service available on the operating server

Darwin allows an external program to reach a second local IP port, different from the one reserved to the prices' flow, through which the program can transfer operational instructions to Directa servers (order, order modification, order cancellation) and receive related information (availability, portfolio, etc.).


Darwin tile creation

An under development service The programmer can create their own plug-ins for Darwin (which may become a tile in the platform, integrated with Darwin workspaces and other existing tiles), by using the instructions for the Darwin's API and the development kit, as supplied by Directa. The development kit and the instructions will be available as soon as possible.


How it works

The Prices Service plugin allows the user to export data from Darwin. The method used is the typical one of the server socket pending on one or more ports of the local host (localhost or 127.0.0.1, according to the operative system) of one or more TCP/IP connections from the client.
The messages, both for the subscription (client-->Darwin) and for the reception (Darwin-->client) are in string format (UTF-8) and end with the NEWLINE character (depending on the operating system).
In order to send/receive messages it is enough to use, respectively, a writeline or a readline (an instruction available in the most programming languages).
The plugin subscribes automatically on the Darwin system to the securities requested; in case of subscribing to the same security more than once, an error message would be received; analogously, an error occurs when trying to unsubscribed from a security that was not subscribed to before.
The maximum number of subscribable securities is the one set forth by Darwin platform.

Plugin launch

If the user is enabled to the plug-in, the service is automatically started together with the Darwin platform; otherwise, the service is not available. The service opens two sockets TCP/IP (one for the information and the other for the trading) ?Listening? on the set ports (by default 10001 and 10002 respectively) and waits for the messages from the client.
It is possible to open more than one connection on the same socket. The plugin will automatically manage the forwarding of the messages to the client that requested them.

HeartBeat signal management

The heartbeat is used to keep the connection active. In fact, in presence of poor quality connections, the socket may close unexpectedly.
In order to avoid this behaviour the prices' service sends and receives an "Heartbeat" packet composed of the character H (Ascii code 72).
Of course implementing the dispatch of the heartbat to Darwin is taken care of by the developer. The prices' service automatically sends the heartbeat every 10 seconds.
Heartbeat messages format:
H\NEWLINE

Management Closing Darwin via API

It 'provides a command to close the Darwin directly through an API command.
The command over to close the Darwin without having to interact with the graphic interface of Darwin or possibly by killing the process, it also guarantees the rescue of their desk Darwin. The command is available in all three socket connections (datafeed, trading and historical calls) The following operation:

Command: CLOSEDARWIN
the answer before the start of the closing process will be as follows:
RUN close Darwin : save(true)
The save(true) It indicates that the desk will be saved.

If you do not want to save the desk of Darwin you can be closed in this way:
CLOSEDARWIN FALSE
the answer will be this:
RUN close Darwin : save(false)
The closing process is the same but it will not be taken into account changes to Darwin's desk.

Darwin connection DataFeed and Trading

The connection to the prices and the trading is conditioned by our server, so it is important to specify that the every day about midnight the Darwin active will automatically disconesse , this is necessary because of the daily work on our servers.
This implies that the Darwin does not allow a H24 use but which must be restarted once a day by referring to the disconnection of midnight, in this schedule can memorize options it useful to make systems that use dGO so that they can schedule of auto reconnection with scripts.

Informative commands to the server

It's possible to request the prices' service information about the portfolio situation, by running some specific commands on the trading channel.
<ACTION CODE>\n
The possible values for <ACTION CODE> are the following:

CODE FLOW ACTION
INFOSTOCKS TRADING List of stocks in the portfolio and in negotiation
INFOAVAILABILITY TRADING Situation of the availability in the portfolio
DARWINSTATUS ALL Returns information about version and connection status
GETPOSITION TRADING Returns information about the position of a single segurity in the same format as the INFOSTOCKS command
INFOACCOUNT TRADING Returns information about the asset balance of the account
ORDERLIST TRADING Returns the orders list (all)
TABLELIST ALL Restituisce le tabelle impostate sul proprio conto
TABLE ALL Restituisce l'elenco dei tickers presenti in una determinata tabella

For example: Command: GETPOSITION FCA to be used in the way specified in the example: <comando> _space_ <ticker>.

Command: ORDERLIST
When you need to see the list of your orders, it is necessary to send to the system a command like:
ORDERLIST \n

After Finding out that the order list can become very bushy, due to the operations that can be carried out, we have created some commands that allow access to filtered orders lists. The two new commands available are:

ORDERLISTNOREV - the list includes only the pending and executed orders
ORDERLISTPENDING - the list includes only the pending orders, cancelled and executed orders will be discarded

NB part of the reason for creating these commands is that, we've decided not to weigh down further on the initial connection to the trading system, and therefore, if the order list is greater than or equal to 100, the order list will be equivalent to the ORDERLISTNOREV command, so, you will have, as an initial detail: the executed orders, and any pending orders, if there were no pending or executed orders, but the list of the cancelled orders exceeds 100. then an error code 1019 will be sent, even though the list is not actually empty. needless to say that,the possibility to check with the native ORDERLIST command, including all orders is always guaranteed.
This management of the 100 limit is workig only upon the connection to the Trading socket.
The orders response details are discussed in the next section.

Messages format to the Client

The prices' service sends to the client the informative messages on the trading socket in the form of a string, and, ending with the NEWLINE (ASCII 10 \n) character.
The general format of the message is the following: <MESSAGE_TYPE> ; <TICKER> ; <TIME HH:MM:SS>;<DATA...> \n
The possible values for <MESSAGE TYPE> are the following:

CODE FLOW MEANING
STOCK TRADING Information about the portfolio (owned stocks and in negotiation)
AVAILABILITY TRADING Portfolio availability (with and without leverage)
DARWIN_STATUS ALL String with information about the connection and the version
INFOACCOUNT TRADING Information about the account status
ORDER TRADING Orders list
The <DATA> field assumes different values depending on the transmitted information.

STOCK message format
STOCK; <TICKER> ; <ORA HH:MM:SS> ; <QUANTITY IN PORTFOLIO> ; <DIRECTA QUANTITY> ; <TRADING QUANTITY> ; <AVERAGE PRICE> ; <GAIN<\n
STOCK record example for the A2A security( 4 Stocks in portfolio and 4 Trading stocks):
STOCK;A2A;10:40:58;4;0;4;1.2375;-1;-1\n

NB: The STOCK data flow is triggered by the commands:

  • INFOSTOCKS - returns with the entire list of shares in portfolio and those in negotiation
  • GetPosition ticker - returns information about the position of a single security in the same format like the INFOSTOCKS' command
NB: Indication of the field <TRADING QUANTITY>
The details could have different response types:

  • STOCK; FCA; 09: 54: 38; 0; 1; 1>; 0.0 ;
  • When the details appear  <val> > means that the order has been taken over by Directa, and you may notice that the amount details in Directa evaluate to 1 ( highlighted in the record with blue color).

  • STOCK; FCA; 09: 54: 41; 0; 0; 1; 0.0 ;
  • In this following detail, it could be noticed that the > is no longer present, which means that the order has been taken over by the Stock Exchange and the quantity details at Directa has returned to be 0 (signaled in the records with the color blue).

  • STOCK; FCA; 10: 03: 16; 0; 1; 1> 1; 0.0 ;
  • In this example, you can notice both a detail > along with a detail , this means that an order is already trading in the exchange while another is still at Directa as pointed out in the detail>.

  • STOCK; FCA; 10: 03: 18; 0; 0; 2; 0.0 ;
  • In this example, it could be seen how the signal > has disappeared and the number of orders has increased because there are two orders, In this example for the FCA Stock, at the stock exchange.

  • Following a withdrawal (eg REVORD <ID_ORD>) -> STOCK; FCA; 10: 09: 15; 0; 0; 1; 0.0 ;
  • You can notice how the amount details in negotiation has decreased by one unit following a cancellation of a security.

  • Trading quantity is equal to 0 *
  • This can occur when, while having a stocke in portfolio, you place a stop condition on both purchase and sale of the same instrument, * the detail is to indicate that, it's not a real zero, but a zero conditioned by other operations.

AVAILABILITY message format AVAILABILITY; <TIME HH:MM:SS> ; <STOCKS AVAILABILITY> ; <STOCKS AVAILABILITY WITH LEVERAGE> ; <DERIVATIVES AVAILABILITY> ; <DERIVATIVES AVAILABILITY WITH LEVERAGE> ; <TOTAL LIQUIDITY>\n
Example of the AVAILABILITY record:
AVAILABILITY;14:47:04;1000;5000:0;0;5000\n

DARWIN_STATUS message format
DARWIN_STATUS; <CONNECTION STATUS>;<enable datafeed> ;<RELEASE>\n

Possible values ​​for DATAFEED ENABLING:
VALUE MEANING
TRUE user enabled for datafeed
FALSE user not enabled for datafeed

Possible values for CONNECTION STATUS:
CODE MEANING
CONN_UNAVAILABLE Unavailable connection
CONN_SLOW Slow connection
CONN_OK Available connection
CONN_TROUBLE Connection with troubles

Example of the DARWIN_STATUS record:
DARWIN_STATUS;CONN_OK;TRUE;Release 1.2.1 build 01/08/2020 14:10:00 more info at http://app1.directatrading.com/trading-api-directa/index.html

INFOACCOUNT message format
INFOACCOUNT; <TIME HH:MM:SS> ; <DIRECTA ACCOUNT CODE> ; <LIQUIDITY> ; <GAIN EURO> ; <OPEN PROFIT/LOSS>\n
Example of the INFOACCOUNT record for the stock Fiat (10 stocks in the portfolio and 10 actions in negotiation):
INFOACCOUNT;12:49:11;40000;150000;1200;430

ORDER message format - ORDERLIST command
ORDER;<TICKER> ; <TIME HH:MM:SS> ; <ORDER ID> ; <OPERATION TYPE> ; <LIMIT PRICE> ; <TRIGGER PRICE> ; <QUANTITY> ; <ORDER STATUS>\n
NB The time of the ORDER flow indicates the exact placing time of the order.
Possible values for <ORDER STATUS>:
CODE MEANING
2000 In negotiation
2001 Entry error
2002 Trading after validation received
2003 Filled
2004 Cancelled
2005 Waiting for validation

Example of the ORDER record for the stock FIAT CHRYSLER AUTO in negotiation (10 stocks, buying order at 4.20):
ORDER;FCA;12:49:11;ORD001;ACQAZ;4.20;0.00;10;2000

TableList Message Format
Returns the table names present on the personal account
Example: by sending a command TABLELIST
BEGIN TABLE
A0;PORTAFOGLIO
M0;MOT
AZ;FIB
A*;STKF A-L
AS;STKF M-Z
AO;OPTIONS
AC;COMBO
A$;EUREX-CME-LIFFE
AD;CME FX
AL;FOREX
AN;LMAX CFD
A1;PRIMA
A2;STAR
A3;PROVATAB
B0;PORTAFOGLIO US
B1;PRIMA
END TABLE

The data flow is distinguished by two markers: a start data flow: BEGIN TABLE, and one for end data flow: END TABLE.
The table names are formed this way: <code; name>. It is important to use the names in this way because, in the table creation stage, it's possible to create them with the same name, but nonetheless, they will still have different codes. In this instance, you can see the two tables A1;PRIMA, and B1; PRIMA, they have the same name but with different codes, this is because the first one refers to the Italian market while the second to the American exchange.

TABLE Message Format
Returns a list of tickers / description inside a table, you must use the command like this: TABLE <name_table>
The names to be used must be identical to the names that are returned by the command TABLELIST. A response example of the command TABLE A1; PRIMA BEGIN LIST A1;PRIMA (9)
AGL;AUTOGRILL SPA
ASR;A.S.ROMA SPA
ATL;ATLANTIA
AZM;AZIMUT
A2A;A2A SpA
BMPS;B.MONTE PASCHI SI
BP;BANCO POPOLARE
BPE;BCA POP EMIL ROMAGNA
BZU;BUZZI UNICEM
END LIST
The data is flow characterized by the data flow start markers, in this case, the BEGIN LIST <A1; FIRST (9)> and end flow END LIST. The initial data flow marker has always the detail: BEGIN LIST and eventually the detail with the market name and number of the items on the list tickers / description.

NB: For to use the command TABLE <name_table> it's necessary to call before the command TABLELIST.

Error codes

Below are the codes displayed to the client in case of ERR message:

COD NAME DESCRIPTION FLOW
0 ERR_UNKNOWN Generic error ALL
1000 ERR_MAX_SUBSCRIPTION_OVERFLOW Reached the maximum number of subscribable securities DATAFEED
1001 ERR_ALREADY_SUBSCRIBED Requested security already subscribed DATAFEED
1002 ERR_EMPTY_LIST No security sent in the command DATAFEED
1003 ERR_UNKNOWN_COMMAND Unknown command ALL
1004 ERR_COMMAND_NOT_EXECUTED Command not executed ALL
1005 ERR_NOT_SUBSCRIBED Subscription error ALL
1006 ERR_DARWIN_STOP Darwin closure in progress ALL
1007 ERR_BAD_SUBSCRIPTION Non existing security error ALL
1008 ERR_DATA_UNAVAILABLE Requested flow unavailable DATAFEED
1009 ERR_TRADING_CMD_INCOMPLETE Incomplete trading command TRADING
1010 ERR_TRADING_CMD_ERROR Wrong trading command TRADING
1011 ERR_TRADING_UNAVAILABLE Trading unavailable TRADING
1012 ERR_TRADING_REQUEST_ERROR Order entry error TRADING
1013 ERR_HISTORYCALL_PARAMS Error number params inseto into command HISTORICAL CALLS
1015 ERR_HISTORYCALL_RANGE_INTRADAY Error range date for intraday request HISTORICAL CALLS
1016 ERR_HISTORYCALL_DAY_OR_RANGE Days or range date errors HISTORICAL CALLS
1018 ERR_EMPTY_STOCKLIST No security in the portfolio TRADING
1019 ERR_EMPTY_ORDERLIST No order is present TRADING
1020 ERR_DUPLICATED_ID Duplicated order ID TRADING
1021 ERR_INVALID_ORDER_STATE Order status inconsistent with the required operation TRADING
1024 ERR_TRADING_PUSH_DISCONNECTED Trading channel disconnected TRADING
1025 ERR_TRADING_PUSH_RECONNECTION_OK Connection to the trading channel correctly reestablished TRADING
1026 ERR_TRADING_PUSH_RELOAD TRADING
1027 ERR_DATAFEED_DISCONNECTED Real time quotes data feed disconnected DATAFEED
1028 ERR_DATAFEED_RELOAD Connection to the real time quotes channel correctly reestablished DATAFEED
1030 ERR_MARKET_UNAVAILABLE The requested ticker is part of a market which quotes are not available for your account DATAFEED
1031 SESSION_NOT_ACTIVE Session token not active anymore, you need to restart your application back from the login. All previous connection will be dropped or will recieve no data TRADING
1032 DATAFEED_NOT_ENABLED Real time data feed not enabled, please verify if the paid subscription is (still) in place DATAFEED


Subscription/unsubscription commands to the server

SUBSCRIPTION/UNSUBSCRIPTION COMMANDS
NB It's important to remember that, regardless of the number of connections established with the 10001 port, the maximum limit of subscribable securities by Darwin is currently 100.
For subscribing/unsubscribing one or more instruments, it is necessary to send a message in the following format:

<SUBSCRIPTION CODE> <TICKER LIST SEPARATED BY COMMA>\n

The possible values for <SUBSCRIPTION CODE> are the following:
CODE FLOW PORT TYPE DATA
SUB DATAFEED 10001 Standard subscription Filled orders + 5 levels book
SUBALL DATAFEED 10001 All the flows Filled orders + 5 levels book + Bidask
SUBPRZ DATAFEED 10001 Prices only Filled orders
SUBPRZALL DATAFEED 10001 Prices and bidask Filled orders + Bidask
SUB10 DATAFEED 10001 All the flows Filled orders + 5 levels Book + 10 levels Book + Bidask
SUB15 DATAFEED 10001 All the flows Filled orders + 5 levels Book + 10 levels Book + 15 levels Book + Bidask
SUB20 DATAFEED 10001 All the flows Filled orders + 5 levels Book + 10 levels Book + 15 levels Book + 20 levels Book +Bidask

Example of subscription to the prices' flow for the stock FIAT CHRYSLER AUTO
SUBPRZ FCA\n

Example of subscription of the standard flow for the stocks FIAT CHRYSLER AUTO, Eni, Luxottica
SUB FCA,ENI,LUX\n

For deleting one or more subscription, it is enough to send the command as reported in the chart below:
CODE TYPE PORT DATA
UNS Unsubscription 10001 All the flows
Example of unsubscription of the stock Fiat Chrysler Auto
UNS FCA\n

NB: The subscription/unsubscription codes are case sensitive; it is not possible to change the type of subscription to a stock. It is necessary to unsubscribe the security and resubscribe it with the desired code..

Subscription/unsubscription to the client messages format

FORMAT OF THE MESSAGES


The prices' service sends messages to the client in the form of a string, ending with the NEWLINE (ASCII 10 \n) character.

The generic format of the message is the following:

<MESSAGE_TYPE> ; <TICKER|ERROR CODE> ; <TIME HH:MM:SS> ; <DATA(ndati)>\n

The possible values for <MESSAGE_TYPE> are the following:
s
CODE FLOW DESCRIPTION
ANAG DATAFEED Registry information
PRICE DATAFEED Filled order
PRICE_AUCT DATAFEED Filled in auction (all the auctions)
BOOK_5 DATAFEED 1 - 5 levels book
BOOK_10 DATAFEED 6 - 10 levels book
BOOK_15 DATAFEED 11 - 15 levels book
BOOK_20 DATAFEED 16 - 20 levels book
BIDASK DATAFEED Bid/ask

The <DATA> field holds different values depending on the transmitted information.


ANAG message format

<MESSAGE_TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <ISIN CODE> ; <DESCRIPTION> ; <REFERENCE PRICE> ; <OPENING PRICE> ; <FLOAT>\n

ANAG record example of the stock FIAT CHRYSLER AUTO:
ANAG;FCA;16:18:13;NL0010877643;FIAT CHRYSLER AUTO;6.875;0.0;1202181255 \n


PRICE message format

<MESSAGE_TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <PRICE> ; <STOCKS QUANTITY> ; <STOCKS PROGRESSIVE> ; <EXCHANGES PROGRESSIVE> ; <MINIMUM OF THE DAY> ; <MAXIMUM OF THE DAY>\n

PRICE record example of the stock FIAT CHRYSLER AUTO:
PRICE;FCA;16:18:11;6.73;10;17917975;10150;6.57;6.93\n


PRICE_AUCT message format

<MESSAGE_TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <PRICE>\n

PRICE_AUCT record example of the stock FIAT CHRYSLER AUTO:
PRICE_AUCT;FCA;16:28:56;7.8\n

BIDASK message format

<MESSAGE_TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <STOCKS QUANTITY BID LEVEL 1> ; <NUMBER OF OFFERS BID LEVEL 1> ; <BID PRICE LEVEL 1> ; <STOCKS QUANTITY ASK LEVEL 1> ; <NUMBER OF OFFERS ASK LEVEL 1> ; <ASK PRICE LEVEL 1>\n

BIDASK record example for the security FIAT CHRYSLER AUTO:
BIDASK; FCA; 16: 41: 21; 14381; 0; 6795; 5458; 0; 6805 \ n
NB: The data regarding the number of PROPOSALS may not be available depending on the market.
Where the security belongs. In lack of which reference could be made to the Book data flow details (explained in detail in the next section) which shows the proposals at Level 1 of the book.

NB: The element related to the number of offers could be unavailable, according to the market to which the stock belongs.


BOOK_5 message format

<MESSAGE TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <STOCKS QUANTITY BID LEVEL 1> ; <NUMBER OF OFFERS BID LEVEL 1> ; <BID PRICE LEVEL 1> ; <STOCKS QUANTITY BID LEVEL 2> ; <NUMBER OF OFFERS BID LEVEL 2> ; <BID PRICE LEVEL 2> ; <STOCKS QUANTITY BID LEVEL 3> ; <NUMBER OF OFFERS BID LEVEL 3> ; <BID PRICE LEVEL 3> ; <STOCKS QUANTITY BID LEVEL 4> ; <NUMBER OF OFFERS BID LEVEL 4> ; <BID PRICE LEVEL 4> ; <STOCKS QUANTITY BID LEVEL 5> ; <NUMBER OF OFFERS BID LEVEL 5> ; <BID PRICE LEVEL 5> ; <STOCKS QUANTITY ASK LEVEL 1> ; <NUMBER OF OFFERS ASK LEVEL 1> ; <ASK PRICE LEVEL 1> ; <STOCKS QUANTITY ASK LEVEL 2> ; <NUMBER OF OFFERS ASK LEVEL 2> ; <ASK PRICE LEVEL 2> ; <STOCKS QUANTITY ASK LEVEL 3> ; <NUMBER OF OFFERS ASK LEVEL 3> ; <ASK PRICE LEVEL 3> ; <STOCKS QUANTITY ASK LEVEL 4> ; <NUMBER OF OFFERS ASK LEVEL 4> ; <ASK PRICE LEVEL 4> ; <STOCKS QUANTITY ASK LEVEL 5> ; <NUMBER OF OFFERS ASK LEVEL 5> ; <ASK PRICE LEVEL 5<\n

BOOK_5 record example of the stock FIAT CHRYSLER AUTO:
BOOK_5;FCA;16:26:09;17743;6;6.755;31230;6;6.75;36723;11;6.745;48250;14;6.74;56771;11;6.735;7600;3;6.765;18795;8;6.77;15358;8;6.775;21212;10;6.78;12522;5;6.785\n


BOOK_10 message format

<MESSAGE TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <STOCKS QUANTITY BID LEVEL 6> ; <NUMBER OF OFFERS BID LEVEL 6> ; <BID PRICE LEVEL 6> ; <STOCKS QUANTITY BID LEVEL 7> ; <NUMBER OF OFFERS BID LEVEL 7> ; <BID PRICE LEVEL 7> ; <STOCKS QUANTITY BID LEVEL 8> ; <NUMBER OF OFFERS BID LEVEL 8> ; <BID PRICE LEVEL 8> ; <STOCKS QUANTITY BID LEVEL 9> ; <NUMBER OF OFFERS BID LEVEL 9> ; <BID PRICE LEVEL 9> ; <STOCKS QUANTITY BID LEVEL 10> ; <NUMBER OF OFFERS BID LEVEL 10> ; <BID PRICE LEVEL 10> ; <STOCKS QUANTITY ASK LEVEL 6> ; <NUMBER OF OFFERS ASK LEVEL 6> ; <ASK PRICE LEVEL 6> ; <STOCKS QUANTITY ASK LEVEL 7> ; <NUMBER OF OFFERS ASK LEVEL 7> ; <ASK PRICE LEVEL 7> ; <STOCKS QUANTITY ASK LEVEL 8> ; <NUMBER OF OFFERS ASK LEVEL 8> ; <ASK PRICE LEVEL 8> ; <STOCKS QUANTITY ASK LEVEL 9> ; <NUMBER OF OFFERS ASK LEVEL 9> ; <ASK PRICE LEVEL 9> ; <STOCKS QUANTITY ASK LEVEL 10> ; <NUMBER OF OFFERS ASK LEVEL 10> ; <ASK PRICE LEVEL 10>\n

BOOK_10 record example of the stock FIAT CHRYSLER AUTO:
BOOK_10;FCA;11:31:14;1445;2;18.456;3635;5;18.454;1045;2;18.452;2500;10;18.45;645;1;18.448;
2908;4;18.482;3215;4;18.484;2015;3;18.486;2839;3;18.488;4450;6;18.49\n



BOOK_15 message format

<MESSAGE TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <STOCKS QUANTITY BID LEVEL 11> ; <NUMBER OF OFFERS BID LEVEL 11> ; <BID PRICE LEVEL 11> ; <STOCKS QUANTITY BID LEVEL 12> ; <NUMBER OF OFFERS BID LEVEL 12> ; <BID PRICE LEVEL 12> ; <STOCKS QUANTITY BID LEVEL 13> ; <NUMBER OF OFFERS BID LEVEL 13> ; <BID PRICE LEVEL 13> ; <STOCKS QUANTITY BID LEVEL 14> ; <NUMBER OF OFFERS BID LEVEL 14> ; <BID PRICE LEVEL 14> ; <STOCKS QUANTITY BID LEVEL 15> ; <NUMBER OF OFFERS BID LEVEL 15> ; <BID PRICE LEVEL 15> ; <STOCKS QUANTITY ASK LEVEL 11> ; <NUMBER OF OFFERS ASK LEVEL 11> ; <ASK PRICE LEVEL 11> ; <STOCKS QUANTITY ASK LEVEL 12> ; <NUMBER OF OFFERS ASK LEVEL 12> ; <ASK PRICE LEVEL 12> ; <STOCKS QUANTITY ASK LEVEL 13> ; <NUMBER OF OFFERS ASK LEVEL 13> ; <ASK PRICE LEVEL 13> ; <STOCKS QUANTITY ASK LEVEL 14> ; <NUMBER OF OFFERS ASK LEVEL 14> ; <ASK PRICE LEVEL 14> ; <STOCKS QUANTITY ASK LEVEL 15> ; <NUMBER OF OFFERS ASK LEVEL 15> ; <ASK PRICE LEVEL 15>\n

BOOK_15 record example of the stock FIAT CHRYSLER AUTO:
BOOK_15;FCA;11:35:32;3172;5;18.48;1906;3;18.478;3993;5;18.476;34141;4;18.474;1901;2;18.472;
1506;2;18.524;651;1;18.526;5651;2;18.528;5851;3;18.53;7599;5;18.532\n



BOOK_20 message format

<MESSAGE TYPE> ; <TICKER> ; <TIME HH:MM:SS> ; <STOCKS QUANTITY BID LEVEL 16> ; <NUMBER OF OFFERS BID LEVEL 16> ; <BID PRICE LEVEL 16> ; <STOCKS QUANTITY BID LEVEL 17> ; <NUMBER OF OFFERS BID LEVEL 17> ; <BID PRICE LEVEL 17> ; <STOCKS QUANTITY BID LEVEL 18> ; <NUMBER OF OFFERS BID LEVEL 18> ; <BID PRICE LEVEL 18> ; <STOCKS QUANTITY BID LEVEL 19> ; <NUMBER OF OFFERS BID LEVEL 19> ; <BID PRICE LEVEL 19> ; <STOCKS QUANTITY BID LEVEL 20> ; <NUMBER OF OFFERS BID LEVEL 20> ; <BID PRICE LEVEL 20> ; <STOCKS QUANTITY ASK LEVEL 16> ; <NUMBER OF OFFERS ASK LEVEL 16> ; <ASK PRICE LEVEL 16> ; <STOCKS QUANTITY ASK LEVEL 17> ; <NUMBER OF OFFERS ASK LEVEL 17> ; <ASK PRICE LEVEL 17> ; <STOCKS QUANTITY ASK LEVEL 18> ; <NUMBER OF OFFERS ASK LEVEL 18> ; <ASK PRICE LEVEL 18> ; <STOCKS QUANTITY ASK LEVEL 19> ; <NUMBER OF OFFERS ASK LEVEL 19> ; <ASK PRICE LEVEL 19> ; <STOCKS QUANTITY ASK LEVEL 20> ; <NUMBER OF OFFERS ASK LEVEL 20> ; <ASK PRICE LEVEL 20>\n

BOOK_20 record example of the stock FIAT CHRYSLER AUTO:
BOOK_20;FCA;11:35:42;1766;3;18.47;1901;2;18.468;982;2;18.466;1291;2;18.464;4062;4;18.462;
16008;4;18.534;2040;3;18.536;1241;2;18.538;765;2;18.54;1285;2;18.542\n



ERR message format

<MESSAGE_TYPE> ; <TICKER> ; <ERROR CODE>\n

Generic ERR record example:
ERR;N/A;1003\n

Example of the ERR record for a specific command with wrong stock:
ERR;FFFF;1007\n



Information related to the Indexes It's possible for the INDICES to have both the information related to the real-time and historical data as well.
The indices' ticker list is referring back to this list:
  • DITA
  • DGER
  • DFRA
  • FMIB
  • FMBTL
  • FMIDC
  • FSTAR
  • DAX
  • SDX
  • MDX
  • TDX
  • NDQ
  • NDQ100
  • DJ

Following are some subscription instances to some indices:
SUB FMIB
PRICE;fMIB;10:23:21;23827.42;0;0;0;23814.62;23893.72
PRICE;fMIB;10:23:33;23827.6;0;0;0;23814.62;23893.72
PRICE;fMIB;10:23:33;23827.44;0;0;0;23814.62;23893.72
PRICE;fMIB;10:23:34;23827.12;0;0;0;23814.62;23893.72
PRICE;fMIB;10:23:35;23826.93;0;0;0;23814.62;23893.72
PRICE;fMIB;10:23:35;23827.16;0;0;0;23814.62;23893.72
UNS FMIB

SUB FMIDC
PRICE;fMidC;10:27:45;34117.41;0;0;0;34040.7;34184.03
PRICE;fMidC;10:27:59;34120.27;0;0;0;34040.7;34184.03
PRICE;fMidC;10:28:14;34118.15;0;0;0;34040.7;34184.03
PRICE;fMidC;10:28:29;34112.11;0;0;0;34040.7;34184.03
UNS FMIDC

Regarding the historic calls, please refer to the commands' instructions, laid in greater detail in the HISTORICAL CALLS section, and use the Tickers in the above-mentioned list.
NB: For the historic calls, you must use the indices' Tickers in Uppercase, if you type them differently the tickers will not be recognized.

Diagnostic commands to the server

It is possible to manage the LOG detail by sending some specific commands on the prices channel.

<COMMAND CODE> {<OPTIONS>}\n

The possible values for <COMMAND CODE> are the following:

CODE FLOW ACTION
ENABLELOG DATAFEED Enables the maximum detail log.
DISABLELOG DATAFEED Disables the LOG. Only important messages and errors will be tracked
The LOG is written into the DARWIN preferences folder.

Diagnostic messages format to the client

The prices' service sends diagnostic messages to the client on the prices socket in a string form, ending with the NEWLINE (ASCII 10 \n) character.

The generic format of the messages is the following:

<MESSAGE_TYPE>\n

The possible values for <MESSAGE_TYPE> are the following:

CODE MEANING
LOG_ENABLED The maximum detail LOG is enabled.
LOG_DISABLED The maximum detail LOG is disabled.

Historical data commands -Function not available- use: HISTORICAL CALLS


Trading commands to the server

To perform trading operations, it is necessary to send a message in the following format: <ACTION CODICE>  &nbps;{<ORDER_ID>},{<TICKER>,<QUANTITY>},{<PRICE>}\n

The Prices' Service may request the client the order confirmation. In this case, it is necessary to answer with the correct code, as indicated in the following chart, and the corresponding <ORDER_ID>.

<ORDER_ID> must be generated by the client, and be univocal for the current session of connection to the socket.

The possible values for <ACTION CODE> are the following:

CODE FLOW ACTION
ACQAZ TRADING Buy stocks at the specified limit price
VENAZ TRADING Sell stocks at the specified limit price
ACQMARKET TRADING Buy stocks at the market price
VENMARKET TRADING Sell stocks at the market price
ACQSTOP TRADING Buy stocks with stop market price
VENSTOP TRADING Buy stocks with stop market price
ACQSTOPLIMIT TRADING Buy stocks with limit price and trigger price
VENSTOPLIMIT TRADING Sell stocks with limit price and trigger price
REVORD TRADING Cancel the specified order
REVALL TRADING Cancel all the orders for the specified ticker
CONFORD TRADING Confirm the specified order
MODORD TRADING Change price for the specified order
ACQAZ/VENAZ message format

ACQAZ <ORDER_ID>,<TICKER>,<QUANTITY>,<PRICE>\n

Example of buying order for 10 FIAT CHRYSLER AUTO at the price of 4,75
ACQAZ ORD001,FCA,10,4.75\n

ACQMARKET/VENMARKET message format

ACQMARKET <ORDER_ID>,<TICKER>,<QUANTITY>\n

Example of buying order for 10 FIAT CHRYSLER AUTO
ACQMARKET ORD001,FCA,10\n

ACQSTOP/VENSTOP message format

ACQSTOP <ORDER_ID>,<TICKER>,<QUANTITY,<TRIGGER>\n

Example of buying order for 10 FIAT CHRYSLER AUTO at the market price when the trigger price of 5,75 is reached
ACQSTOP ORD001,FCA,10,5.75\n

ACQSTOPLIMIT/VENSTOPLIMIT message format

ACQSTOPLIMIT <ORDER_ID>,<TICKER>,<QUANTITY>,<LIMIT PRICE>,<TRIGGER PRICE>\n

Example of buying order for 10 FIAT CHRYSLER AUTO at the price of 6 when the trigger price of 5,75 is reached
ACQSTOPLIMIT ORD001,FCA,10,6,5.75\n

REVORD message format

REVORD <ORDER_ID>\n

Example of order ORD001 cancellation
REVORD ORD001\n

REVALL message format

REVALL <TICKER>\n

Example of cancellation of all the orders for FIAT CHRYSLER AUTO (intraday only)

REVALL FCA\n

NB The REVALL applies only to the regular orders and not for those with the limit condition,
where it's necessary to carry out a timely cancellation of the order through REVORD <id_ordine>,
as it's the same behavior as that of Darwin.


CONFORD message format

CONFORD <ID_ORDINE>\n

Sample confirmation of the order ORD001 following a request by the server
Conford ORD001\n

ORDER CONFIRMATION HANDLING

The management of the order confirmation depends on the choice set by the individual accounts.
To chang the confirmation management option, you need to login to the identification page
https://www1.directatrading.com
Sign in with your account
Click on MainBoard
Click on the Menu item : Options
On the next page, click again on the menu item : Options
The order confirmation mode is shown On the upper section of the page.
We would like to remind you that on some orders types, even though the choice is set to No order confirmation, the order confirmation is always active.


MODORD Message

MODORD <ID_ORD>,<PPRICE>\n

Example of modify ORD001 to price 4.50
MODORD ORD001,4.50\n

If the order is stop, you must insert the signal price.
MODORD <ID_ORD>,<LIMIT PRICE>,<SIGNAL PRICE>\n


MODORD message format

MODORD <ORDER_ID>,<PRICE>\n

Example of order ORD001 modification to the price of 4.50
MODORD ORD001,4.50\n

If it is a stop order, also the trigger price should be indicated.
MODORD <ORDER_ID>,<LIMIT PRICE>,<TRIGGER PRICE>\n

Trading messages to the client format

The Prices Service sends the client the result of trading operations in a string format, ending with the NEWLINE (ASCII 10 \n) character.

The generic message format is the following:

<MESSAGE_TYPE> ; <TICKER> ; <ORDER_ID> ; <CODE> ; <SENT COMMAND> ; <ASKED QUANTITY|FILLED QUANTITY> ; <PRICE ENTRY> ; <ERROR DESCRIPTION>\n

The possible values for <MESSAGE TYPE> are the following:

CODE FLOW MEANING
TRADOK TRADING Positive outcome of the operation (PLACEMENT, EXECUTION, CANCELLATION)
TRADERR TRADING Negative outcome
TRADCONFIRM TRADING Needed order confirmation from the client

The possible values for <CODE> are the following:
CODE MEANING
3000 Request correctly received
3001 Request executed
3002 Request cancelled
3003 Order confirmation needed

Example of the SENT ORDER record for buying 10 FIAT CHRYSLER AUTO at the 4,75 price:
TRADOK;FCA;ORD001;3000;ACQAZ;10;4.75,0.0

Example of the FILLED ORDER record for buying 10 FIAT CHRYSLER AUTO at the 4,75 price:
TRADOK;FCA;ORD001;3001;ACQAZ;10;4.75,0.0

Example of the CANCELLED ORDER record for buying 10 FIAT CHRYSLER AUTO at the 4,75 price:
TRADOK;FCA;ORD001;3002;ACQAZ;10;4.75,0.0

Example of the CONFIRMATION NEEDED record for ORD001 order
TRADCONFIRM;FCA;ORD001;3003;ACQAZ;10;1;VI TRASMETTO L'ORDINE DI ACQUISTO DI 10 F AL PREZZO DI 1,0000 EURO PER UN VALORE DI 10 EURO.

Example of the IMMISSION ERROR record for buying 10 FIAT at the 200 price:
TRADERR;FCA;ORD001;1012;ACQAZ;10;200;L'ORDINE NON PUO' ESSERE INOLTRATO PER SCOSTAMENTO DI PREZZO TROPPO ELEVATO RISPETTO AI VALORI DI MERCATO

Plus Command TRADING

After several suggestions, we have made an efffort to create some commands to extend the set of information retrievable through the API.
At the moment, special attention has been given to the expansion of the trading related information.
The chioce was made to safeguard the Trading Systems currently in use, and to create commands that can be activated and deactivated to access the features.
The following are the new available commands:

COMMAND MEANING VALUE DEFAULT
FLOWPOINT Start & End markers of the data flow packages FALSE / TRUE FALSE
UPDATEORDER Possibility, at order submission, to receive updates without having to send specific commands FALSE / TRUE FALSE
PRICEEXE fields related to the trade execution price are added, quantity and Order_ID relating to the TRADOK and ORDER packages FALSE / TRUE FALSE
LOGCMD added at the end of TRADOK and TRADERR packages of the command that has generated the package FALSE / TRUE FALSE
POINTUPDATEORDER a new way to have an automatic update on one's own situation with regard to trade operation. FALSE / TRUE FALSE
AUTOREC an automatic method of restoring trading connection because of line drops FALSE / TRUE FALSE

For each command, you can perform three types of tasks:
  • Set to TRUE - TRUE command_type'blank - e.g. PRICEEXE TRUE; API Response: PRICEEXE; TRUE
  • Set to FALSE - Command_type'blank'FALSE - e.g. FLOWPOINT FALSE; Response API response: FLOWPOINT; FALSE
  • Request the current status - Command type - e.g UPDATEORDER; API response: UPDATEORDE;FALSE

FLOWPOINT COMMAND
It distinguishes the commands ORDERLIST and INFOSTOCKS from the start & end flags of the flow.
For Examples (in blue will be identified the lines sent to the socket, those received in black):
Activation of the Command FLOWPOINT
FLOWPOINT TRUE
FLOWPOINT;TRUE
ORDERLIST
BEGIN ORDERLIST
ORDER;A2A;09:46:11;ORD1;ACQAZ;1.075;0.0;1;2004
ORDER;A2A;09:59:46;ORD2;ACQAZ;1.5;0.0;1;2003
ORDER;A2A;09:57:12;ORD3;ACQAZ;1.052;0.0;1;2004
ORDER;ENEL;10:04:42;ORD9;VENAZ;3.8;0.0;1;2003
END ORDERLIST

Activation of the Command FLOWPOINT
FLOWPOINT TRUE
FLOWPOINT;TRUE
INFOSTOCKS
BEGIN STOCKLIST
STOCK;AGL;16:41:49;47;0;;7.7036;20
STOCK;A2A;16:41:49;82;70;70> -70;1.1326;-4
STOCK;BMPS;16:41:49;1;0;;2.18;-1
STOCK;LX.EURUSD;16:41:49;144;0;;1.122389;43
STOCK;.FB;16:41:49;14;0;;83.1958;77
STOCK;.GOOG;16:41:49;10;0;;641.7701;-362
STOCK;.KO;16:41:49;4;0;;43.4792;-14
END STOCKLIST

UPDATEORDER COMMAND
Upon submission of an order, you will always receive the TRADOK package that will indicate the situation of the order, with this command set to TRUE. by default this is set to FALSE, to avoid the recreation of a Trading System that's already operational, you will receive updates on the situation of the order and other data relating to the portfolio without sending additional commands via socket. Update messages will be different depending on the operation being performed:
OPERATION DESCRIPTION
PLACING ORDER In addition to the package TRADOK (with the code 3000) the ORDER package will be sent, relating to the entered order, and the information on the balance status of the account, the package INFOACCOUNT
CHANGED ORDER in addition to TRADOK (with the code 3000) the ORDER package will be sent relative to the changed order, the STOCK of the financial instrument, the details of the command AVAILABILITY-Liquidity portfolio (with or without margin) and information on the balance status of the account, the package INFOACCOUNT (this will appear twice, having been made an change).
EXECUTED ORDER when an order should be executed TRADOK detail comes out (with code 3001) and in addition, the detail of the order through the package ORDER, the relative STOCK of the security, the detail AVAILABILITY-Liquidity of the portfolio (with or without margin) and information on the balance status of the account, the INFOACCOUNT package.
CANCELED ORDER in addition to the TRADOK package (with the 3002 detail) moreover, there will be the STOCK package related to the financial instrument, the detaile: AVAILABILITY-Liquidity portfolio (with or without margin) and the information on the balance situation of the account, the INFOACCOUNT package.
Examples (in blue will be identified the lines sent to the socket, those received are in black, and, in red are the comments):
A data flow regarding all the possible operations will be displayed. Activation of the commands
UPDATEORDER TRUE
UPDATEORDER;TRUE
I send a purchase order
ACQAZ ORD172001,LX.EURUSD,10,1.11941
In this case, the order confirmation is on, so the order confirmation
TRADCONFIRM;LX.EURUSD;ORD172001;3003;ACQAZ;10;1.119410;I SEND YOU PURCHASE ORDER OF 10 LX.EURUSD AT THE PRICE OF $ 1,119410 TRADE VALUE of $ 11,194. order confirmation is requested by the customer: the command CONFORD We confirm the order
CONFORD ORD172001
TRADOK;LX.EURUSD;ORD172001;3000;ACQAZ;10;1.11941;0.0
ORDER;LX.EURUSD;17:20:26;ORD172001;ACQAZ;1.11941;0.0;10;2002
INFOACCOUNT;17:20:26;47511;13.19;-1;0.41999998688697815
Another change
MODORD ORD172001,1.11949
TRADOK;LX.EURUSD;ORD172001;3000;ACQAZ;10;1.11949;0.0
ORDER;LX.EURUSD;17:20:43;ORD172001;ACQAZ;1.11949;0.0;10;2002
INFOACCOUNT;17:20:44;47511;13.19;-1;0.41999998688697815
STOCK;LX.EURUSD;17:20:44;144;0;10;1.122389;206
AVAILABILITY;17:20:44;539899.8;542133.0;0.0;0.0;541257.3
INFOACCOUNT;17:20:45;47511;13.19;-1;1.2800999879837036
Another change, to get executed
MODORD ORD172001,1.12399
TRADOK;LX.EURUSD;ORD172001;3000;ACQAZ;10;1.12399;0.0
ORDER;LX.EURUSD;17:20:56;ORD172001;ACQAZ;1.12399;0.0;10;2002
INFOACCOUNT;17:20:56;47511;13.19;-1;0.41999998688697815
STOCK;LX.EURUSD;17:20:56;144;10;10>;1.122389;196
AVAILABILITY;17:20:56;539899.8;542133.0;0.0;0.0;541257.3
INFOACCOUNT;17:20:56;47511;13.19;-1;0.41999998688697815
order executed
TRADOK;LX.EURUSD;ORD172001;3001;ACQAZ;10;1.12399;0.0
ORDER;LX.EURUSD;17:20:56;ORD172001;ACQAZ;1.12399;0.0;10;2003
STOCK;LX.EURUSD;17:20:58;154;0;;1.122494;203
AVAILABILITY;17:20:58;539899.4;542132.56;0.0;0.0;541006.9
INFOACCOUNT;17:20:59;47511;13.19;-1;0.41999998688697815 we suggest a cancel order
order submission
ACQAZ ORD173106,LX.EURUSD,10,1.11941
In this case, order confirmation is important, so, confirm the order
TRADCONFIRM;LX.EURUSD;ORD173106;3003;ACQAZ;10;1.119410;I SEND YOU A PURCHASE ORDER OF 10 LX.EURUSD AT THE PRICE OF 1,119410 USD FOR A TOTAL AMOUNT OF 11194 USD.
CONFORD ORD173106
TRADOK;LX.EURUSD;ORD173106;3000;ACQAZ;10;1.11941;0.0
ORDER;LX.EURUSD;17:31:36;ORD173106;ACQAZ;1.11941;0.0;10;2002
INFOACCOUNT;17:31:36;47511;13.19;-1;0.41999998688697815
Cancel the order
REVORD ORD173106
TRADOK;LX.EURUSD;ORD173106;3002;ACQAZ;;1.11941;0.0
STOCK;LX.EURUSD;17:31:42;154;0;;1.122494;149
AVAILABILITY;17:31:42;539899.4;542132.56;0.0;0.0;541006.9
INFOACCOUNT;17:31:43;47511;13.19;-1;0.41999998688697815

COMMAND PRICEEXE
The command will be running on TRADOK and ORDER packages. By setting the command to TRUE, you will have the following information:
  • TRADOK package, the following details will be added towards the end:
    • executed price (useful for purchases at best or at the market)
    • quantity executed (if all, it will be equal to the amount detail already in the remaining amount package
    • quantity residual (if the it was a total order execution, it will be equal to 0)
    • the id referring to Directa
  • ORDER package, the following details will be added towards the end:
    • average price
    • execution price
    • at the market quantity, useful for checking if at the market quantity still exists
    • id referring to Directa
Here is an example of a data flow to showcase the differences: (in blue will be identified the lines sent to the socket, those received in black, in bold face we will instead highlight the new fields)
PRICEEXE TRUE
PRICEEXE;TRUE
ACQAZ ORD105037,A2A,1,1.328
TRADOK;A2A;ORD105037;3000;ACQAZ;1;1.328;0.0;0.0;0;0;P3710505738518
MODORD ORD105037,1.344
TRADOK;A2A;ORD105037;3000;ACQAZ;1;1.344;0.0;0.0;0;0;P3710512338519
MODORD ORD105037,1.345
TRADOK;A2A;ORD105037;3000;ACQAZ;1;1.345;0.0;0.0;0;0;P3710513238520
TRADOK;A2A;ORD105037;3001;ACQAZ;1;1.345;0.0;1.3440;1;0;P3710513238520
FLOWPOINT TRUE
FLOWPOINT;TRUE
ORDERLIST
BEGIN ORDERLIST
ORDER;A2A;10:50:57;ORD105037;ACQAZ;1.344;0.0;1;2004;0.0;0.0;0;P3710505738518
ORDER;A2A;10:51:23;ORD105037;ACQAZ;1.345;0.0;1;2004;0.0;0.0;0;P3710512338519
ORDER;A2A;10:51:32;ORD105037;ACQAZ;1.345;0.0;1;2003;1.3400;1.3440;0;P3710513238520
END ORDERLIST
NBThe fields will be added later on in the order in which they were described, the other fields will be in the same original order, that's without the activation of the PRICEEXE command.
Another very important detail is the possibility of having the execution price included in the ORDER package, at the moment, this field will be evaluated only within a Darwin session, therefore, if there was a trading socket disconnection, the value will always be available, and, it will be no longer available if you close and re-open Darwin. however, the evaluation of the fields is guaranteed, even if they are not available with a 0, so as not to create failures in the reading of the messages.

COMMAND LOGCMD
This command, when activated (LOGCMD TRUE) adds at the end of the packages: TRADOK and TRADERR, and the command that has generated the package, for the sake of giving greater information on the order submissions. This command also be working if it's active, rigardless of wheather the PRICEEXE is active or not, even though the addition of the command will always be towards the bottom.
Below, a usage example is offered by using: (in blue will be identified the lines sent to the socket, those received in black, and in bold type, we will instead highlight the new fields
LOGCMD TRUE
LOGCMD;TRUE
PRICEEXE TRUE
PRICEEXE;TRUE
ACQAZ ORD121835,FCA,1,4.75
TRADOK;FCA;ORD121835;3000;ACQAZ;1;4.75;0.0;0.0;0;0;S1112184397605;ACQAZ ORD121835,FCA,1,4.75
REVORD ORD121835
TRADOK;FCA;ORD121835;3002;ACQAZ;1;4.75;0.0;0.0;0;0;S1112184397605;REVORD ORD121835
PRICEEXE FALSE
PRICEEXE;FALSE
ACQAZ ORD121916,FCA,1,4.75
TRADOK;FCA;ORD121916;3000;ACQAZ;1;4.75;0.0;ACQAZ ORD121916,FCA,1,4.75
REVORD ORD121916
TRADOK;FCA;ORD121916;3002;ACQAZ;1;4.75;0.0;REVORD ORD121916
ACQAZ ORD124431,FCA,1,1.75
TRADERR;FCA;ORD124431;1012;ACQAZ;1;1.7500;THE ORDER CANNOT BE SUBMITTED DUE TO HIGH PRICE DEVIATION COMPARED TO THE MARKET PRICES;ACQAZ ORD124431,FCA,1,1.7500

POINTUPDATEORDER COMMAND
This command is intended as a more complete command to get automatic updates without having to send commands to the socket.
The characteristics of this command is that the update will be always the same, namely the upgrade packages will not change according to the operation performed unlike the first proposal for a camando UPDATEORDER.
This information package will always after its operation TRADOK, this type of upgrade is guaranteed for orders placed via API, if these are facts about Darwin platform it could happen that this update does not reach to avoid the risk of putting inaccurate information.
The update will always be composed of:
BEGIN UPDATEORDER
UORDER
USTOCK
UAVAILABILITY
UINFOACCOUNT
END UPDATEORDER

Description:
  • BEGIN UPDATEORDER - START update
  • UORDER - Package Order concerning the placing / run / revocation effected
  • USTOCK - Package STOCK situation portfolio according to your input / run / revocation effected
  • UAVAILABILITY - Package AVAILABILITY situation
  • UINFOACCOUNT - NFOACCOUNT package updated
  • END UPDATEORDER - END update

NBThe fields are all initialized with a U to highlight the fact that, the field is related to the update, and so to avoid confusion compared to the other fields. Below, a usage example is given: (in blue will be identified the lines sent to the socket, those received in black, and in bold type we will instead highlight the new fields)
PRICEEXE TRUE
PRICEEXE;TRUE
POINTUPDATEORDER TRUE
POINTUPDATEORDER;TRUE
ACQAZ ORD1,FCA,1,5.75
TRADOK;FCA;ORD1;3000;ACQAZ;1;5.75;0.0;0.0;0;0;S4216521807924
BEGIN UPDATEORDER
UORDER;FCA;16:52:18;ORD1;ACQAZ;5.75;0.0;1;2002;0.0;0.0;0;S4216521807924
USTOCK;FCA;16:52:18;0;0;1;0.0;
UAVAILABILITY;16:52:18;45.09;45.09;0.0;0.0;50.84
UINFOACCOUNT;16:52:18;47511;50.84;0;0.0
END UPDATEORDER

MODORD ORD1,5.65
TRADOK;FCA;ORD1;3000;ACQAZ;1;5.65;0.0;0.0;0;0;S4216523407947
BEGIN UPDATEORDER
UORDER;FCA;16:52:34;ORD1;ACQAZ;5.65;0.0;1;2006;0.0;0.0;0;S4216523407947
USTOCK;FCA;16:52:34;0;0;1;0.0;
UAVAILABILITY;16:52:34;45.19;45.19;0.0;0.0;50.84
UINFOACCOUNT;16:52:34;47511;50.84;0;0.0
END UPDATEORDER

REVORD ORD1
TRADOK;FCA;ORD1;3002;ACQAZ;1;5.65;0.0;0.0;0;0;S4216523407947
BEGIN UPDATEORDER
UORDER;FCA;16:52:34;ORD1;ACQAZ;5.65;0.0;1;2004;0.0;0.0;0;S4216523407947
USTOCK;FCA;16:52:59;0;0;;0.0;
UAVAILABILITY;16:52:59;50.84;50.84;0.0;0.0;50.84
UINFOACCOUNT;16:52:59;47511;50.84;0;0.0
END UPDATEORDER


NB by activating this command, the changed orders will have, as a detail for the order status the value of 2006, and this' was required to have a distinguishing detail compared to the standard codes of 2000/2002, this code will also have an effect on the ORDERLIST command, if the command will gets disabled, the detail in 2006 will no longer be available and you will return to the default of (2000/2002))

NB We recommend, to to avoid errors, to keep enabled only one update method, therefore, either the command UPDATEORDER, or the command POINTUPDATEORDER should be active. If both the commands are activated POINTUPDATEORDER will have higher priority, and, in case one becomes disabled, both of them will then be disabled,This is to avoid the risk of requesting inaccurate updates.

THE AUTOREC COMMAND(currently in a testing phase)
This command is meannt to make an automatic reconnection if trading disconnection occures. The command should be activated after connecting the socket and only after receiving the initial packages.
Below, a usage example is given: (in blue will be identified lines sent to the socket, those received in black, and bold we instead highlight the new fields)
AUTOREC TRUE
AUTOREC;TRUE;AUTORECOK
ERR;N/A;1024
Trading Disconnesso;false;1024
Recconect Trading to 5 sec
TradingRiconesso;true;1025
DARWIN_STATUS;RECONNTRADINGOK CONN_OK ;TRUE;Release 1.2.179 build 24/11/2015 14:37:00 more info at http://213.92.13.32/directaapi/rss.php
ERR;N/A;1018
ORDER;FCA;10:49:00;ORD1;ACQAZ;6.165;0.0;1;2004
ORDER;FCA;10:36:11;ORD2;ACQAZ;6.15;0.0;1;2004
ORDER;FCA;10:36:45;ORD3;ACQAZ;6.145;0.0;1;2004
ORDER;FCA;10:47:49;ORD4;ACQAZ;6.145;0.0;1;2004
ORDER;FCA;10:49:05;ORD5;ACQAZ;6.16;0.0;1;2004
ACQAZ ORD1,FCA,1,4.75
TRADOK;FCA;ORD1;3000;ACQAZ;1;4.75;0.0
MODORD ORD1,4.85
TRADOK;FCA;ORD1;3000;ACQAZ;1;4.85;0.0
REVORD ORD1
TRADOK;FCA;ORD1;3002;ACQAZ;1;4.85;0.0


Periodicals Available historical

Specific historical periods available

The limit currently imposed are 100 days for intraday calls and five years for EnfOfDay calls when calls beyond the limits of the response will be composed of the maximum depth of our data base, in case of error in the controls or within the limits of error codes they will be sent.

TIME FRAME Maximum Depth(historical maximum available)
1 and 5 seconds Maximum 1 day
10 and 30 seconds Maximum 3 days
1, 2, 3 and 4 minutes Maximum 100 days
END OF DAY Maximum 15 years

Introduction and how to use the commands to the Server


To enable the connection you need to connect with the socket on the 10003 port

You can use four commands: TBT (Usage 1), TBTRANGE (Usage 2), CANDLE (Usage 3), and CANDLERANGE (Usage 4).

To use the commands you need to insert a space between the arguments.


The Usage 1 and Usage 2 commands are related to the historical calls of TickByTick type, while the Usage 3 and Usage 4 commands are specific for the Candles.

Usage 1:

				        		
TBT stock number_of_days

stock: The code of the stock

number_of_days: The number of days (including today) of history depth

Usage 2:
				        	
TBTRANGE stock start_date end_date

stock: The code of the stock

start_date_time: The starting date of the requested time range, in the format yyyyMMddHHmmss

end_date_time: The ending date of the requested time range, in the format yyyyMMddHHmmss

Usage 3:
				        	
CANDLE stock number_of_days candle

stock: The code of the stock

number_of_days: The number of days (including today) of history depth

candle: The period in seconds for a candlestick representation.

Usage 4:
				        	
CANDLERANGE stock start_date_time end_date_time candle

stock:The code of the stock

start_date_time:The starting date of the requested time range, in the format yyyyMMddHHmmss

end_date_time: The ending date of the requested time range, in the format yyyyMMddHHssmm

candle: The period in seconds for a candlestick representation.


If the arguments are not correct you will receive an error reply
If the number of days is wrong you will receive the following error reply: Wrong number_of_days value
If the period is wrong you will receive the following error reply: Wrong candle value
If the data range is wrong you will receive the following error reply: Wrong start_date and/or end_date value.
If some arguments are missing you will receive the following error reply: Not enough parameters.


SETTING THE DETAIL OF VOLUMES DURING AFTERHOURS

Description for the command VOLUMEAFTERHOURS
Command to set the detail of the volumes during AFTERHOURS (AH), for securities that are AH. By default the phase of AH the service responds to the detail of the volumes with the sum of the volumes of the more continuous volumes of the AH. If you wanted to change this detail is at our disposal the command: VOLUMEAFTERHOURS Can be used in two different ways: Only typing VOLUMEAFTERHOURS which response will tell how is the choice set.
the choices are as follows:

PARAMETER DESCRIPTION
CNT retail volume continuous phase
AH Retail volumes during afterhours
CNT+AH sum of the volumes continues + afterhours

The detail CNT + AH is the default setting
The second way to use strives to set the desired detail, you must type the command with the parameter,
example: VOLUMEAFTERHOURS AH
doing this operation, the detail volumes during the AH will be set to only volumes generated in AH.

The following are practical examples for the use of this command:

Examples for the information of the setting: typing VOLUMEAFTERHOURS you can have three types of responses:

VOLUME_AFTERHOURS CNT+AH default indicates the sum of the volumes in the volumes continues with the volumes AH
VOLUME_AFTERHOURS AH setting that indicates that the volumes will be displayed in AH
VOLUME_AFTERHOURS CNT setting that indicates that the volumes will be displayed in continuous

Examples for changing the setting of retail volumes:

Set as volumes CNT + AH  command: VOLUME_AFTERHOURS CNT+AH
 reply: VOLUME_AFTERHOURS CNT+AH, indicates that the setting in the CNT + AH was performed
Set as volumes CNT  command: VOLUME_AFTERHOURS CNT
 reply: VOLUME_AFTERHOURS CNT, indicates that the setting in the CNT was performed
Set as volumes AH  command: VOLUME_AFTERHOURS AH
 reply: VOLUME_AFTERHOURS AH, indicates that the setting in the AH was performed

Example for the use of the command VOLUMEAFTERHOURS:

in this example are shown with TX commands sent while with RX answers. 17:58:50 TX Connection socket localhost port:100003
17:58:52 RX DARWIN_STATUS;CONN_OK;TRUE;Release 1.2.1 build 01/08/2020 14:10:00 more info..
18:00:11 TX VOLUMEAFTERHOURS
18:00:12 RX VOLUME_AFTERHOURS CNT+AH
18:00:23 TX CANDLE FCA 1 86400
18:00:23 RX BEGIN CANDLES
18:00:33 RX CANDLE;FCA;20141106;09:00:00;8.82500;8.80000;9.01500;8.85000;11597547
18:00:33 RX END CANDLES
18:00:41 TX VOLUMEAFTERHOURS CNT
18:00:41 RX VOLUME_AFTERHOURS CNT
18:00:47 TX CANDLE FCA 1 86400
18:00:47 RX BEGIN CANDLES
18:00:57 RX CANDLE;FCA;20141106;09:00:00;8.84500;8.80000;9.01500;8.85000;11597147
18:00:57 RX END CANDLES
18:01:02 TX VOLUMEAFTERHOURS AH
18:01:02 RX VOLUME_AFTERHOURS AH
18:01:29 TX CANDLE FCA 1 86400
18:01:29 RX BEGIN CANDLES
18:01:39 RX CANDLE;FCA;20141106;09:00:00;8.82500;8.80000;9.01500;8.85000;400
18:01:39 RX END CANDLES
18:01:57 TX VOLUMEAFTERHOURS CNT
18:01:57 RX VOLUME_AFTERHOURS CNT
18:02:01 TX CANDLE FCA 1 86400
18:02:01 RX BEGIN CANDLES
18:02:11 RX CANDLE;FCA;20141106;09:00:00;8.84500;8.80000;9.01500;8.85000;11597147
18:02:11 RX END CANDLES
18:02:38 TX VOLUMEAFTERHOURS CNT+AH
18:02:38 RX VOLUME_AFTERHOURS CNT+AH
18:02:43 TX CANDLE FCA 1 86400
18:02:43 RX BEGIN CANDLES
18:02:53 RX CANDLE;FCA;20141106;09:00:00;8.82500;8.80000;9.01500;8.85000;11597547
18:02:53 RX END CANDLES

The volumes are in bold, and you can see how detailed changes according to our setting,
NB at the end of the connection will return to the default situation (CNT + AH)

Response message to the client:

In this section are reported some examples of the reply after having sent a command for the historical calls, each example is related to one of the four available commands.

Commands for TickByTick


Command TBT

Example of command (to be sent to the server):
TBT REY 1 (REY 1 day)

Command response:
no delta... 11
TBT;REY;20140618;09:09:21;57.55000;11
TBT;REY;20140618;09:09:21;57.55000;12
........
TBT;REY;20140618;13:42:16;57.05000;11966
END TBT

Command TBTRANGE

Example of command (to be sent to the server):
TBTR REY 20140617090000 20140618140000

Command response:
no delta... 0
TBT;REY;20140617;09:12:23;57.90000;56
TBT;REY;20140617;09:12:23;57.90000;114
........
TBT;REY;20140618;13:42:16;57.05000;11966
END TBT


Commands for Candles


Command CANDLE
Example of command (to be sent to the server):
CANDLE REY 1 3600      explanation:(REY 1day 1hour,or 3600 seconds)

Command response:
CANDLE;REY;20140618;09:00:00;57.65000;57.35000;58.10000;57.55000;1115
........
CANDLE;REY;20140618;13:00:00;57.05000;57.00000;57.70000;57.45000;11966

Command CANDLERANGE
Example of command (to be sent to the server):
CANDLERANGE REY 20140617090000 20140618130000 3600      explanation: (REY date_time_start:17/06/2014 09:00:00 date_time_end:18/06/2014 13:00:00 1hour, or 3600 seconds)

Command response:
CANDLE;REY;20140617;09:00:00;57.90000;57.75000;58.25000;58.25000;1089
........
CANDLE;REY;20140618;13:00:00;57.05000;57.00000;57.70000;57.45000;11966

Plugin Directa

Multicharts

The current online version of our pluginIN to connect with Multicharts is 1.83 - 13/0/2020.
To find the installer needed for the connection, you have to follow these steps:
Starting from the Main Board of the Trading site at http://www1.directatrading.com/, click on Info -> point 5a (ADDITIONAL ACTIVATIONS AND VARIATIONS/Additional Activations) -> point 3i (API). At the top you will find listed the two installers, one for the 32bit systems, and the other for the 64bit.

    13/07/2020 Update about 100 days history datas

    27/04/2018 Fixed freeze on cancel order

    21/07/2017 Update market order, autorec, update exit strategy

    09/02/2017 Update history call out of range

    13/01/2017 Update for Darwin Command Line

    14/11/2016 Bugfixed study volume 1Day resolution

    07/04/2016 Latest release available plugin Multicharts

Darwin Command Line

Darwin standalone version without GUI: At the request of some users, we decided to implement a Darwin without any user interface that delivers the data set Darwin described in the API protocol. This version we called Darwin Command Line, will be executable, precisely, via the command line and should already be fully compatible with what you have eventually developed, as it has been possible to use it without additional changes even with our plugin Multicharts. To proceed to download the necessary resources to be able to use this component are available at this address: DCL.jar
The currently available version is the: 1.1.17 - 02/02/2019

    12/11/2018 IDOrder valid in all DCL Session

    26/07/2018 Update for compatibility with Directa Multicharts plugin

    08/06/2018 IdOrder valide in the entire DCL session

    17/05/2018 General Update

    05/01/2018 Update about inactive contact information

    21/07/2017 Update about autore trading

    07/06/2017 Update about Autorec command for datafeed connection

    27/03/2017 Update book5 and bidask - price modify order - different timezone datafeed

    09/03/2017 Bugfix to timezone into datafeed

    19/01/2017 AUTOREC Command into Datafeed connection.

    04/07/2016 First release of the Beta version

Microsoft Excel Add-In

Microsoft Excel Add-In: We have created libraries that allow the connection between Darwin (with and without GUI) and an Excel file, so you can manipulate the data provided by the Protocol API directly on your spreadsheets. In order to use this component you need to download this launcher can be downloaded at this link: SetupXL.exe
This program will copy all necessary files to use Excel with Darwin and open a sample file created by us, after this operation just open your eventual excel files, all the features of this component They are explained in detail in the guide dedicated to this link: ExcelGuide
To update the add-ins will need to use the program and click on ExcelPlugin and will be downloaded and replaced the files necessary to connect without having to perform any manual operation.
Below an image of the application that you install on your PC

ExcelPlugin






    The version currently in line is: 1.0.0 - 29/07/2016.





    29/07/2016  First release of the Beta version


dGO

Specific

The dGO's new version is designed for developer users in particular:

  • The possibility of taking advantage of the AUTOLOGIN: by Selecting Remember, which will save the credentials, the option to click on AutoLogin will get activated allowing the "headless" access, namely without iterations of mouse / keyboard by the user directly into Darwin. To interrupt the AUTOLOGIN phase click on the Cancel button which will send back to the manual input section of the credentials.


              



  • Test connection (telnet)

    It is possible, once started Darwin, to test whether the Prices Service is correctly working. It is enough to be connected on the pc locally using the TELNET function on the port of the service (default 10001).
    It is possible to use the TELNET command for all the defined ports, i.e. the 10001 (DATAFEED), 10002 (Trading) and 10003 (Historical calls).

    Once connected, run the command and type enter (corresponding to the NEWLINE \n ascii 10 character). The system will start sending data.

    The command to be typed in order to verify the connection is: telnet localhost -port-
    Below is an example on a OSX system:


    MacBook-Pro:~$ telnet localhost 10001
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    H
    SUBALL F
    PRICE F 15:58:52;3.446;4388;16063708;6673
    PRICE F 15:58:52;3.446;0;16063708;6673
    BOOK_5 F 15:59:02;8549;4;3.444;25996;11;3.442;57070;16;3.44;39874;11;3.438;21293;7;3.436;75777;14;3.45;33945;12;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BIDASK F 16:00:01;8549;0;3.444;75777;0;3.45
    BOOK_5 F 15:59:03;8549;4;3.444;25996;11;3.442;59981;18;3.44;39874;11;3.438;21293;7;3.436;75777;14;3.45;33945;12;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BOOK_5 F 15:59:03;8549;4;3.444;25996;11;3.442;59981;18;3.44;39874;11;3.438;21293;7;3.436;75777;14;3.45;29600;11;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BOOK_5 F 15:59:04;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;75777;14;3.45;29600;11;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BOOK_5 F 15:59:05;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;75777;14;3.45;33945;12;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BOOK_5 F 15:59:06;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;75777;14;3.45;29600;11;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BIDASK F 16:00:01;12904;0;3.444;75777;0;3.45
    BOOK_5 F 15:59:06;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;75777;14;3.45;29600;11;3.452;23875;9;3.454;38092;11;3.456;24600;8;3.458
    BIDASK F 16:00:01;8549;0;3.444;75777;0;3.45
    BIDASK F 16:00:01;8549;0;3.444;77277;0;3.45
    BOOK_5 F 15:59:06;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;77277;15;3.45;28100;10;3.452;23875;9;3.454;38092;11;3.456;24600;8;3.458
    BOOK_5 F 15:59:07;8549;4;3.444;25996;11;3.442;59981;18;3.44;34734;10;3.438;21293;7;3.436;77277;15;3.45;28100;10;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    BIDASK F 16:00:01;4549;0;3.444;77277;0;3.45
    BOOK_5 F 15:59:08;90;1;3.444;20139;9;3.442;61481;19;3.44;34734;10;3.438;21293;7;3.436;86405;16;3.45;32445;11;3.452;28217;10;3.454;38092;11;3.456;24600;8;3.458
    H
    H
    H
    H
    ^]
    telnet> quit
    Connection closed.
    MacBook-Pro:~ $

    In systems WINDOWS system TELNET is not active by default, but you have to activate it manually

    Code examples


    DATA RECEIVING EXAMPLE

    In this section soma example for the Prices Flow receiving are available, developed in some programming languages:



    //DarwinClient.cs Class that implements the functions Socket
    //CLASS DARWINCLIENT

    using System;
    using System.Net.Sockets;
    namespace DarwinClient
    {
        public class DarwinClient
        {
          private TcpClient clientSocket;
          private String host;
          private int port;
          private NetworkStream serverStream;
          private System.IO.StreamReader streamReader;

          //Constructor - sets HOST and PORT connection
          public DarwinClient (String host, int port)
          {
            this.host = host;
            this.port = port;
            clientSocket = new TcpClient ();
          }

          //Opens the connection to the server
          public void startConnection ()
          {
            clientSocket.Connect (this.host, this.port);
            serverStream = clientSocket.GetStream ();
            streamReader = new System.IO.StreamReader (clientSocket.GetStream ());
          }

          //Terminates the connection
          public void endConnection ()
          {
            clientSocket.Close ();
          }

          //Sends the command to the server ( automatically adds the NEWLINE )
          public void sendCmd (String msg)
          {
            byte[] outStream = System.Text.Encoding.ASCII.GetBytes (msg + "\n");
            serverStream.Write (outStream, 0, outStream.Length);
            serverStream.Flush ();
          }

          //Reads a line from the server
          public String readLine ()
          {
            String returndata = streamReader.ReadLine ();
            return returndata;
          }
        }
      }//end class



    //Main.cs Main program that uses the class DarwinClient and print console data for 120 seconds before closing the connection
    //CLASS MAIN
    using System;

    namespace DarwinClient
    {
      class MainClass
      {

        public static void Main ()
        {
          Console.WriteLine ("Starting client...");
          try {
            //Instantiate the class that server to handle the socket
            DarwinClient dClient = new DarwinClient ("localhost", 10001);
            //Open the connection
            dClient.startConnection ();
            Console.WriteLine ("Connection to localhost:10001 successfull");
            //Send the command (standard subscription Fiat Book + Price + Bidask)
            String cmd = "SUBALL F";
            dClient.sendCmd (cmd);
            Console.WriteLine (" --> " + cmd);
            String line = null;
            long start = DateTime.UtcNow.Ticks;
            bool continua = true;
            //Read for 120 seconds
            while (continua) {
              //Read the next line
              line = dClient.readLine ();
              if (line != null) {
                Console.WriteLine (" <-- " + line);
              }
              long now = DateTime.UtcNow.Ticks;
              long sec = (now - start) / 10000000;
              if (sec > 120) {
                continua = false;
              }
            }
            //End the subscription
            Console.WriteLine ("Terminating subscriptions");
            dClient.sendCmd ("UNS F");
            Console.WriteLine ("Connection closed");
            //Close the socket
            dClient.endConnection ();
          } catch (Exception exx) {
            //If there are errors we display them
            Console.WriteLine ("Error in DarwinClient: " + exx.Message);
            Console.WriteLine (exx.StackTrace);
          }
        }
      }
    }//end class
    //Example in java for connection to the receiving port of the flow rates 10001
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.Socket;
    import java.util.Scanner;

    /**
    *Class example to connect to port 10001 DataFeed .
    *Makes into connection is called a command input,
    *given this command will start the disclosure of the title/s for 60 seconds.
    *Past the minutes will be signed on the title/s and closed the connection.
    *
    *Obviously if you enter an invalid command there will be error code and closing.
    */
    public class ConnectDataFeed{
     Socket s; //use the socket for connection
     PrintWriter pW; //provides methods print and println , which allow you to write any given Java , converting it automatically in string.
     BufferedReader bfr; //uses a buffer to temporarily store the characters to read / write
     int porta; //port on which to access
     String host; //host on which to access
     //variables for code development
     static String tick;
     static boolean verifica=true;

     /**
     *Constructor,in this case we initialize the host and port to connect
     /*
     public ConnectDataFeed(int porta,String host){
      this.porta=porta;
      this.host=host;
     }

       /**
     *Connection to the socket.
     *Create the socket PrintWriter and the buffer.
     */
     private void Connection(){
      try{
       s = new Socket(host, porta);
       pW = new PrintWriter(s.getOutputStream(), true);
       bfr = new BufferedReader(new InputStreamReader(s.getInputStream()));
       System.out.println("Connection successful");
       System.out.println(RLine());
      } catch (Exception e) {
       System.err.println("Unable to connect to the DataFeed: " + e );
      }
     }

     /**
     *Method for the closing of the connection.
     */
     private void closeConnection(){
      try {
       System.out.println("Shutting.");
       pW.close();
       bfr.close();
       s.close();
       System.out.println("closing performed!");
      } catch (Exception e){
       System.err.println("Error disconnecting from the DataFeed: " + e);
      }  }
     /**
     * Method to do the send command given input
     * @param cmd the command
      /*
      private void sendCommand(String cmd){
       pW.println(cmd);
     }

     /**
     * Method to print the contents of the buffer.
     * @return string containing the string buffer
     */
     private String RLine(){
      String line = null;
      try {
        line = bfr.readLine();
      } catch (IOException e) {
       e.printStackTrace();
      }
      return line;
     }

     /**
     * Method used for the printing of the buffer for a number of seconds taken into input
     */
     private void sott_nsec(){
       int timer=120;//seconds
       boolean continue=true;
       String line="";
       long start= System.currentTimeMillis();//variable for the timer
       System.out.println("Print for -->"+timer+"<-- seconds the subscriptions for "+tick);
       while(continue){
        line=RLine();//takes the message from the buffer
        if(line.startsWith("ERR")){
        continue=false;
        verifica=false;
       }
        System.out.println(line);//printing the answer
        long now=System.currentTimeMillis();//management of the timer
        long tot= (now-start)/1000;
        if(tot>timer) continue=false;
      }
     }

     /**
     * Method used to derive the ticker of the title by the command input
     * This method is not essential but it serves to show how unsubscribe a title .
     * It is not important because when you close the connection securities underwritten are unsubscribe.
     * @param cmd input command
     * @return ticker
     */
     private String formatTick(String cmd){
      String formats=cmd.replace(" ", "\t\t\t\t\t\t\t\t");
      String tick=formats.substring(formats.length()-8,formats.length()).trim();
      return tick;
     }
     //The main class
     public static void main(String args[]){
     System.out.println("TEST DATAFEED");

     ConnectDataFeed t=new ConnectDataFeed(10001,"localhost");//object creation
     t.Connection();//Connection

     Scanner scanner = new Scanner(System.in); //Variable management input

     System.out.print("Type the command:");
     String cmd = scanner.nextLine();//input command

     t.sendCommand(cmd);//sending the command

      //Call of the print buffer, with controls
      if(cmd.startsWith("SUB")){
      tick=t.formatTick(cmd);//To take the ticker
      t.sott_nsec();//method for the subscription for n seconds
      if(verifica==true){
       System.out.println("\n unsubscription the title---> UNS "+tick);
       }
      }
     else
      System.out.println(t.RLine());

     t.closeConnection();//close connection
     }
    }
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/socket.h>
    #include <netinet/in.h>
    #include <netdb.h>

    //A method for handling errors,not essential for the connection
    void error(const char *msg)
    {
     perror(msg);
     exit(0);
    }

    //Main class
    int main(int argc, char *argv[])
    {
     int sockfd, portno, n;
     struct sockaddr_in serv_addr;
     struct hostent *server;
     int i=0;
     char buffer[256];
     char command[256];
     int nb;
     int nLine=100;

     printf("Connection to DATAFEED\n\n");

     char host[20];
     sprintf(host,"localhost");

     //variable containing the port number
     portno=10001;
     //opening socket
     sockfd = socket(AF_INET, SOCK_STREAM, 0);
     if (sockfd < 0)
      error("ERROR opening socket");
      //to set the host variable in this case localhost(127.0.0.1)
      server=gethostbyname(host);
     if (server == NULL) {
       fprintf(stderr,"ERROR, no such host\n");
       exit(0);
     }

      //connection management to the socket
      bzero((char *) &serv_addr, sizeof(serv_addr));

      serv_addr.sin_family = AF_INET;

     bcopy((char *)server->h_addr,
      (char *)&serv_addr.sin_addr.s_addr,
      server->h_length);

     serv_addr.sin_port = htons(portno);

     //Management for any errors in connection with the socket
     if (connect(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
      error("ERROR connecting");
     bzero(buffer,256);
     n = write(sockfd, command, strlen(command));

     if (n < 0)
      error("ERROR writing to socket");

      bzero(buffer,256);

     n = read(sockfd, buffer, 255);
     if (n < 0)
      error("ERROR reading from socket");

     //Printing successful connection
      printf("CONNECTION SUCCESSFUL on port%d\n",portno);
      printf("%s\n", buffer);

      //send the client's control in this case as the subscription of FCA
      nb=sprintf(buffer,"SUB FCA\n");
      write(sockfd,buffer,nb);

      while(i<=nLine){
      //Reading and printing the buffer or the server response
      //Print the first 100 rows, then exits the loop
      nb=read(sockfd,buffer,256);
      buffer[nb]=0;
      printf("%d Message from server: %s\n",i,buffer);
      i++;
     }

     //Closing the connection to the socket.
     printf("Closing the connection\n");
     close(sockfd);
     return 0;
    }//end main


     Download file:

    EXAMPLE TRADING

    NB: SAFETY For this example shows a command invented that does no order.

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.Socket;
    import java.util.Vector;

    /**
    * Class of example for connecting to the Trading through port 10002.
    * This example connects the situation and printing portfolio and the list of orders.
    * Then he makes an example of a command to send trading, for safety you entered a command that does NOTHING.
    * After sending the command you will get the answer to video and will close the connection and terminate the program.
    *
    * LOOK OUT:having put a command NULL obviously the answer is NULL, screen will display an H (HeartBeat),
    *  but this is not the answer, but what goes on at that time, that is NULL.
    * /

    public class TradingConnect{
     Socket s; //we use the socket for connection
     PrintWriter pW; //provides methods print and println, which allow you to write any given Java, converting it automatically in string.
     BufferedReader bfr; //uses a buffer to temporarily store the characters to read/write
     int porta; //port on which to access
     String host; //host on which to access
     Vector ordini=new Vector();

     TradingConnect(int porta,String host){
      this.porta=porta;
      this.host=host;
     }

     /**
      * Connection to the socket.
      * To create the socket PrintWriter and the buffer.
      /*
      private void Connessione(){
      try {
       s = new Socket(host, porta);
       pW = new PrintWriter(s.getOutputStream(), true);
       bfr = new BufferedReader(new InputStreamReader(s.getInputStream()));
       System.out.println("Connection Successful");
       System.out.println(RLine());
       System.out.println(RLine());
       boolean state=true;
       System.out.println("List orders");
       System.out.print("Loading");
        while(state){
        String line=RLine();
        if(line.startsWith("ORDER")){
         System.out.print(".");
         ordini.add(line);
         }
        else if(line.startsWith("ERR")){
         System.out.println(line);
         state=false;
        }
        else
         state=false;
       }
       System.out.println(".");
       int i=0;
       while(i     System.out.println(ordini.get(i));
        i++;
       }

        System.out.println("end List");
      } catch (Exception e) {
        System.err.println("Unable to connect to the DataFeed: " + e );
      }
     }

     /**
      * Method for the closing of the connection.
      */
      private void closeConnection(){
      try {
       System.out.println("Shutting.");
       pW.close();
       bfr.close();
       s.close();
       System.out.println("Closing connection successful!");
      catch (Exception e){
        System.err.println("Error disconnecting from the DataFeed: " + e);
      }
     }

     /**
      * Method to print the contents of the buffer.
      * @return string containing the string buffer
      */
      private String RLine(){
      String line = null;
      try {
       line = bfr.readLine();
      } catch (IOException e) {
       e.printStackTrace();
      }
      return line;
     }

     private void sendCommand(String cmd){
      pW.println(cmd);
     }

     public static void main(String[] args){
      TradingConnect t=new TradingConnect(10002,"localhost");
      t.Connessione();
      System.out.println("---End list orders----\n");
      //Try to control trading
      //Taking a sendcmd you could try a command trading,
      //precaution we put an example that does nothing.
      //enter the command
      //command acqz: ACQAZ <order>,<ticker>,<quantity>,<price>
      String cmd="ACQAZ ORD001,PIPPO,10,0.000";
      t.sendCommand(cmd);
      System.out.println(cmd);
      String risposta;
      //in this case the answer will be a heartbeat because our command does nothing
      //specifies that the answer is not the heartbeat but having nothing, print what passes or a H
      risposta=t.RLine();

      System.out.println(risposta);
      t.closeConnection();
     }//end class
    example trading with C Sharp -in development-
    example trading with C -in development-


     Download file:

    EXAMPLE CALLS HISTORICAL

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.PrintWriter;
    import java.net.Socket;

    /**
    * Class example for calls historical socket connection on port 10003
    * Connection on port and connect message occurred through line Darwinstatus,
    *Once connected sends the command via a send and print to video content required.
    */
    public class TbtConnect{
     Socket s; //The socket for connection
     PrintWriter pW; //provides methods print and println, which allow you to write any given Java, converting it automatically in string.
     BufferedReader bfr; //uses a buffer to temporarily store the characters to read/write
     int porta; //port on which to access
     String host; //host on which to access

     public TbtConnect(int porta,String host){
      this.porta=porta;
      this.host=host;
     }

     /**
      *Connection to the socket.
      *To create the socket PrintWriter and the buffer.
      */
     public void Connessione(){
      try {
       s = new Socket(host, porta);
       pW = new PrintWriter(s.getOutputStream(), true);
       bfr = new BufferedReader(new InputStreamReader(s.getInputStream()));
       System.out.println("Connessione avvenuta");
       System.out.println(RLine());
      } catch (Exception e) {
       System.err.println("Unable to connect to the DataFeed: " + e );
      }
     }

     /**
      *Method for the closing of the connection.
      */
      public void closeConnection(){
       try {
        System.out.println("Shutting.");
        pW.close();
        bfr.close();
        s.close();
        System.out.println("Closing connection successful!");
      } catch (Exception e){
       System.err.println("Error disconnecting from the DataFeed: " + e);
      }
     }

     /**
      * Method to do the send command given input
      * @param cmd the command
      */
     public void sendCommand(String cmd){
      pW.println(cmd);
     }

     /**
      * Method to print the contents of the buffer.
      * @return string containing the string buffer
      */
      public String RLine(){
      String line = null;
      try {
       line = bfr.readLine();
      } catch (IOException e) {
       e.printStackTrace();
      }
      return line;
     }

     public static void main(String args[]){
     TbtConnect t=new TbtConnect(10003,"localhost");
     t.Connessione();
     String cmd="CANDLE FCA 1 60";
     //String cmd="TBT FCA 1"; command commented, if you want to try the tbt uncomment
     //TBT <ticker> <nday>
     t.sendCommand(cmd);
     boolean stato=true;
     while(stato){
      String line=t.RLine();
      if(line.equals("END TBT") || line.equals("END CANDLES")){
       System.out.println(line);    stato=false;
      }
      else
       System.out.println(line);
      }
      t.closeConnection();
     }
    } //end class

    import socket
    import time
    import threading
    import Queue


    def worker(socket, stopper, rx_queue):
     """thread worker function"""
     message = ""
     while not stopper.is_set():
      data = client_socket.recv(512)

      if data == "":
       time.sleep(1)
      else:
       message = message + (data)
       if "END " in data:
       print("Message Received");
       rx_queue.put(message)
       message = ""
      return

    ###########################################
    ###########################################


    if __name__ == "__main__":
     rx_queue =Queue.Queue() # create a Thread Safe Queue
     stopper = threading.Event() # create a Thread Safe Event

     client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     client_socket.connect(('localhost', 10003)) # connect to HISTORICAL DATA socket

      t = threading.Thread(target=worker, args=(client_socket, stopper, rx_queue ) )
      t.start()
      time.sleep( 5 )

      print("Extract 1 hour candles")

      print("Extract EOD pricesfor last 5 years")
      cmd="CANDLE MSE 1250 86400"
      client_socket.send(cmd+"\n")
      time.sleep( 5 )

      print("Wait for 15 seconds")
      time.sleep( 15 )

      stopper.set() # force thread stop
      t.join();
      client_socket.close()

      f = open("MSE.txt", 'w')
      while not rx_queue.empty():
       message = rx_queue.get()
       f.write(message)

      f.close()
    print("Done!")
    example trading with C Sharp -in development-
    example trading with C -in development-


     Download file:


    01/08/2020 Update datafeed service, multicharts

    12/11/2018 Update Darwin Command Line section

    26/07/2018  Update Plugin Directa section

    05/02/2018  Add details abot book levels

    05/02/2018  Aggiornamento Tutorial - Esempi di codice (codice per chiamate storiche)

    13/10/2016 Information of Connection Darwin

    13/10/2016 Close Darwin with API command

    13/10/2016 Directa plugin Multicharts information

    13/10/2016 New trading command

    03/12/2015 General Update

    31/03/2015 Introduction a table for Utility History Calls

    19/01/2015 Introduction Mail image and update page

    26/12/2014 Introduction English documentation

    15/12/2014 Update commands section Trading

    10/11/2014 Update introduction activation link in the email

    16/10/2014 Update examples

    08/10/2014 Update Calls section Historical command TBT

    07/10/2014 Update Calls section Historic

    26/08/2014 First release of the page on