PSContent

 

1.    Introduction

                                                                                                                     

2.    Getting License

 

3.    TWSLINK Installation

 

4.    TWSLINK Setup and on principle usage

 

5.    Description of exported functions

 

5.1. TWSLINK general functions

5.1.1.   Function INITDLL

5.1.2.   Function CONNECT

5.1.3.   Function DISCONNECT

5.1.4.   Function SET_DLLPARAM

5.1.5.   Function GET_DLLSTATUS

5.1.6.   Function SET_STOP

5.1.7.   Function SET_BREAK

5.1.8.   Function WAITDLL

5.1.9.   Function WAIT_FOR_REQ_PROCESSED

5.1.10.Function GET_CONNECTED

5.1.11.Function WAIT_FOR_EVENT

5.1.12.Function DISPOSE

5.1.13.Function CONNECT_XML

5.1.14.Function INITDLL_XML

5.1.15.Function GET_EVENT_VAL

5.1.16.Function REQ_CURRENT_TIME

5.1.17.Function TIME_COMPONENT

5.1.18.Function TIME_STRING

5.1.19.Function SECONDS_1970

5.1.20.Function MILLISECONDS_1970

5.1.21.Function SET_TIMER

5.1.22.Function KILL_TIMER

5.1.23.Function PLAY_SOUND

5.1.24.Function GET_EVENT_VAL_L

5.1.25.Function GET_EVENT_VAL_D

 

5.2. Contract related functions

5.2.1.   Function REGISTER_CONTRACT

5.2.2.   Function WAIT_FOR_ACCEPTED

5.2.3.   Function GET_CONTRACT_STATUS

5.2.4.   Function REQ_MARKET_DATA

5.2.5.   Function GET_CONTRACT_VAL

5.2.6.   Function CLOSE_CONTRACT

5.2.7.   Function GET_POSITIONS

5.2.8.   Function GET_STOPPROTECTION

5.2.9.   Function GET_MARKET_DATA

5.2.10.Function GET_TICK

5.2.11.Function QUERY_MARKET_DATA

5.2.12.Function ADD_COMBO_LEG

5.2.13.Function EXTRACT_MARKET_DATA

5.2.14.Function GET_CONTRACTUID_LIST

5.2.15.Function EXTRACT_ARRAY_VALUE

5.2.16.Function WAIT_FOR_TICK

5.2.17.Function CLOSE_CASH_POSITION

5.2.18.Function FORCE_CONTRACT

5.2.19.Function SET_INDICATOR_SIZE

5.2.20.Function VALIDATE_PRICE

5.2.21.Function REM_COMBO_LEG

5.2.22.Function SET_CONTRACT_VAL

5.2.23.Function REQ_BAR_DATA

5.2.24.Function GET_BAR_DATA

5.2.25.Function REGISTER_CONTRACT_XML

5.2.26.Function REGISTER_CONTRACT_XML_STYLE

5.2.27.Function REQ_MARKET_DEPTH

5.2.28.Function GET_MARKET_DEPTH

5.2.29.Function GET_MARKET_DEPTH2

5.2.30.Function REQ_HIST_DATA

5.2.31.Function REQ_SCANNER_PARAMETER

5.2.32.Function REQ_SCANNER_SUBSCRIPTION

5.2.33.Function CANCEL_SCANNER_SUBSCRIPTION

5.2.34.Function PIPS

5.2.35.Function REQ_FUNDAMENTAL_DATA

 

5.3. Order related functions

5.3.1.   Function PLACE_ORDER

5.3.2.   Function SET_ORDERVAL

5.3.3.   Function WAIT_FOR_ORDER_STATUS

5.3.4.   Function WAIT_FOR_ORDER_STATUS_RNG

5.3.5.   Function GET_ORDER_STATUS

5.3.6.   Function GET_ORDER_ERROR

5.3.7.   Function ATTACH

5.3.8.   Function ORDER_MODIFIABLE

5.3.9.   Function TRANSMIT

5.3.10.Function CANCEL_ORDER

5.3.11.Function SET_FA_MEMBERS

5.3.12.Function WAIT_FOR_FILLED

5.3.13.Function BUY_LMT

5.3.14.Function SELL_LMT

5.3.15.Function BUY_STPLMT

5.3.16.Function SELL_STPLMT

5.3.17.Function BUY_MKT

5.3.18.Function SELL_MKT

5.3.19.Function TOGGLE_ORDER

5.3.20.Function BUY_STP

5.3.21.Function SELL_STP

5.3.22.Function BUY_TRAIL

5.3.23.Function SELL_TRAIL

5.3.24.Function CONVERT_ID

5.3.25.Function CONVERT_ID_STRING

5.3.26.Function GET_ORDER_VAL

5.3.27.Function GET_EXECUTION_PRICE

5.3.28.Function GET_ORDERUID_LIST

5.3.29.Function TOGGLE_ORDER_PCT

5.3.30.Function WAIT_FOR_SUBMITTED

5.3.31.Function GET_OPEN_ORDERUID_LIST

 

5.4. Account related functions

5.4.1.   Function GET_ACC_VAL

5.4.2.   Function GET_BASECURRENCY

5.4.3.   Function GET_ACC_NAME

5.4.4.   Function REQ_ACC_UPDATE

5.4.5.   Function GET_CASH_BALANCE

5.4.6.   Function GET_EXCHANGE_RATE

5.4.7.   Function GET_MARKET_VAL

5.4.8.   Function GET_PORTFOLIO_VAL

 

5.5. Callback initialisation

5.5.1.   General Consideration of Callback Usage

5.5.2.   Function SET_EVENT_HANDLER

5.5.3.   Function SET_EVENT_HANDLER_OLE

 

5.6. Miscellaneous functions

5.6.1.   Function SEND_MAIL

5.6.2.   Function SET_LNG_VAR

5.6.3.   Function SET_DBL_VAR

5.6.4.   Function SET_STR_VAR

5.6.5.   Function GET_LNG_VAR

5.6.6.   Function GET_DBL_VAR

5.6.7.   Function GET_STR_VAR

5.6.8.   Function REM_LNG_VAR

5.6.9.   Function CUSTOMCOMMENT

5.6.10.Function START_APPLICATION

5.6.11.Function FROM_FILE

5.6.12.Function TO_FILE

5.6.13.Function REM_DBL_VAR

5.6.14.Function REM_STR_VAR

5.6.15.Function NEWS_BULLETIN

5.6.16.Function CONNECT_DB

5.6.17.Function DISCONNECT_DB

5.6.18.Function SQL

5.6.19.Function SQL2

5.6.20.Function GET_LNG

5.6.21.Function GET_DBL

5.6.22.Function GET_STR

5.6.23.Function ADD_LNG

5.6.24.Function ADD_DBL

5.6.25.Function CUSTOMLOG

5.6.26.Function DELETE_CUSTOMLOG

5.6.27.Function PARSE_XML

 

6.    Tables

6.1. Table Initialisation Flag Values

6.2. Table TWSLINK Parameter Names

6.3. Table TWSLINK Status Identifiers and their possible String Values

6.4. Table Contract Status Identifier

6.5. Table Contract Value Identifiers

6.6. Table Order Property Identifiers

6.7. Table Order Status Identifier

6.8. Table Order Error Identifier

6.9. Table Account Value Identifier

6.10.            Table TWSLINK Loglevel Values

6.11.            Table Callback Function Pointer Definition

6.11.1.Table of Primary Event Mask

6.12.            Table Market Data Field Identifiers

6.12.1.Table Market Data Sub Field Identifiers

6.12.2.Table Market Data ID Values

6.13.            Table TWSLINK Sub-Event Identifiers

6.14.            Table ID Conversion Types

6.15.            Table Market Value IDs

6.16.            Table Portfolio Value IDs

6.17.            Table Indicator Identifiers

6.18.            Table Date/Time Format Specifiers

6.19.            Table Realtime Bar Identifiers

6.20.            Table Contract Property Attribute Names

 

7.    General notes of handling

7.1. Determination

7.2. Plausibility

7.3. Technical Notes/Restrictions´

7.4. API Reference-Help

 

8.    Bug Reporting

 

9.    Compatibility

 

10.  General programming techniques

10.1.            Register Contracts

10.1.1.Register multiple contracts

10.2.            Accessing market data

10.3.            Placing Orders for FA Accounts

10.4.            Attaching Stop/Target Orders

10.5.            The Order ID Types and their Meaning

10.6.            Callback Usage

 

11. Database Support

 

 

1. Introduction

 

The Interface DLL (TWSLINK) is thought to link any Application, that can utilize a DLL or COM, with Interactive Brokers TWS©, for the Purpose of Transmitting and Controlling Orders. All necessary Actions around orderhandling, connection and necessary requests, are done by the TWSLINK. This allows the user to concentrate on the strategy behind. Various functions take control over orders, contracts and account.

 

An extensive and scaleable logging allows users to track and fix problems and gives him the chance to integrate TWSLINK with his Strategy Builder / Signal Server to his preferred way.

 

Various samples e.g. for TradeStateson 2000i© given in .ELS – Format, Excel etc, demonstrate the use of TWSLINK. However, it should be easy to call all exported DLL-Functions from any other application that allows DLL Function Call or COM.

 

Several TWSLINK-Parameters take effect on how to connect to TWS, sizing buffers, timing delays for automatic reconnection etc.. But don’t feel cluttered by to many setup parameters. Most of these parameters can be used with their default-value.

 

2. Getting License

 

TWSLINK is provided as demo versions. It comes with no restrictions except runtime limited to 2 hours. You can get a unlimited license by purchasing EUR 180,- vial PayPal for

 

ce_@gmx.de.

 

 

You can easily create a PayPal account without costs. Only a valid credit card is needed. Its number is transferred to PayPal once when creating an account.

 

Once you have fnished the payment, you can activate TWSLink by using the Set License Key dialog which can be accessed through the trayicon in the the lower right corner of your taskbar. Once this key is set, it is stored in file twslink.lic

and the key is loaded automatically from this file at next startup. (If you need to move with TWSLink, take this file on the trip as well).

 

Set Identification Dialog: You need to input license key only.

 

 

 

Note: The demoversion has a runtime of 2 hours. After all exported functions are inaccessible expect

DISCONNECT , CANCEL_ORDER, CLOSE_CONTRACT and CLOSE_CASH_POSITION.

 

The Use of the TWSLINK is at your own Risk. The Author is not responsible for any monetary loss or physical or mental damage that could be related to the use of TWSLINK. It is strongly recommend to test the TWSLINK with Demo- or Paper Account before trading on real accounts.

 

 

3. TWSLINK Installation

 

Simply run TWSLink.msi. Pay attention to the Readme/Install Text-Files in each sample directory. Depending of the language to which the Samples refer, additionally components may have to be installed (e.g. Perl, Python).

 

 

4. TWSLINK Setup and on principle usage.

 

A high-beep indicates that the DLL has been loaded. In contrariwise, a low-beep signals DLL has been unloaded. In Addition a Tray Icon shows DLL Status and Account Information. The Final Information String of the Tray has Format:

           

            Account Name (or Short List FA Accounts)

            [clientid][process id]

            current net liquidation value in base currency

            runtime net liquidation delta value in base currency

 

Tray Icons and their Meaning:

Icon

Meaning

TWSLink is not connected.

TWSLink is connecting.

Connection to TWS established.

No License. This is shown in the 2. tray window, left of TWSLink tray.

Demo License. This is shown in the 2. tray window, left of TWSLink tray.

License granted. Only few seconds visible. This is shown in the 2. tray window, left of TWSLink tray.

 

                                              

 

Before placing orders, requesting marketdata or calling any other contract dependent function, you need to register a contract first in order to obtain a unique id.

 

Call:

            Contractuid= REGISTER_CONTRACT(…).                                

 

Now connect to TWS. This Function normally has to be called once, if the automatic reconnect timer is enabled.

Call:

            CONNECT(…).                        

 

 

Check if your contract(s) has been accepted by TWS.

 

If WAIT_FOR_ACCEPTED(Contractuid, 000) >= -1 then

Begin

    Do Your Trading Actions…

End

            Else Begin

                CUSTOMCOMMENT(“Something is wrong with my Contract Specification”,1,1)         

            End

 

 

5. Description of Exported Functions

 

5.1 TWSLINK Initialisation and Setup

 

 

5.1.1 Function INITDLL            back

 

Description:     Function removed.

 

 

     

5.1.2 Function CONNECT        back

 

Description:     Connect to TWS.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Connection established.

0

Connection failed.

 

Parameter Table

#

Name

Type

Comment

Default

1

Host

LPSTR

Host for TWS Connection.

127.0.0.1

2

Port

int

Port for TWS Connection.

 

3

startingClientId

int

Preferred TWS Client ID for TWSLINK Connection.

Set < 0 to allow TWSLink try Connection on next free ClientId.

1

4

Timeout

int

Timeout in Minutes. Pass -1 to wait Infinite.

5000

 

Comments:

  • An initial Call of this Function activates also the Reconnection Timer unless its Loop Timeparameter > 0.

 

Sample:           Connect to TWS at 192.166.0.2:7496 and use ClientID=1.

retcode = CONNECT (”192.166.0.2”,7496,1 ,-1)

Connect to TWS at 192.166.0.2:7496 and start with ClientID=1 and allow TWSLink to try next ClientId if Id=1 should be already used by another Client.

retcode = CONNECT (”192.166.0.2”,7496,-1 ,-1)

 

 

5.1.3 Function DISCONNECT               back

 

Description:     Disconnect from TWS. Once called, it stop the automatic reconnect-cycle. Normally this function has not to be called as TWSLink calls it before being unloaded.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Ok.

0

No Ok.

 

Sample:           retcode = DISCONNECT ()

 

 

5.1.4 Function SET_DLLPARAM          back

 

Description:     Set a specific DLL parameter.  This is usually called to set a parameter which Initialisation is not supported by INITDLL.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Ok.

0

Parameter couldn’t be set.

-2

Parameter unknown.

 

Parameter Table

#

Name

Type

Comment

Value Ref.

1

sCommand

LPSTR

Name of Parameter.

Table 6.2

2

sParam

LPSTR

Value of Parameter as string.

 

 

Sample:           Set the minimum delay between 2 commands to 300 milliseconds.

retcode = SET_DLLPARAM ("setcmddelay",“300“) 

 

 

5.1.5 Function GET_DLLSTATUS        back

 

Description:     Get the status of a specific DLL parameter (property).

 

Return Type:    string  (Constant String)

 

Return Value Table

Value

Meaning

String describing the Status.

Table 6.3 Value.

“nok”

#1 unknown.

 

Parameter Table

#

Name

Type

Comment

Value Ref.

1

sParam

string

Name of Status.

Table 6.3

2

lParam

int

Additional Integer Parameter. Its use depends on #1.

 

2

sParam2

string

Additional String Parameter. Its use depends on #1.

 

 

Sample:           Get the Connection Status of TWSLINK.

StringStatus = GET_DLLSTATUS("connected",0,””) 

Check if Exchange ISLAND is in the List of unavailable Exchanges

ISLAND_UNAV = GET_DLLSTATUS("exunav",0,”ISLAND) 

 

 

5.1.6 Function SET_STOP       (not threadsafe) back

 

Description:     Set Stop Flag to enable/disable Function Call. The same Effect can be obtained by calling SET_DLLPARAM with #1 = “setfunctioncall” and Value = “1” or “0”. Unlike SET_STOP, a Call of SET_DLLPARAM is threadsafe. On the other Hand,  SET_DLLPARAM could be locked due to a Prior Call of another threadsafe Function. So call SET_STOP in Emergency Situations only and take care to call this Function from one Thread only. Normally there should be no Need to call this Function. It is thought as Escape from unormal Situations during Tests.

 

Return Type:    int

 

Return Value Table

Value

Meaning

New Stop Flag Value

 

 

Parameter Table

#

Name

Type

Comment

Value Ref.

1

Flag

int

If 1, Function gets disabled, otherwhise enabled

 

 

Sample:           Stop Function Call.

int_FunctionCallDisabled = SET_STOP(1) 

 

 

5.1.7 Function SET_BREAK    back

 

Description:     Function removed.

 

 

5.1.8 Function WAITDLL back

 

Description:     Pauses execution of calling thread.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Pause finished,

0

Function Call stopped.

 

 

Parameter Table

#

Name

Type

Comment

Value Range

1

Duration

int

Duration of Pause in Milliseconds

> 0

 

Sample:           Let the calling Thread sleep 1.5 Seconds.

WAITDLL(1500) 

 

 

5.1.9 Function WAIT_FOR_REQ_PROCESSED  back

 

Description:     Waits until most important requests has been answered by TWS. This function can be used if one or more functions have been called which require an answer from TWS (like REGISTER_CONTRACT, PLACE_ORDER, etc.) to wait until all of these requests have been answered. If function returns 1, you can gather for instance contract status and order status without waiting for them.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Latest Requests finished,

0

Timeout or there are still pending Request.

-1

Not connected.

-2

Function Call stopped.

 

 

Parameter Table

#

Name

Type

Comment

Value Range

1

Duration

int

Time for Function Returns.

If 0, Function returns immediately after having checked for pending Requests.

If > 0, Function waits the passed Time for all Requests having finished.

> 40

< 10000

 

Comments:

  • Currently the Functions respects 5 Types of Requests:

1. Requests for Account Updates

2. Requests for Contract Details.

3. Requests for Order States.

4. Requests for Executions.

5. Requests for Open Orders.

 

Sample:           Give IB Server/TWS 5 Seconds to process latest Requests.

WAIT_FOR_REQ_PROCESSED(5000) 

 

 

5.1.10 Function GET_CONNECTED     back

 

Description:     Get Connection Status.

 

Return Type:    int

 

Return Value Table

Value

Meaning

2

DLL connected to TWS and TWS connected to IB Server.

1

DLL connected to TWS.

0

DLL not connected to TWS.

 

Comments:

  • It is not really necessary to distinguish between return Value 1 and 2. But may some developers may want to have access to this Detail.

 

Sample:           Check Connection.

IsConnected = GET_CONNECTED() 

If IsConnected >= 1 then

End

      All ok

Else

      May I should wait with further operations

end

 

 

5.1.11 Function WAIT_FOR_EVENT  back

 

Description:     Wait for next event. An Event is of the same structure as the callback parameter Set. Table 6.11 describes the event structure.

 

Return Type:    int

 

Return Value Table

Value

Meaning

> 0

UID of Event.

0

No Event in the Meantime or asked Event not occurred in the Meantime.

-1

Event Category (#1) not matching.

-2

Event Subcateory (#2) not matching.

2147483647

Function Call disabled.

 

Parameter Table

#

Name

Type

Comment

Value Range

1

timeout

Long

Timeout

=> 0

 

Comments:

  • You can access to all event members by the various GET_EVENT_VAL functions.
    But be aware, the next call of WAIT_FOR_EVENT frees the event identified by the uid of the prior call of WAIT_FOR_EVENT. So finish process of event completely before next call of WAIT_FOR_EVENT.
  • Once you have an Event ID - returned Value > 0 - all Event Member Values can be accessed by calling Function GET_EVENT_VAL or GET_EVENT_VAL_L or GET_EVENT_VAL_D.

 

Sample:           Wait at the most of 5 Seconds for next Event.

EventId = WAIT_FOR_EVENT(5000) 

 

 

5.1.12 Function DISPOSE  back

 

Description:     Clean up Ressources. This Function should be called in .NET Environments before closing the Application as well as in all other Environments if TWSLink should hang on shutdown.

 

Return Type:    int

 

Return Value Table

Value

Meaning

0

ok

 

Comments:

  • Once this function has been called, TWSLink can’t be reactivated.

 

Sample:           Clean up DLL internal Ressources.

Ret = DISPOSE() 

 

 

5.1.13 Function CONNECT_XML          back

 

Description:     Connect to TWS with Parameters predefined in xml Setup File.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Connection established.

0

Connection failed.

-1

Unknown Connection Id.

 

Parameter Table

#

Name

Type

Comment

Default

1

connectionid

int

Id of Connection in xml Setup File.

 

2

timeout

int

Timeout of Connection in ms.

 

 

Comments:

  • An initial Call of this function activates also the reconnection timer as int its loop timeparameter > 0.
  • Format of Connection Tag in xml Setup File:

    <connections>

         <cnct id="1" ip="192.168.5.1" port="7496" clientid="1" desc="accountname"/>

   </connections>

Sample:           Connect to TWS with connection of id=3. allow a 10 second timeout.

retcode = CONNECT_XML (3,10000)

 

 

5.1.14 Function INITDLL_XML back

 

Description:     Function removed.

 

 

 

5.1.15 Function GET_EVENT_VAL                  back

 

Description:     Get Value as string for specified event.

 

Return Type:    string

 

Return Value Table

Value

Meaning

Any String

Value demanded for as String.

“nok”

Function Call stopped.

“enf”

Event not found.

“vnf”

Value id unknown.

 

Parameter Table

#

Name

Type

Comment

1

uidevent

int

Unique ID of Event. Previously returned by WAIT_FOR_EVENT or

-1 to refer to latest Event.

2

valueid

int

Id of Value to be returned. Table 6.11.

 

Sample:           Get Value of 2. int Member of Event with uid=69 as String

retcode = GET_EVENT_VAL(69,2)

 

 

5.1.16 Function REQ_CURRENT_TIME                        back

 

Description:     Get server time as passed seconds since 01/01/1970.

 

Return Type:    int

 

Return Value Table

Value

Meaning

Any Value

Seconds Past since 01/01/1970

0

Internal Error.

-1

Function Call stopped.

-2

Memerror

 

Parameter Table

#

Name

Type

Comment

1

timeout

int

Timeout for server response in Milliseconds.

 

Sample:           Wait at the most 1 Second to get current Server Time.

PastSeconds = GET_CURRENT_TIME(1000)

 

 

5.1.17 Function TIME_COMPONENT               back

 

Description:     Get time component – Year, Month, Day, Hour, Minute or Second of time given in seconds passed since 01/01/1970.

 

Return Type:    int

 

Return Value Table

Value

Meaning

Any Value

Component value.

0

Function Call stopped.

-1

Error. Invalid time.

 

Parameter Table

#

Name

Type

Comment

1

timeinseconds

int

Seconds passed since 01/01/1970

2

componentcode

int

1: Year
2: Month
3: Day
4: Hour
5: Minute
6: Second

 

Sample:           Get Day of date represented by time value 1207672395.

Day = TIME_COMPONENT(1207672395,3)

-> 8

 

 

5.1.18 Function TIME_STRING                        back

 

Description:     Get formatted time string for time given in seconds passed since 01/01/1970.

 

Return Type:    string

 

Return Value Table

Value

Meaning

Any Value

Time formatted as string.

nok

Function Call stopped.

emtpy

Error. Invalid time.

 

Parameter Table

#

Name

Type

Comment

1

timeinseconds

int

Seconds passed since 01/01/1970

2

format

string

Format string. (Table 6.18)

 

Sample:           Get time string formatted of time represented by time value 1207672395.

TimeString = TIME_STRING(1207672395,”%Y-%m-%d %H:%M:%S”)

-> 2008-04-08 18:33:15

 

 

5.1.19 Function SECONDS_1970                     back

 

Description:     Seconds passed from 01/01/1970 to now.

 

Return Type:    int

 

Return Value Table

Value

Meaning

Any Value

Seconds value.

0

Function Call stopped.

-1

Internal Error.

 

Sample:           Get seconds from 01/01/1970 to now..

seconds = SECONDS_1970()

 

 

5.1.20 Function MILLISECONDS_1970            back

 

Description:     Milliseconds passed from 01/01/1970 to now.

 

Return Type:    double

 

Return Value Table

Value

Meaning

Any Value

Seconds value.

0

Function Call stopped.

-1

Internal Error.

 

 

Sample:           Get milliseconds from 01/01/1970 to now..

mseconds = MILLISECONDS_1970()

 

 

5.1.21 Function SET_TIMER                back

 

Description:     Set a timer.

 

Return Type:    int

 

Return Value Table

Value

Meaning

Any Value

Id of timer (used to reference timer event and to stop timer)

0

Function Call stopped.

-1

Error. Invalid time.

 

Parameter Table

#

Name

Type

Comment

1

delayinms

int

Timer delay in milliseconds.

 

Comments:

  • Note: Delay must be integer divideable by masterclock value (xml::dllparam::masterclock)

 

Sample:           Set a 2 second timer.

id = SET_TIMER(2000)

 

 

5.1.22 Function KILL_TIMER               back

 

Description:     Kill specific/all timer(s).

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Ok

0

Function Call stopped.

-1

Error. Invalid time.

 

Parameter Table

#

Name

Type

Comment

1

idoftimer

int

> 0: Kill timer with id=#1.
0: Kill all timers.

 

Sample:           Kill timer with id=3

res = KILL_TIMER(3)

 

 

5.1.23 Function PLAY_SOUND                        back

 

Description:     Play specified soundfile or stop playing all soundfiles.

 

Return Type:    int

 

Return Value Table

Value

Meaning

1

Ok

0

Function Call stopped.

-1

Error.

 

Parameter Table

#

Name

Type

Comment

1

soundfilename

string

Path and name of soundfile.

2

loop

int

1: play in loop.
0: play once.

3

exclusive

int

1: play passed file only.

0: play passed file also.

 

Sample:           Play soundfile c:\mysound.wav in a loop exclusive

res = PLAY_SOUND(“c:\\mysound.wav”,1,1)

Stop playing all files.

res = PLAY_SOUND(“”,1,1)

 

 

5.1.24 Function GET_EVENT_VAL_L              back

 

Description:     Get Value as Long for specified Event.

 

Return Type:    int

 

Return Value Table

Value

Meaning

Any Value

Value demanded for as String.

2147483647

Function Call stopped.

2147483646

Event not found.

2147483645

Value id unknown.

 

Parameter Table

#

Name

Type

Comment

1

Uidevent

int

Unique ID of Event. Previously returned by WAIT_FOR_EVENT or

-1 to refer to latest Event.

2

Valueid

int

Id of Value to be returned. Table 6.11.

 

Sample:           Get Value of 2. int Member of Event with uid=69 as Long.

retcode = GET_EVENT_VAL_L(69,2)

 

 

5.1.25 Function GET_EVENT_VAL_D              back

 

Description:     Get Value as Double for specified Event.

 

Return Type:    double

 

Return Value Table

Value

Meaning

Any Value

Value demanded for as String.

888888888888888

Function Call stopped.

777777777777777

Event not found.

777777777777776

Value id unknown.

 

Parameter Table

#

Name

Type

Comment

1

Uidevent

int

Unique ID of Event. Previously returned by WAIT_FOR_EVENT or

-1 to refer to latest Event.

2

Valueid

int

Id of Value to be returned. Table 6.11.

 

Sample:           Get Value of 2. double Member of Event with uid=69 as Double.

retcode = GET_EVENT_VAL_D(69,6)

 

 

5.2 Contract Related Functions

 

5.2.1 Function REGISTER_CONTRACT           back

 

Description:     Register a Contract. This Function must be called once before any Function is called that needs a Contract ID Parameter (e.g. PLACE_ORDER).

 

Return Type:    int

 

Return Value Table

Value

Meaning

> 0

Unique TWSLINK internal Contract ID (UID). Contract Registration successful.

= 0

The Request defines multiple Contracts.

< 0

Registration failed.

 

Parameter Table

#

Name

Type

Comment

Format/ poss. Values/Sample

1

symbol

LPSTR

Symbol Name of Contract.

e.g. “MSFT”, “QM”

2

sectype

LPSTR

Security Type Abbreviation of Contract.

STK” for Stock

FUT” for Future

FOP” for Futures Option

OPT” for Option

CASH” for Forex

BAG” for Bag

IND” for Index

3

currency

LPSTR