Documentation

Last updated on 30. 1. 2016 by Mark Fric

New DebugConsole for Snippets

DebugConsole was added in version 4.10 to allow for easier debugging/logging during Snippets development. It is very simple to use and allows you to see what’s going on “behind the scene” when your snippet is executed.

Debug console is available from the toolbar:

This displays debug/log console that displays both normal program logs and a special debug messages.

How to use it

Before using it add include of this package to the beginning of the snippet, for exmaple


import com.strategyquant.lib.snippets.WhatIf;
import com.strategyquant.lib.debugging.DebugConsole;

public class ByDirection extends WhatIf {

Now you can call method DebugConsole.log(“category”, “message”); that will send this message with given category to a debug console.

Let’s add some debug message to a WhatIf snippet ByDirection.java, that can filter teh trades by direction:

public void filter(SQOrderList originalOrders) throws Exception {
    int direction = getStringParameterValue("Direction").equals("Long") ? SQConst.ORDER_BUY : SQConst.ORDER_SELL;
    int count = 0;

for(Iterator<SQOrder> i = originalOrders.listIterator(); i.hasNext();) {
count++;
SQOrder order = i.next();

DebugConsole.log(“WhatIf-direction”, “Order number #”+count+” has direction: “+(order.Type == SQConst.ORDER_BUY ? “Long” : “Short”));

if(order.Type != direction) {
i.remove();
}
}
}


After you’ll run WhatIf case on some strategy you’ll see the following output in the debug console:

Was this article helpful? The article was useful The article was not useful

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments