public class SQStrategy extends FlexibleSettings
| Modifier and Type | Field and Description |
|---|---|
com.strategyquant.futurelib.backtester.DataDefinition |
DataDef
The Data def.
|
static org.slf4j.Logger |
Log
The Constant Log.
|
BYTE_MISSING, DOUBLE_MISSING, FLOAT_MISSING, INT_MISSING, LONG_MISSING| Constructor and Description |
|---|
SQStrategy(java.lang.String name)
Instantiates a new SQ strategy.
|
| Modifier and Type | Method and Description |
|---|---|
void |
applySettings(SQSettings settings)
Apply settings.
|
int |
BarsSinceEntry()
Bars since entry.
|
double |
Close(int index)
Close.
|
double |
CloseD(int index)
Close d.
|
void |
deinit()
Deinit.
|
void |
EnterLongAtLimit(double stopPrice)
Enter long at limit.
|
void |
EnterLongAtLimit(double stopPrice,
double size)
Enter long at limit.
|
void |
EnterLongAtLimit(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
Enter long at limit.
|
void |
EnterLongAtMarket()
Enter long at market.
|
void |
EnterLongAtMarket(double size)
Enter long at market.
|
void |
EnterLongAtStop(double stopPrice)
Enter long at stop.
|
void |
EnterLongAtStop(double stopPrice,
double size)
Enter long at stop.
|
void |
EnterLongAtStop(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
Enter long at stop.
|
void |
EnterShortAtLimit(double stopPrice)
Enter short at limit.
|
void |
EnterShortAtLimit(double stopPrice,
double size)
Enter short at limit.
|
void |
EnterShortAtLimit(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
Enter short at limit.
|
void |
EnterShortAtMarket()
Enter short at market.
|
void |
EnterShortAtMarket(double size)
Enter short at market.
|
void |
EnterShortAtStop(double stopPrice)
Enter short at stop.
|
void |
EnterShortAtStop(double stopPrice,
double size)
Enter short at stop.
|
void |
EnterShortAtStop(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
Enter short at stop.
|
double |
EntryPrice()
returns real entry price of the last opened order.
|
void |
ExitLong()
Exit long.
|
void |
ExitLongLimit(double priceLevel,
java.lang.String signalName)
Exit long limit.
|
void |
ExitLongStop(double priceLevel,
java.lang.String signalName)
Exit long stop.
|
void |
ExitShort()
Exit short.
|
void |
ExitShortLimit(double priceLevel,
java.lang.String signalName)
Exit short limit.
|
void |
ExitShortStop(double priceLevel,
java.lang.String signalName)
Exit short stop.
|
void |
finishTest()
Finish test.
|
SQSettings |
getSettings()
Gets the settings.
|
java.lang.String |
getStrategyName()
Gets the strategy name.
|
java.util.ArrayList<java.lang.String> |
getTradedSymbols()
Gets the traded symbols.
|
SQOrderList |
getTradesHistory()
Gets the trades history.
|
void |
init()
Inits the.
|
void |
initDataDef()
Inits the data def.
|
int |
MarketPosition()
Market position.
|
void |
onBarUpdate()
called when bar is updated (new tick or bar close arrives) .
|
double |
Open(int index)
Open.
|
void |
performOnBarUpdate()
prepares the indexes and calls onBarUpdate().
|
void |
precomputeBlocks(com.strategyquant.futurelib.backtester.DataSeries dataSeries)
Precompute blocks.
|
java.lang.String |
print()
Prints the.
|
void |
setTradeHandler(com.strategyquant.futurelib.backtester.TradeHandler tradeHandler)
Sets the trade handler.
|
void |
setTradingEngine(com.strategyquant.futurelib.engine.trading.TradingEngine tradingEngine)
Sets the trading engine.
|
double |
SubdataClose(int dataIndex,
int index)
Subdata close.
|
double |
SubdataOpen(int dataIndex,
int index)
Subdata open.
|
long |
SubdataTime(int dataIndex,
int index)
Subdata time.
|
com.strategyquant.futurelib.backtester.SymbolInfo |
SymbolInfo()
Symbol info.
|
long |
Time(int index)
Time.
|
clearAll, clone, contains, get, get, getAll, getAllKeys, getBoolean, getBoolean, getByte, getByte, getDouble, getDouble, getFloat, getFloat, getInt, getInt, getLong, getLong, getString, getString, hetKeyType, remove, set, set, setAllpublic static final org.slf4j.Logger Log
public com.strategyquant.futurelib.backtester.DataDefinition DataDef
public SQStrategy(java.lang.String name)
name - the namepublic void applySettings(SQSettings settings)
settings - the settingspublic SQSettings getSettings()
public void onBarUpdate()
public void init()
public void initDataDef()
public void deinit()
public void EnterLongAtMarket()
public void EnterLongAtMarket(double size)
size - the sizepublic void EnterShortAtMarket()
public void EnterShortAtMarket(double size)
size - the sizepublic void ExitLong()
public void ExitShort()
public void EnterLongAtStop(double stopPrice)
stopPrice - the stop pricepublic void EnterLongAtStop(double stopPrice,
double size)
stopPrice - the stop pricesize - the sizepublic void EnterLongAtStop(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
symbol - the symbolsignalName - the signal namestopPrice - the stop pricesize - the sizepublic void EnterShortAtStop(double stopPrice)
stopPrice - the stop pricepublic void EnterShortAtStop(double stopPrice,
double size)
stopPrice - the stop pricesize - the sizepublic void EnterShortAtStop(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
symbol - the symbolsignalName - the signal namestopPrice - the stop pricesize - the sizepublic void EnterLongAtLimit(double stopPrice)
stopPrice - the stop pricepublic void EnterLongAtLimit(double stopPrice,
double size)
stopPrice - the stop pricesize - the sizepublic void EnterLongAtLimit(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
symbol - the symbolsignalName - the signal namestopPrice - the stop pricesize - the sizepublic void EnterShortAtLimit(double stopPrice)
stopPrice - the stop pricepublic void EnterShortAtLimit(double stopPrice,
double size)
stopPrice - the stop pricesize - the sizepublic void EnterShortAtLimit(java.lang.String symbol,
java.lang.String signalName,
double stopPrice,
double size)
symbol - the symbolsignalName - the signal namestopPrice - the stop pricesize - the sizepublic int MarketPosition()
public int BarsSinceEntry()
public long Time(int index)
index - the indexpublic long SubdataTime(int dataIndex,
int index)
dataIndex - the data indexindex - the indexpublic double Open(int index)
index - the indexpublic double SubdataOpen(int dataIndex,
int index)
dataIndex - the data indexindex - the indexpublic double Close(int index)
index - the indexpublic double CloseD(int index)
index - the indexpublic double SubdataClose(int dataIndex,
int index)
dataIndex - the data indexindex - the indexpublic SQOrderList getTradesHistory() throws java.lang.Exception
java.lang.Exception - the exceptionpublic java.util.ArrayList<java.lang.String> getTradedSymbols()
public java.lang.String getStrategyName()
public void setTradeHandler(com.strategyquant.futurelib.backtester.TradeHandler tradeHandler)
tradeHandler - the new trade handlerpublic void performOnBarUpdate()
throws java.lang.Exception
java.lang.Exception - the exceptionpublic void finishTest()
throws java.lang.Exception
java.lang.Exception - the exceptionpublic void precomputeBlocks(com.strategyquant.futurelib.backtester.DataSeries dataSeries)
dataSeries - the data seriespublic double EntryPrice()
public void ExitLongStop(double priceLevel,
java.lang.String signalName)
priceLevel - the price levelsignalName - the signal namepublic void ExitLongLimit(double priceLevel,
java.lang.String signalName)
priceLevel - the price levelsignalName - the signal namepublic void ExitShortStop(double priceLevel,
java.lang.String signalName)
priceLevel - the price levelsignalName - the signal namepublic void ExitShortLimit(double priceLevel,
java.lang.String signalName)
priceLevel - the price levelsignalName - the signal namepublic java.lang.String print()
public void setTradingEngine(com.strategyquant.futurelib.engine.trading.TradingEngine tradingEngine)
tradingEngine - the new trading enginepublic com.strategyquant.futurelib.backtester.SymbolInfo SymbolInfo()