📄 loadtest.java
字号:
package com.jsystemtrader.strategy;
import com.ib.client.*;
import com.jsystemtrader.indicator.*;
import com.jsystemtrader.platform.*;
import com.jsystemtrader.util.*;
/**
* This is a totally mindless strategy whose sole purpose is to test the system.
* This strategy will buy and sell every one minute to maximize the number of
* trades so that the potential JSystemTrader bugs/problems can be uncovered.
*/
public class LoadTest extends Strategy {
public LoadTest() throws JSystemTraderException {
Contract contract = ContractFactory.makeContract("ES", "FUT", "GLOBEX", MostLiquidContract.getMostLiquid(), null);
setStrategy(contract, PriceBar.BAR_1_MINUTE, false, 25000);
}
/**
* This method is invoked when a new bar is completed.
*/
public void onBar() {
// First, let the super strategy decide if we can trade at all
super.onBar();
if (decision == DECISION_NONE) { // the super strategy has no objections
// see class level coments for explanation of this strategy
PositionManager positionManager = getPositionManager();
int position = positionManager.getPosition();
if (position == PositionManager.POSITION_NONE || position == PositionManager.POSITION_SHORT) {
decision = DECISION_LONG;
}
if (position == PositionManager.POSITION_LONG) {
decision = DECISION_SHORT;
}
}
}
/**
* This method is invoked when a new tick comes in.
*/
public void onTick() {
super.onTick();
double lastTick = quoteHistory.getLast();
// do something
}
/**
* Instance of NumberFormat is shared by multiple threads,
* so the access must be synchronized.
*/
public void updateState() {
super.updateState();
String msg = this.getName() + ": state updated" + "<br>";
eventLog.write(msg, "Info", 1);
strategyLog.write(strategyLogColumns, getCalendar(), "Info", 1);
}
/**
* Called from the super class
*/
public void updateIndicators() throws IndicatorCalculationException {
// nothing to do
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -