com.dukascopy.api.system
Interface IClient

All Known Subinterfaces:
ITesterClient

public interface IClient

Main entry point for the connection to the server


Method Summary
 void addNewsFilter(INewsFilter newsFilter)
          Adds news filter
 void connect(String jnlp, String username, String password)
          Authenticates and connects to dukascopy servers
 void connect(String jnlp, String username, String password, String pin)
          Authenticates and connects to dukascopy servers
 BufferedImage getCaptchaImage(String jnlp)
          Returns the image that can be provided to the user to generate correct pin code
 INewsFilter getNewsFilter(INewsFilter.NewsSource newsSource)
          Returns news filter for the source
 Map<Long,IStrategy> getStartedStrategies()
          Returns map with ids mapped to associated strategies
 Set<Instrument> getSubscribedInstruments()
          Returns subscribed instruments
 boolean isConnected()
          Returns true if client is authenticated authorized and transport is in connected state
 IStrategy loadStrategy(File strategyBinaryFile)
          Loads strategy from jfx file
 void reconnect()
          Tries to reconnect transport without reauthenticating.
 INewsFilter removeNewsFilter(INewsFilter.NewsSource newsSource)
          Removes news filter, resetting it to the default value
 void setCacheDirectory(File cacheDirectory)
          Sets the location of the cache files.
 void setErr(PrintStream err)
          Sets stream that will be passed to the strategy through IConsole.
 void setOut(PrintStream out)
          Sets stream that will be passed to the strategy through IConsole.
 void setSystemListener(ISystemListener systemListener)
          Sets the listener, that will receive notifications about connects disconnects and strategies starts and stops
 void setSubscribedInstruments(Set<Instrument> instruments)
          Subscribes to the specified instruments set
 long startStrategy(IStrategy strategy)
          Starts the strategy with default exception handler that will stop strategy if it trows exception
 long startStrategy(IStrategy strategy, IStrategyExceptionHandler exceptionHandler)
          Starts the strategy
 void stopStrategy(long processId)
          Stops the strategy with the specified id
 

Method Detail

connect

void connect(String jnlp,
             String username,
             String password)
             throws JFAuthenticationException,
                    JFVersionException,
                    Exception
Authenticates and connects to dukascopy servers

Parameters:
jnlp - address of jnlp file, that is used to launch platform
username - user name
password - password
Throws:
JFAuthenticationException - authentication error, incorrect username or password, IP address unrecognized in case of LIVE systems
JFVersionException - version is blocked on the server, update your libraries
Exception - all kinds of errors that resulted in exception

connect

void connect(String jnlp,
             String username,
             String password,
             String pin)
             throws JFAuthenticationException,
                    JFVersionException,
                    Exception
Authenticates and connects to dukascopy servers

Parameters:
jnlp - address of jnlp file, that is used to launch platform
username - user name
password - password
pin - pin code generated with the captcha from the last getCaptchaImage(java.lang.String) call
Throws:
JFAuthenticationException - authentication error, incorrect username or password, IP address unrecognized in case of LIVE systems
JFVersionException - version is blocked on the server, update your libraries
Exception - all kinds of errors that resulted in exception

getCaptchaImage

BufferedImage getCaptchaImage(String jnlp)
                              throws Exception
Returns the image that can be provided to the user to generate correct pin code

Parameters:
jnlp - address of jnlp file, that is used to launch platform
Returns:
captha image
Throws:
Exception - if request for captcha failed

reconnect

void reconnect()
Tries to reconnect transport without reauthenticating. Method is asynchronous, meaning it will exit immidiately after sending connection request without waiting for the response. Caller will receive notification through ISystemListener interface


isConnected

boolean isConnected()
Returns true if client is authenticated authorized and transport is in connected state

Returns:
true if there is open and working connection to the server

startStrategy

long startStrategy(IStrategy strategy)
                   throws IllegalStateException,
                          NullPointerException
Starts the strategy with default exception handler that will stop strategy if it trows exception

Parameters:
strategy - strategy to run
Returns:
returns id assigned to the strategy
Throws:
IllegalStateException - if not connected
NullPointerException - if one of the parameters is null

startStrategy

long startStrategy(IStrategy strategy,
                   IStrategyExceptionHandler exceptionHandler)
                   throws IllegalStateException,
                          NullPointerException
Starts the strategy

Parameters:
strategy - strategy to run
exceptionHandler - if not null then passed exception handler will be called when strategy throws exception
Returns:
returns id assigned to the strategy
Throws:
IllegalStateException - if not connected
NullPointerException - if one of the parameters is null

loadStrategy

IStrategy loadStrategy(File strategyBinaryFile)
                       throws Exception
Loads strategy from jfx file

Parameters:
strategyBinaryFile - jfx file
Returns:
loaded strategy
Throws:
Exception - if loading failed

stopStrategy

void stopStrategy(long processId)
Stops the strategy with the specified id

Parameters:
processId - id of the strategy

getStartedStrategies

Map<Long,IStrategy> getStartedStrategies()
Returns map with ids mapped to associated strategies

Returns:
started strategies

setSystemListener

void setSystemListener(ISystemListener systemListener)
Sets the listener, that will receive notifications about connects disconnects and strategies starts and stops

Parameters:
systemListener - listener

addNewsFilter

void addNewsFilter(INewsFilter newsFilter)
Adds news filter

Parameters:
newsFilter - news filter

getNewsFilter

INewsFilter getNewsFilter(INewsFilter.NewsSource newsSource)
Returns news filter for the source

Parameters:
newsSource - news source
Returns:
news filter

removeNewsFilter

INewsFilter removeNewsFilter(INewsFilter.NewsSource newsSource)
Removes news filter, resetting it to the default value

Parameters:
newsSource - news source
Returns:
news filter removed

setSubscribedInstruments

void setSubscribedInstruments(Set<Instrument> instruments)
Subscribes to the specified instruments set

Parameters:
instruments - set of the instruments

getSubscribedInstruments

Set<Instrument> getSubscribedInstruments()
Returns subscribed instruments

Returns:
set of the subscribed instruments

setOut

void setOut(PrintStream out)
Sets stream that will be passed to the strategy through IConsole. Default out is System.out

Parameters:
out - stream

setErr

void setErr(PrintStream err)
Sets stream that will be passed to the strategy through IConsole. Default err is System.err

Parameters:
err - stream

setCacheDirectory

void setCacheDirectory(File cacheDirectory)
Sets the location of the cache files. Default is System.getProperty("java.io.tmpdir") + "/.cache"

Parameters:
cacheDirectory - directory where cache files should be saved


Copyright © 2011. All Rights Reserved.