Hi,
I tried it (at the end I also include the modified code).
The market data now looks like this:
092810,225959,-2.28,1.35855
092810,230000,-2.28,1.35855
092810,230001,0.0,-1
092810,230002,0.0,-1
092810,230003,0.0,-1
092810,230004,0.0,-1
092810,230005,0.0,-1
092810,230006,0.0,-1
which is rather ugly.
Would it be possible to make it repeat the last value until new data
arrives?
I would normally think, you just store it and repeat it, but I am not
sure what happens if you work with multiple underlyings? Will this not
confuse data streams..?
Alternatively: can we simply return null? (I am not sure whether this
crashes some other part of the code)
Probably it is: if either the course is negative or balance is NaN.
Cheers
Klaus
public synchronized MarketSnapshot getMarketSnapshot(long time) {
if (midPointPrice == 0) {
// This is normal. It happens at the very start when
market depth is initializing.
return null;
}
if (!balances.isEmpty()) {
double multiplier = 2.0 / (balances.size() + 1.0);
for (double balance : balances) {
averageBalance += (balance - averageBalance) *
multiplier;
}
}
if (Double.isNaN(averageBalance)) {
averageBalance = 0;
}
double oneSecondBalance =
Double.valueOf(df2.format(averageBalance));
MarketSnapshot marketSnapshot = new MarketSnapshot(time,
oneSecondBalance, midPointPrice);
balances.clear();
return marketSnapshot;
}
--
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.