Dear Newtrader
please find below the complete file listing.
I am not sure what you mean with "strategy magic in the
onBookSnapshot"?
The file is verbatim as I used it. Thus it is the Defender2 with
minimal adaptions
for the other contract, I do not (yet) care about the entries it
generates.
(At this point I have no strategy for EUR-trading. I am still in the
process of acquiring
base data for strategy development - unsuccessful so far.)
package com.jbooktrader.strategy;
import com.jbooktrader.indicator.velocity.*;
import com.jbooktrader.platform.indicator.*;
import com.jbooktrader.platform.model.*;
import com.jbooktrader.platform.optimizer.*;
import com.jbooktrader.strategy.base.*;
/**
*
*/
public class DefenderEUR extends StrategyEUR {
// Technical indicators
private final Indicator balanceVelocityInd,
trendStrengthVelocityInd;
// Strategy parameters names
private static final String FAST_PERIOD = "Fast Period";
private static final String SLOW_PERIOD = "Slow Period";
private static final String TREND_PERIOD = "Trend Period";
private static final String ENTRY = "Entry";
// Strategy parameters values
private final int entry;
public DefenderEUR(StrategyParams optimizationParams) throws
JBookTraderException {
super(optimizationParams);
entry = getParam(ENTRY);
balanceVelocityInd = new
BalanceVelocity(getParam(FAST_PERIOD), getParam(SLOW_PERIOD));
trendStrengthVelocityInd = new
TrendStrengthVelocity(getParam(TREND_PERIOD));
addIndicator(balanceVelocityInd);
addIndicator(trendStrengthVelocityInd);
}
/**
* Adds parameters to strategy. Each parameter must have 5 values:
* name: identifier
* min, max, step: range for optimizer
* value: used in backtesting and trading
*/
@Override
public void setParams() {
addParam(FAST_PERIOD, 4, 18, 1, 9);
addParam(SLOW_PERIOD, 2500, 4500, 100, 3380);
addParam(TREND_PERIOD, 250, 800, 10, 585);
addParam(ENTRY, 120, 200, 1, 170);
}
/**
* Framework invokes this method when a new snapshot of the limit
order book is taken
* and the technical indicators are recalculated. This is where
the strategy itself
* (i.e., its entry and exit conditions) should be defined.
*/
@Override
public void onBookSnapshot() {
double balanceVelocity = balanceVelocityInd.getValue() * 10;
double trendStrengthVelocity =
trendStrengthVelocityInd.getValue();
int currentPosition = getPositionManager().getPosition();
if (currentPosition > 0 && balanceVelocity <= -entry) {
setPosition(0);
}
if (currentPosition < 0 && balanceVelocity >= entry) {
setPosition(0);
}
if (trendStrengthVelocity < 0) {
if (balanceVelocity >= entry) {
setPosition(1);
} else if (balanceVelocity <= -entry) {
setPosition(-1);
}
}
}
}
On 5 Apr., 13:40, new_trader <[email protected]> wrote:
> can you upload your java strategy implmentation file, of course
> without your strategy magic in the onBookSnapshot() method.
> I have one recording slot free and can try to reproduce the problem
>
> On Apr 4, 1:21 am, ecthx <[email protected]> wrote:
>
>
>
> > EventReport.htm is the JBT log file. You can find it in the reports
> > folder.
> > It may contain some important info so take a look at it, and if you
> > can't figure out
> > what's wrong, post it here so more people can help.
>
> > On Apr 3, 4:13 pm, Klaus <[email protected]> wrote:
>
> > > Hi,
>
> > > I am not sure what you mean with event report - as the problem is that
> > > there is no further reaction.
>
> > > So here I post an excerpt from the market data file..
> > > 33010,165944,42.86,1.34135
> > > 033010,165945,42.86,1.34135
> > > 033010,165946,42.96,1.34135
> > > 033010,165947,43.87,1.34135
> > > 033010,165948,43.98,1.34135
> > > 033010,165949,32.89,1.3414
> > > 033010,165950,30.11,1.3414
> > > 033010,165951,34.56,1.3414
> > > 033010,165952,35.57,1.3414
> > > 033010,165953,28.24,1.34145
> > > 033010,165954,33.33,1.34145
> > > 033010,165955,33.33,1.34145
> > > 033010,165956,33.33,1.34145
> > > 033010,165957,39.76,1.3414
> > > 033010,165958,39.52,1.3414
> > > 033010,165959,42.71,1.3414
> > > 033010,170000,42.75,1.3414
> > > 033010,170001,44.83,1.3414
> > > 033010,170002,44.83,1.3414
> > > 033010,170003,44.83,1.3414
> > > 033010,170004,44.83,1.3414
> > > 033010,170005,6.31,1.3416
> > > 033010,170006,6.31,1.3416
> > > 033010,170007,6.31,1.3416
> > > 033010,170008,6.31,1.3416
> > > 033010,170009,6.31,1.3416
> > > 033010,170010,6.31,1.3416
> > > 033010,170011,6.31,1.3416
> > > 033010,170012,6.31,1.3416
> > > 033010,170013,6.31,1.3416
>
> > > .. and the following lines go on like that until I interrupt it while
> > > the data in TWS changes.
> > > Also at the same time there are no further updates to EUR data in the
> > > interface.
> > > On the other hand ES data updates and is still correctly written in
> > > parallel.
>
> > > As far as I can see always ES remains intact while EUR stalls at some
> > > point.
>
> > > Cheers
> > > Klaus
>
> > > On 3 Apr., 17:44, ecthx <[email protected]> wrote:
>
> > > > Post your event report
>
> > > > On Apr 3, 7:48 am, Klaus <[email protected]> wrote:
>
> > > > > Hi,
>
> > > > > I do currently use JBookTrader to acquire data for two symbols: EUR
> > > > > Future and ES Future.
> > > > > The ES future support is built in the distribution. EUR I added to it.
>
> > > > > At this point I did not yet care about any trading approach, I did
> > > > > only focus on acquiring data as a basis for tuning the system. As EUR-
> > > > > Data is not available otherwise, I am particularly interested in this.
> > > > > However, what I noticed was this:
> > > > > - I start a system for EUR and one for ES in forward testing mode in
> > > > > order to do data acquisition.
> > > > > - At some point I typically notice that the jbooktrader is getting
> > > > > stuck with the EUR acquisition
> > > > > while still acquiring new ES data. That means despite changing
> > > > > prices in IB the data in jbooktrader for EUR
> > > > > do no longer change, and from thereon jbooktrader repeats the same
> > > > > line over and over in the data
> > > > > file.
>
> > > > > - Typically this happens after several hours, but within one day
> > > > > (i.e., most one day sets of data are faulty).
>
> > > > > BTW, I am runing TWS under IBController (using IB 901) and the most
> > > > > recent download from the jbooktrader-website.
>
> > > > > ---- here is how I implemented the data acquisition for EUR ---
>
> > > > > I derived StrategyEUR from StrategyES (i.e., copy and adapt). Main
> > > > > adaptation is:
> > > > > protected StrategyEUR(StrategyParams optimizationParams) throws
> > > > > JBookTraderException {
> > > > > super(optimizationParams);
> > > > > // Specify the contract to trade
> > > > > Contract contract = ContractFactory.makeFutureContract("EUR",
> > > > > "GLOBEX");
> > > > > // Define trading schedule
> > > > > TradingSchedule tradingSchedule = new TradingSchedule("9:55",
> > > > > "15:25", "America/New_York");
> > > > > // Not sure about the correct schedule
> > > > > int multiplier = 125000;// contract multiplier
> > > > > double bidAskSpread = 0.0001; // prevalent spread between best
> > > > > bid and best ask
> > > > > Commission commission =
> > > > > CommissionFactory.getBundledNorthAmericaFutureCommission();
> > > > > setStrategy(contract, tradingSchedule, multiplier, commission,
> > > > > bidAskSpread);
> > > > > }
>
> > > > > I copied Defender2 and made a DefenderEUR class based on StrategyEUR
>
> > > > > When running, I run Defender2 and DefenderEUR.
>
> > > > > ---------------------------------------------
>
> > > > > Any comments and support would be greatly appreciated.
>
> > > > > Best Regards
> > > > > Klaus
--
You received this message because you are subscribed to the Google Groups
"JBookTrader" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jbooktrader?hl=en.