-
Notifications
You must be signed in to change notification settings - Fork 73
Trading agents
A trading strategy, within the quantcomponents framework, is simply an OSGi service, implementing
the interface:
com.quantcomponents.algo.ITradingAgentFactory
Once a service implementing this interface is activated in the OSGi framework where a
Trading Agent Manager exists, it will be available in the UI, as a robot-shaped icon.
public interface ITradingAgentFactory extends ISeriesProcessorFactory<Date, Double> {
ITradingAgent createProcessor(Properties configuration);
}
This interface is used to create a trading strategy instance, implementing:
com.quantcomponents.algo.ITradingAgent
for each execution.
Please refer to the API documentation and to the
example code provided, to learn how to build a new strategy.
To create a new strategy, open the Plugin-in development perspective in Eclipse, and create a
plugin project, targeted to run in an OSGi framework.
Create a class implementing com.quantcomponents.algo.ITradingAgentFactory
, and register it
as a service, by means of the OSGi activator, by Declarative Services, etc.
Probably the easiest way to do it is by using a Declarative Service Component definition, as in the
example code here.
Please note that once a component file has been created, its path must be added to the META-INF/MANIFEST-MF
with the following syntax:
Service-Component: OSGI-INF/averageCrossingTAFactory.xml
A succinct guide to creating OSGi bundles as Declarative Services components is found
here.
Once the bundle has been created, it is possible to install it in the running Eclipse in a very
convenient way, thanks to the Apache Felix Fileinstall service,
which has been installed as a dependency of the quantcomponents feature.
This service monitors file system directories, and deploys into the OSGi framework any bundle that
is found in them.
In particular, if the installation have been done correctly, the Felix Fileinstall service is
monitoring two directories:
<quantcomponents config>
<quantcomponents config>/plugins
While the first directory is used to pass service configurations to the OSGi Config Admin service, and it essential to create an instance of the IB Adapter, the second directory is used to deploy and un-deploy OSGi bundles into the running system.
In order to deploy a new strategy bundle into the framework:
- Right-click on the strategy project, and select Export....
- Choose Plug-in Development -> Deployable plug-ins and fragments.
- Leave all the defaults (check that only the new bundle project is selected), and, under Destination, select Directory.
- Use the Browse button and select the
<quantcomponents config>
directory, as configured from the [installation](Eclipse feature installation). Attention! Theplugins
directory must not be selected, since Eclipse will create it, if not existing, and it will copy the new bundle in there anyway.
Once the export process is complete, the new bundle should be installed and activated into the OSGi framework, and a new robot-shaped icon should be available in the Trading Agents view if you right-click the TradingAgentManager and select Refresh.
To remove the new bundle, simply remove the bundle directory from the <quantcomponents config>/plugins
directory, and refresh the view.