com.dukascopy.api
Interface IContext


public interface IContext

Gives access to the various parts of the system


Method Summary
<T> Future<T>
executeTask(Callable<T> callable)
          Every strategy executes in it's own thread.
 IAccount getAccount()
          Returns last known state of the account info.
 IChart getChart(Instrument instrument)
          Returns first chart for specified instrument.
 Set<IChart> getCharts(Instrument instrument)
          Returns set of charts for specified instrument.
 IConsole getConsole()
          Returns interface that allows to write messages into the Messages table
 IEngine getEngine()
          Returns interface of the main engine (order submitting, merging etc)
 File getFilesDir()
          Returns directory where reading and writing is allowed.
 IHistory getHistory()
          Returns interface that allows access to history data
 IIndicators getIndicators()
          Returns interface that allows to calculate indicator values
 IStrategies getStrategies()
          Returns interface that allows to start/stop and control other strategies
 Set<Instrument> getSubscribedInstruments()
          Returns set of the currently subscribed instruments
 IUserInterface getUserInterface()
          Returns an interface which provides control to custom strategy tabs in the main and bottom panels
 boolean isFullAccessGranted()
          Returns true if strategy is granted full access.
 boolean isStopped()
          Returns true if user requested to stop the strategy.
 void pause()
          Pauses historical testing, doesn't have any effect if not in historical tester
 void setSubscribedInstruments(Set<Instrument> instruments)
          Checks that the instruments are subscribed and subscribes to the instrument if it's not.
 void stop()
          Stops strategy execution.
 void subscribeToBarsFeed(Instrument instrument, Period period, OfferSide offerSide, IBarFeedListener listener)
          Subscribes passed listener on bars feed notification by passed instrument, period and offer side
 void subscribeToPointAndFigureFeed(Instrument instrument, OfferSide offerSide, PriceRange priceRange, ReversalAmount reversalAmount, IPointAndFigureFeedListener listener)
          Subscribes passed listener on point and figure feed notification by passed instrument, offer side, price range and reversal amount
 void subscribeToRangeBarFeed(Instrument instrument, OfferSide offerSide, PriceRange priceRange, IRangeBarFeedListener listener)
          Subscribes passed listener on range bars feed notification by passed instrument, offer side and price range
 void subscribeToTickBarFeed(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, ITickBarFeedListener listener)
          Subscribes passed listener on tick bar feed notification by passed instrument, offer side and tick bar size
 void unsubscribeFromBarsFeed(IBarFeedListener listener)
          Unsubscribes passed listener from bars feed notification
 void unsubscribeFromPointAndFigureFeed(IPointAndFigureFeedListener listener)
          Unsubscribes passed listener from point and figure feed notification
 void unsubscribeFromRangeBarFeed(IRangeBarFeedListener listener)
          Unsubscribes passed listener from range bars feed notification
 void unsubscribeFromTickBarFeed(ITickBarFeedListener listener)
          Unsubscribes passed listener from tick bar feed notification
 

Method Detail

getEngine

IEngine getEngine()
Returns interface of the main engine (order submitting, merging etc)

Returns:
main engine

getChart

IChart getChart(Instrument instrument)
Returns first chart for specified instrument. If there is more than one chart for this instrument, then method returns one of them, but always the same.

Parameters:
instrument - currency pair
Returns:
chart

getCharts

Set<IChart> getCharts(Instrument instrument)
Returns set of charts for specified instrument.

Parameters:
instrument - currency pair
Returns:
Set<IChart>

getUserInterface

IUserInterface getUserInterface()
Returns an interface which provides control to custom strategy tabs in the main and bottom panels

Returns:
singleton instance of the IUserInterface

getHistory

IHistory getHistory()
Returns interface that allows access to history data

Returns:
interface for history access

getConsole

IConsole getConsole()
Returns interface that allows to write messages into the Messages table

Returns:
interface for messages sending

getIndicators

IIndicators getIndicators()
Returns interface that allows to calculate indicator values

Returns:
interface for indicator calculations

getAccount

IAccount getAccount()
Returns last known state of the account info. This state is updated once in 5 seconds and can be inaccurate if significant price changes happen on the market

Returns:
account

getStrategies

IStrategies getStrategies()
Returns interface that allows to start/stop and control other strategies

Returns:

setSubscribedInstruments

void setSubscribedInstruments(Set<Instrument> instruments)
Checks that the instruments are subscribed and subscribes to the instrument if it's not. Also locks the instruments so that user could not unsubscribe while strategy is running

Parameters:
instruments - set of instruments, that strategy needs for it's work

getSubscribedInstruments

Set<Instrument> getSubscribedInstruments()
Returns set of the currently subscribed instruments

Returns:
set of the subscribed instruments

stop

void stop()
Stops strategy execution. Current task will be completed. This method doesn't work in IStrategy.onStart()


isStopped

boolean isStopped()
Returns true if user requested to stop the strategy. Can be used to check if strategy was stopped (for example from non strategy threads running in parallel)

Returns:
true if strategy stop was requested

isFullAccessGranted

boolean isFullAccessGranted()
Returns true if strategy is granted full access.

Returns:
true of false depending on access level

executeTask

<T> Future<T> executeTask(Callable<T> callable)
Every strategy executes in it's own thread. This will ensure single threaded model: Any handle method of IStrategy will be executed in order. Submission of orders can be called only from these thread. If some critical action like submitting order needs to be called from other thread, you need to use this method to access strategy thread.

Type Parameters:
T - type of the return value
Parameters:
callable - task to execute
Returns:
Future<T> that can be used to get result of execution

getFilesDir

File getFilesDir()
Returns directory where reading and writing is allowed. Usually ~/My Documents/My Strategies/files

Returns:
directory with free read/write access

pause

void pause()
Pauses historical testing, doesn't have any effect if not in historical tester


subscribeToBarsFeed

void subscribeToBarsFeed(Instrument instrument,
                         Period period,
                         OfferSide offerSide,
                         IBarFeedListener listener)
Subscribes passed listener on bars feed notification by passed instrument, period and offer side

Parameters:
instrument -
period -
offerSide -
listener -

unsubscribeFromBarsFeed

void unsubscribeFromBarsFeed(IBarFeedListener listener)
Unsubscribes passed listener from bars feed notification

Parameters:
listener -

subscribeToRangeBarFeed

void subscribeToRangeBarFeed(Instrument instrument,
                             OfferSide offerSide,
                             PriceRange priceRange,
                             IRangeBarFeedListener listener)
Subscribes passed listener on range bars feed notification by passed instrument, offer side and price range

Parameters:
instrument -
offerSide -
priceRange -
listener -

unsubscribeFromRangeBarFeed

void unsubscribeFromRangeBarFeed(IRangeBarFeedListener listener)
Unsubscribes passed listener from range bars feed notification

Parameters:
listener -

subscribeToPointAndFigureFeed

void subscribeToPointAndFigureFeed(Instrument instrument,
                                   OfferSide offerSide,
                                   PriceRange priceRange,
                                   ReversalAmount reversalAmount,
                                   IPointAndFigureFeedListener listener)
Subscribes passed listener on point and figure feed notification by passed instrument, offer side, price range and reversal amount

Parameters:
instrument -
offerSide -
priceRange -
reversalAmount -
listener -

unsubscribeFromPointAndFigureFeed

void unsubscribeFromPointAndFigureFeed(IPointAndFigureFeedListener listener)
Unsubscribes passed listener from point and figure feed notification

Parameters:
listener -

subscribeToTickBarFeed

void subscribeToTickBarFeed(Instrument instrument,
                            OfferSide offerSide,
                            TickBarSize tickBarSize,
                            ITickBarFeedListener listener)
Subscribes passed listener on tick bar feed notification by passed instrument, offer side and tick bar size

Parameters:
instrument -
offerSide -
tickBarSize -
listener -

unsubscribeFromTickBarFeed

void unsubscribeFromTickBarFeed(ITickBarFeedListener listener)
Unsubscribes passed listener from tick bar feed notification

Parameters:
listener -


Copyright © 2011. All Rights Reserved.