public interface IContext
Modifier and Type | Method and Description |
---|---|
void |
addConfigurationChangeListener(String parameter,
PropertyChangeListener listener)
Register a listener for a strategy configuration parameter which is preceded by a
Configurable annotation. |
void |
closeChart(IChart chart)
Close specified chart.
|
<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(IFinancialInstrument financialInstrument)
Returns first chart for specified instrument.
|
IChart |
getChart(Instrument instrument)
Returns first chart for specified instrument.
|
Set<IChart> |
getCharts()
Returns all open charts.
|
Set<IChart> |
getCharts(IFinancialInstrument financialInstrument)
Returns set of charts 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
|
IDataService |
getDataService()
Returns interface that allows access to system data.
|
IDownloadableStrategies |
getDownloadableStrategies()
Returns interface that allows to handle downloadable strategies
|
IEngine |
getEngine()
Returns interface of the main engine (order submitting, merging etc)
|
IFeedInfoProvider |
getFeedInfoProvider()
NOTE: Under development
|
File |
getFilesDir()
Returns directory where reading and writing is allowed.
|
IFinancialInstrumentProvider |
getFinancialInstrumentProvider()
NOTE: Under development
|
IHistory |
getHistory()
Returns interface that allows access to history data
|
IIndicators |
getIndicators()
Returns interface that allows to calculate indicator values
|
IChart |
getLastActiveChart() |
IReportService |
getReportService()
Returns interface that give access to reporting system
|
IStrategies |
getStrategies()
Deprecated.
use
IClient.startStrategy(IStrategy) instead |
Set<IFinancialInstrument> |
getSubscribedFinancialInstruments()
Returns set of the currently subscribed instruments
|
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
|
JFUtils |
getUtils()
Returns interface with JForex utility methods, e.g., currency converter
|
boolean |
isFullAccessGranted()
Returns true if strategy is granted full access.
|
boolean |
isStopped()
Returns true if user requested to stop the strategy.
|
IChart |
openChart(IFeedDescriptor feedDescriptor)
Opens new chart with specified in
IFeedDescriptor parameters. |
void |
pause()
Pauses historical testing, doesn't have any effect if not in historical tester
|
void |
removeConfigurationChangeListener(String parameter,
PropertyChangeListener listener)
Unregister a listener for a certain configuration parameter which is preceded by a
Configurable annotation. |
void |
setConfigurableChangeListener(ConfigurableChangeListener listener)
Subscribes to configurable changes during the strategy run,
overwrites previously set listener.
|
void |
setSubscribedFinancialInstruments(Set<IFinancialInstrument> financialInstruments)
Checks that the instruments are subscribed and subscribes to the instrument if it's not.
|
void |
setSubscribedFinancialInstruments(Set<IFinancialInstrument> financialInstruments,
boolean lock)
Checks that the instruments are subscribed and subscribes to the instrument if it's not.
|
void |
setSubscribedInstruments(Set<Instrument> instruments)
Checks that the instruments are subscribed and subscribes to the instrument if it's not.
|
void |
setSubscribedInstruments(Set<Instrument> instruments,
boolean lock)
Checks that the instruments are subscribed and subscribes to the instrument if it's not.
|
void |
stop()
Stops strategy execution.
|
void |
subscribeToBarsFeed(IFinancialInstrument financialInstrument,
Period period,
OfferSide offerSide,
IBarFeedListener listener)
Subscribes passed listener on bars feed notification by passed instrument, period and offer side.
|
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 |
subscribeToFeed(IFeedDescriptor feedDescriptor,
IFeedListener feedListener)
Subscribes passed listener on feed notification by passed feed descriptor
|
<T extends ITimedData> |
subscribeToFeed(ITailoredFeedDescriptor<T> feedDescriptor,
ITailoredFeedListener<T> feedListener)
A convenience type-safe method to receive a particular feed data.
|
void |
subscribeToPointAndFigureFeed(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
ReversalAmount reversalAmount,
IPointAndFigureFeedListener listener)
|
void |
subscribeToRangeBarFeed(Instrument instrument,
OfferSide offerSide,
PriceRange priceRange,
IRangeBarFeedListener listener)
|
void |
subscribeToRenkoBarFeed(Instrument instrument,
OfferSide offerSide,
PriceRange brickSize,
IRenkoBarFeedListener listener)
|
void |
subscribeToTickBarFeed(Instrument instrument,
OfferSide offerSide,
TickBarSize tickBarSize,
ITickBarFeedListener listener)
|
void |
subscribeToTicksFeed(IFinancialInstrument financialInstrument,
ITickFeedListener listener)
Subscribes passed listener on ticks feed notification by passed instrument.
|
void |
subscribeToTicksFeed(Instrument instrument,
ITickFeedListener listener)
Subscribes passed listener on ticks feed notification by passed instrument.
|
void |
unsubscribeFromBarsFeed(IBarFeedListener listener)
Unsubscribes passed listener from bars feed notification
|
void |
unsubscribeFromFeed(IFeedListener feedListener)
Unsubscribes passed listener from feed notification
|
void |
unsubscribeFromFeed(IFeedListener feedListener,
IFeedDescriptor feedDescriptor)
Unsubscribes passed listener from feed notification according to the given feed descriptor
|
<T extends ITimedData> |
unsubscribeFromFeed(ITailoredFeedListener<T> feedListener)
Unsubscribes passed listener from feed notification
|
<T extends ITimedData> |
unsubscribeFromFeed(ITailoredFeedListener<T> feedListener,
ITailoredFeedDescriptor<T> feedDescriptor)
Unsubscribes passed listener from feed notification according to the given feed descriptor
|
void |
unsubscribeFromPointAndFigureFeed(IPointAndFigureFeedListener listener)
Deprecated.
|
void |
unsubscribeFromRangeBarFeed(IRangeBarFeedListener listener)
Deprecated.
|
void |
unsubscribeFromRenkoBarFeed(IRenkoBarFeedListener listener)
Deprecated.
|
void |
unsubscribeFromTickBarFeed(ITickBarFeedListener listener)
Deprecated.
|
void |
unsubscribeFromTicksFeed(ITickFeedListener listener)
Unsubscribes passed listener from ticks feed notification
|
IEngine getEngine()
IChart getChart(Instrument instrument)
instrument
- currency pairIChart getChart(IFinancialInstrument financialInstrument)
financialInstrument
- IFinancialInstrument
currency pairSet<IChart> getCharts(Instrument instrument)
instrument
- currency pairSet<IChart>
Set<IChart> getCharts(IFinancialInstrument financialInstrument)
financialInstrument
- IFinancialInstrument
currency pairSet<IChart>
IChart getLastActiveChart()
IChart
object of the last active chart, i.e., the chart which last had focusIChart openChart(IFeedDescriptor feedDescriptor)
IFeedDescriptor
parameters.feedDescriptor
- new chart's feed descriptorIllegalArgumentException
- when feedDescriptor not formed wellvoid closeChart(IChart chart)
chart
- chart to closeIUserInterface getUserInterface()
IHistory getHistory()
IConsole getConsole()
IIndicators getIndicators()
IAccount getAccount()
IDownloadableStrategies getDownloadableStrategies()
JFUtils getUtils()
JFUtils
objectIDataService getDataService()
IReportService getReportService()
IFinancialInstrumentProvider getFinancialInstrumentProvider()
IFinancialInstrument
dataIFeedInfoProvider getFeedInfoProvider()
IFinancialInstrument
datavoid setSubscribedInstruments(Set<Instrument> instruments)
setSubscribedInstruments(Set, boolean)
with lock set as false
context.setSubscribedInstruments(new HashSet(Arrays.asList(Instrument.EURUSD, Instrument.AUDCAD)));
instruments
- set of instruments, that strategy needs for it's workvoid setSubscribedFinancialInstruments(Set<IFinancialInstrument> financialInstruments)
setSubscribedInstruments(Set, boolean)
with lock set as false
IFinancialInstrumentProvider provider = context.getFinancialInstrumentProvider(); IFinancialInstrument eurusdInstr = provider.getFinancialInstrument("EUR/USD"); IFinancialInstrument audcadInstr = provider.getFinancialInstrument("AUD/CAD"); context.setSubscribedInstruments(new HashSet(Arrays.asList(eurusdInstr, audcadInstr)));
financialInstruments
- set of instruments, that strategy needs for it's workvoid setSubscribedInstruments(Set<Instrument> instruments, boolean lock)
context.setSubscribedInstruments(new HashSet(Arrays.asList(Instrument.EURUSD, Instrument.AUDCAD), true));
instruments
- set of instruments, that strategy needs for it's worklock
- false
- method returns fast after invoking and doesn't wait for subscription will be done. true
- otherwise.void setSubscribedFinancialInstruments(Set<IFinancialInstrument> financialInstruments, boolean lock)
IFinancialInstrumentProvider provider = context.getFinancialInstrumentProvider(); IFinancialInstrument eurusdInstr = provider.getFinancialInstrument("EURUSD"); IFinancialInstrument audcadInstr = provider.getFinancialInstrument("AUDCAD"); context.setSubscribedInstruments(new HashSet(Arrays.asList(eurusdInstr, audcadInstr)));
financialInstruments
- set of instruments, that strategy needs for it's worklock
- false
- method returns fast after invoking and doesn't wait for subscription will be done. true
- otherwise.Set<Instrument> getSubscribedInstruments()
Set<IFinancialInstrument> getSubscribedFinancialInstruments()
void stop()
boolean isStopped()
boolean isFullAccessGranted()
<T> Future<T> executeTask(Callable<T> callable)
IStrategy
will be executed in order.
Submission of orders can be called only from this thread.
If some critical action like submitting order needs to be called from another thread, you need to use this method to access
strategy thread. For instance:
Thread thread = new Thread(new Runnable() { public void run() { try { context.executeTask(task); } catch (Exception e) { console.getErr().println(Thread.currentThread().getName() + " " + e); } } }); thread.start();
T
- type of the return valuecallable
- task to executeFuture<T>
that can be used to get result of executionFile getFilesDir()
void pause()
<T extends ITimedData> void subscribeToFeed(ITailoredFeedDescriptor<T> feedDescriptor, ITailoredFeedListener<T> feedListener)
// create type-safe descriptor ITailoredFeedDescriptor<IPointAndFigure> descriptor = new PointAndFigureFeedDescriptor(Instrument.EURUSD, PriceRange.THREE_PIPS, ReversalAmount.THREE, OfferSide.ASK); // create type-safe listener ITailoredFeedListener<IPointAndFigure> listener = new ITailoredFeedListener<IPointAndFigure>() { @Override public void onFeedData(ITailoredFeedDescriptor<IPointAndFigure> feedDescriptor, IPointAndFigure feedData) { // Print IPointAndFigure specific data without casting console.getOut().println(feedData.isRising()); } }; // subscribe context.subscribeToFeed(descriptor, listener);
feedDescriptor
- ITailoredFeedDescriptor
feedListener
- ITailoredFeedListener
subscribeToFeed(IFeedDescriptor, IFeedListener)
<T extends ITimedData> void unsubscribeFromFeed(ITailoredFeedListener<T> feedListener)
feedListener
- ITailoredFeedListener
<T extends ITimedData> void unsubscribeFromFeed(ITailoredFeedListener<T> feedListener, ITailoredFeedDescriptor<T> feedDescriptor)
feedListener
- ITailoredFeedListener
feedDescriptor
- ITailoredFeedDescriptor
void subscribeToFeed(IFeedDescriptor feedDescriptor, IFeedListener feedListener)
feedDescriptor
- IFeedDescriptor
feedListener
- IFeedListener
void unsubscribeFromFeed(IFeedListener feedListener)
feedListener
- IFeedListener
void unsubscribeFromFeed(IFeedListener feedListener, IFeedDescriptor feedDescriptor)
feedListener
- IFeedListener
feedDescriptor
- IFeedDescriptor
void subscribeToTicksFeed(Instrument instrument, ITickFeedListener listener)
instrument
- Instrument
of ticks to listenlistener
- ITickFeedListener
listenervoid subscribeToTicksFeed(IFinancialInstrument financialInstrument, ITickFeedListener listener)
financialInstrument
- IFinancialInstrument
of ticks to listenlistener
- ITickFeedListener
listenervoid unsubscribeFromTicksFeed(ITickFeedListener listener)
listener
- listener to unsubscribevoid subscribeToBarsFeed(Instrument instrument, Period period, OfferSide offerSide, IBarFeedListener listener)
instrument
- Instrument
of bars to listenperiod
- Period
period of bars to listen (Tick period is not supported).offerSide
- OfferSide
of bars to listenlistener
- IBarFeedListener
listenervoid subscribeToBarsFeed(IFinancialInstrument financialInstrument, Period period, OfferSide offerSide, IBarFeedListener listener)
financialInstrument
- IFinancialInstrument
of bars to listenperiod
- Period
period of bars to listen (Tick period is not supported).offerSide
- OfferSide
of bars to listenlistener
- IBarFeedListener
listenervoid unsubscribeFromBarsFeed(IBarFeedListener listener)
listener
- listener to unsubscribevoid addConfigurationChangeListener(String parameter, PropertyChangeListener listener)
Configurable
annotation.
Listener will listen changes of specified property for running strategy.parameter
- either the name of strategy field which is preceded by a Configurable
annotation or
Configurable.value()
- the assigned configurable parameter name that appears besides
its value in GUI.listener
- Listener which will get PropertyChangeEvent
svoid removeConfigurationChangeListener(String parameter, PropertyChangeListener listener)
Configurable
annotation.parameter
- either the name of strategy field which is preceded by a Configurable
annotation or
Configurable.value()
- the assigned configurable parameter name that appears besides
its value in GUI.listener
- Listener which will get PropertyChangeEvent
svoid setConfigurableChangeListener(ConfigurableChangeListener listener)
listener
- listener to subscribe@Deprecated void subscribeToRangeBarFeed(Instrument instrument, OfferSide offerSide, PriceRange priceRange, IRangeBarFeedListener listener)
subscribeToFeed(com.dukascopy.api.feed.ITailoredFeedDescriptor, com.dukascopy.api.feed.ITailoredFeedListener)
instrument
- Instrument
of bars to listenofferSide
- OfferSide
of bars to listenpriceRange
- PriceRange
of bars to listenlistener
- IRangeBarFeedListener
listener@Deprecated void unsubscribeFromRangeBarFeed(IRangeBarFeedListener listener)
unsubscribeFromFeed(com.dukascopy.api.feed.ITailoredFeedListener)
listener
- listener to unsubscribe@Deprecated void subscribeToPointAndFigureFeed(Instrument instrument, OfferSide offerSide, PriceRange priceRange, ReversalAmount reversalAmount, IPointAndFigureFeedListener listener)
subscribeToFeed(com.dukascopy.api.feed.ITailoredFeedDescriptor, com.dukascopy.api.feed.ITailoredFeedListener)
instrument
- Instrument
of P&Fs to listenofferSide
- OfferSide
of P&Fs to listenpriceRange
- PriceRange
of P&Fs to listenreversalAmount
- ReversalAmount
of P&Fs to listenlistener
- IPointAndFigureFeedListener
listener@Deprecated void unsubscribeFromPointAndFigureFeed(IPointAndFigureFeedListener listener)
unsubscribeFromFeed(com.dukascopy.api.feed.ITailoredFeedListener)
listener
- listener to unsubscribe@Deprecated void subscribeToTickBarFeed(Instrument instrument, OfferSide offerSide, TickBarSize tickBarSize, ITickBarFeedListener listener)
subscribeToFeed(com.dukascopy.api.feed.ITailoredFeedDescriptor, com.dukascopy.api.feed.ITailoredFeedListener)
instrument
- Instrument
of tick bars to listenofferSide
- OfferSide
of tick bars to listentickBarSize
- TickBarSize
of tick bars to listenlistener
- ITickBarFeedListener
listener@Deprecated void unsubscribeFromTickBarFeed(ITickBarFeedListener listener)
unsubscribeFromFeed(com.dukascopy.api.feed.ITailoredFeedListener)
listener
- listener to unsubscribe@Deprecated void subscribeToRenkoBarFeed(Instrument instrument, OfferSide offerSide, PriceRange brickSize, IRenkoBarFeedListener listener)
subscribeToFeed(com.dukascopy.api.feed.ITailoredFeedDescriptor, com.dukascopy.api.feed.ITailoredFeedListener)
instrument
- Instrument
of renko bars to listenofferSide
- OfferSide
of renko bars to listenbrickSize
- brick size
of renko bars to listenlistener
- IRenkoBarFeedListener
listener@Deprecated void unsubscribeFromRenkoBarFeed(IRenkoBarFeedListener listener)
unsubscribeFromFeed(com.dukascopy.api.feed.ITailoredFeedListener)
listener
- listener to unsubscribe@Deprecated IStrategies getStrategies()
IClient.startStrategy(IStrategy)
insteadCopyright © 2016. All rights reserved.