-
Class Tracer - strategy tracing
Each strategy that inherits from BaseStrategyClass contains a protected member
variable _pTracer, which is pointer to the object of class Tracer.
Declaration of class Tracer can be found in CoreStrategies\StrategyFeatures\Tracer.h.
This class is used to store user specified messages (strategy trace information) in file
located in C:\Program Files\StrategyTuner2\bin\UserTrace\<user name>
(or in C:\Program Files\StrategyTuner2\API\bin_debug\UserTrace\<user name>
if you run the strategy in debug environment).
You must call BaseStrategyClass::onInitParameters() in
onInitParameters of your strategy
or make sure that it is called down the inheritance tree.
Otherwise _pTracer would remain undefined becoming a potential cause of strategy failure.
There are two ways to create trace records:
- void add(TraceLevel l, char *message, ...) adds to existing trace records or
starts a new record if none existed yet. At the end of sequence of calls to add() you
need to call void flush() which causes the record to be written to disk.
- void trace(TraceLevel l, char *message, ...) flushes the currently open record
to disk if there is any. Creates a new one and immediately flushes it to disk.
TraceLevel is a strategy parameter. It belongs to the Strategy section of parameter
file (VTrader->Strategy). Possible values of TraceLevel are "NONE", "LOW", "PARAM", "BAR", "ORDER",
"POSITION", "ALWAYS". Additionally, you can switch on or off all traces by means of parameter TraceToFile.
It can be found in the same section along with TraceLevel.
TraceLevel can be one of (from low to high):
- LELEL_NONE
- no trace is produced.
- LEVEL_LOW
- low level information, significant only if verbose tracing is necessary.
- LEVEL_PARAM
- echo output of strategy parameters
- LEVEL_BAR
- periodic information, such as bar open/close, high/low prices
- LEVEL_ORDER
- order specific data - order type, price, etc
- LEVEL_POSITION
- positions specific data - time, price, number of lots of position being opened or closed
- LEVEL_ALWAYS
- important information that has to be present no matter what. For example, error messages
of the strategy.
If value of TraceLevel parameter is lower or equal (less or equal) than that given in
add() or trace() then the trace information is added to the record.
Otherwise, it is omitted.
For sake of simplicity both add() and trace() have overloaded versions
that do not take TraceLevel parameter. Their trace information is always added
to the record:
- void add(char *message, ...)
- void trace(char *message, ...)
-
Class FATS::Time - time representation
Useful functions:
- long h() - return current hour (0-23)
- long m() - return current minute (0-59)
- long s() - return current second (0-59)
- long seconds() - return seconds since 00:00:00
-
Class FATS::Date - date representation
Useful functions:
- long year() - return current year (yyyy)
- long month() - return current month (1-12)
- long day() - return current day (1-32)
- long days() - return days since year start (1-366)
-
Class XpathWrapper - used to retrieve attribute names from strategy XML file in order
to set strategy parameters.
Useful functions:
- const char * asString( const char *expression, char* buffer, long length) - returns the value of the expression in
a string format.
Parameters:
- const char *expression - XPath expression, for instance Strategy/@name will get
the value of strategy's attribute name
- char *buffer - holds the retrieved value
- long length - length of the buffer
Return value:
- const char* - pointer to the beginning of the buffer
- long asLong(const char *expression) - returns the value of the expression as long
- double asDouble(const char *expression) - returns the value of the expression as double
- FATS::Time asTime(const char *expression ) - returns the value of the expression as time
- bool asBool(const char *expression) - returns the value of the expression as boolean
-
Class OvernightDataContainer - holds the data that is saved by
the end of the day and restored on the next day.
Useful functions:
- bool add(const char* name, T value) - saves an item of type T
under the key name.
Return value is unused.
- T get(const char* name, T error) - returns value of an item of type T
under the key name.
In case of a problem, returns the default error value.
-
Class BarId - bar id
Useful functions:
- BarId::BARTYPE type() - returns one of following:
- ERR - for error
- TIME - for time bars
- VOLUME - for volume bars
- TRANSACTION - for transaction bars
- DAILY - for daily bars
- long period()- returns bar's period.
-
Class TransactionDataWrapper contains transaction data and attributes
Useful functions:
- long contract_id() - returns contract id
- long time() - returns transaction time
- double value(int index) - returns the transaction data according to the index:
-
Class BarDataWrapper contains bar data and attributes
Useful functions:
- long contract_id() - returns the contract id
- double open() - returns bar open price
- double close() - returns bar close price
- double high() - returns the highest price within the bar
- double low() - returns the lowest price within the bar
- int transNum() - returns the number of transactions within the bar
- int volume() - returns the volume within the bar
- int index() - returns sequential index of the bar
- long openTime() - returns bar open time
- long closeTime() - returns bar close time
-
Class ActionDataWrapper contains action data and attributes
Useful functions, members and constants:
- enum ACTION_TYPE - action type:
- ACTION_NONE
- ALERT_TIME
- ALERT_TIME_TRANS
- BUY_LIMIT
- SELL_LIMIT
- BUY_STOP
- SELL_STOP
- BUY_STOP_LIMIT
- SELL_STOP_LIMIT
- BUY_MARKET
- SELL_MARKET
- enum ORDER_STATUS - order status:
- STATUS_QUEUED
- STATUS_SEND
- STATUS_WORKING
- STATUS_CANCELED
- STATUS_REJECTED
- STATUS_FILLED
- STATUS_PARTFILLED
- STATUS_UNKNOWN
- bool isOrder() - returns true if the action is an order, false otherwise
- bool isLong() - returns true if long position, false otherwise
- long _contract_id - contract id
- long _id - action id
- long _time - time the action is sent
- long _fill_time - time the action is filled (if applicable)
- double _price - price of the action
- double _price2 - price2 of the action (if applicable)
- double _fill_price - price at which the action is filled (if applicable)
- long _count - number of lots for the action (if applicable)
- ACTION_TYPE _action_type - action type
- ORDER_STATUS _order_status - action status
- TransactionDataWrapper _trans - corresponding transaction
-
Enumeration MARKET_DIRECTION
- MARKET_BULLISH
- MARKET_BEARISH
- MARKET_ANY
-
Class SmartParams contains attributes for smart order
Useful functions and defines:
- SmartParams() - set attributes for non-smart order.
- SmartParams(long timeout) - set attributes for smart order with
given timeout and zero slippage.
- SmartParams(long timeout, double slippage) - set attributes for smart order with
given timeout and slippage.
- bool smart() - returns true for smart order, false otherwise.
- long timeout() - returns timeout for smart order.
- double slippage() - returns slippage for smart order.
- #define NON_SMART_ORDER (SmartParams()) - non smart order.
- #define DEFAULT_SMART_ORDER (SmartParams(SmartParams::DEFAULT_TIMEOUT)) - default
smart order where timeout is taken from the configuration file.
-
Class family Predicate - sets criteria for alerts
- RANGE(X,Y) - set the predicate for checking range
- EQ(X) - set the EQUAL predicate
- EQE(X,Y) - set the EQUAL predicate with epsilon Y
- LT(X) - set the LESS predicate
- LE(X) - set the LESS_OR_EQUAL predicate
- GE(X) - set the GREAT_OR_EQUAL predicate
- GT(X) - set the GREAT predicate