@Documented
@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface Configurable
Parameter type | Applicable Java types | Representation | Remote mode differences |
Number | int, double, short, long, Integer, Double, Short, Long | Number field with a modifiable step size | |
Boolean | boolean, Boolean | Checkbox | |
String | String | Text field | |
File | java.util.File | Text field with a path and a file chooser | |
Date | java.util.Calendar, java.util.Date, long and Long with Configurable.datetimeAsLong = true | Date picker | |
Color | java.util.Color | Color picker | |
Constants | any enum or Enum or a class containing self-typed public static final fields | Single-selection combobox | User-defined constants via Configurable.options |
Collection of constants | java.util.Collection of any enum or Enum or a class containing self-typed public static final fields | Multi-selection dialog | User-defined constants are not allowed |
IFeedDescriptor | IFeedDescriptor implementations from com.dukascopy.api.feed.util | Data feed chooser dialog |
Consider the following parameter usage examples:
@Configurable(value = "int param", stepSize = 3)
public int intParam = 1;
@Configurable(value = "double param", stepSize = 0.5)
public double doubleParam = 0.5;
@Configurable("bool param")
public boolean boolParam = true;
@Configurable("text param")
public String textParam = "some text";
@Configurable("")
public File file = new File(".");
@Configurable(value="current time", description="default is current time")
public Calendar currentTime = Calendar.getInstance();
@Configurable("")
public Color color = new Color(100, 100, 100);
@Configurable("instrument (enum)")
public Instrument instrument = Instrument.EURUSD;
@Configurable("")
public Set<Instrument> instruments = new HashSet<Instrument>(
Arrays.asList(new Instrument[] {Instrument.EURUSD, Instrument.AUDCAD})
);
@Configurable("")
public IFeedDescriptor renkoFeedDescriptor = new RenkoFeedDescriptor(Instrument.EURUSD, PriceRange.TWO_PIPS, OfferSide.ASK);
//date/time usage possibilities
private static Calendar myCalendar;
static {
myCalendar = Calendar.getInstance();
myCalendar.set(2012, Calendar.JULY, 17, 14, 30, 00);
}
@Configurable(value="particular time", description="17th july 14:30")
public Calendar particularTime = myCalendar;
private static Calendar calTodayAt5am;
static {
calTodayAt5am = Calendar.getInstance();
calTodayAt5am.set(Calendar.HOUR_OF_DAY, 5);
calTodayAt5am.set(Calendar.MINUTE, 0);
calTodayAt5am.set(Calendar.SECOND, 0);
}
@Configurable(value="time in millis", description="default is today at 5am", datetimeAsLong=true)
public long timeInMillis = calTodayAt5am.getTimeInMillis();
//custom enum
enum Mode {
BUY,
SELL,
NONE
}
@Configurable("mode (enum param)")
public Mode mode = Mode.BUY;
//custom class with self-typed constants
static class Person {
public static final Person FOO = new Person("foo");
public static final Person BAR = new Person("bar");
public final String name;
public Person(String name){
this.name = name;
}
@Override
public String toString(){
return name;
}
}
@Configurable("")
public Person person;
@Configurable("")
public List<Person> persons;
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
value
Name of the field that will appear in dialog.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
datetimeAsLong
If true, then field contains date/time value presented as long.
|
java.lang.String |
description
A short description of annotated field.
|
java.lang.String |
fileType
This field is exclusively for File parameters,
for other types of parameters fileType value will be ignored.
|
boolean |
hidden
If true, then property is saved in preset, but isn't shown in Settings dialog.
|
boolean |
modifiable
Determines if the parameter is changeable during the strategy run.
|
boolean |
obligatory
Setting this to true means field is obligatory.
|
java.lang.String[] |
options
Determines possible values of a String field.
|
boolean |
readOnly
Setting this to true means field is read only and cannot be modified.
|
double |
stepSize
This field is suitable for parameter's types as : int, long or double.
|
public abstract java.lang.String value
public abstract java.lang.String fileType
File parameters can be visualized in 2 ways:
1. textField and button("..."), which allow you to specify file from your file system. Do not use fileType or define it ="" to use this visualization
2. combobox with predefined list of file(s) from strategy directory.
fileType should not be empty to use this visualization.
In this case fileType is filter, which specifies what files to show in combo.
e.g. fieldType="*" - return all your files from Strategy directory,
fieldType="*.xml" - return only files with XML extension from Strategy directory
public abstract double stepSize
public abstract boolean obligatory
public abstract boolean readOnly
public abstract java.lang.String description
public abstract boolean datetimeAsLong
public abstract java.lang.String[] options
Copyright © 2024. All rights reserved.