som tests

This commit is contained in:
7u83 2017-03-14 07:50:26 +01:00
parent 3ddf431c48
commit 1fd742f714
5 changed files with 25 additions and 18 deletions

View File

@ -37,7 +37,7 @@ public class OrderBookDialog extends javax.swing.JDialog {
public OrderBookDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
books.setDepth(1000);
books.setDepth(1000000);
}
/**

View File

@ -116,8 +116,8 @@ public class QuoteVertical extends javax.swing.JPanel implements QuoteReceiver {
public void UpdateQuote(Quote q) {
/*
javax.swing.SwingUtilities.invokeLater(() -> {
// javax.swing.SwingUtilities.invokeLater(() -> {
String text, vtext;
text = dfm.format(q.price);
vtext = dfv.format(q.volume);
@ -132,8 +132,8 @@ public class QuoteVertical extends javax.swing.JPanel implements QuoteReceiver {
last_price = q.price;
this.quoteLabel.setText(text);
this.volumeLabel.setText("(" + vtext + ")");
});
*/
// });
}

View File

@ -516,7 +516,7 @@ public class Exchange {
}
public Double getBestPrice() {
System.out.printf("Get BP\n");
SortedSet<Order> bid = order_books.get(OrderType.BUYLIMIT);
SortedSet<Order> ask = order_books.get(OrderType.SELLLIMIT);
@ -538,13 +538,15 @@ public class Exchange {
// there is bid and ask
if (a != null && b != null) {
Quote q = new Quote();
System.out.printf("aaaaa bbbbb %f %f \n",a.limit,b.limit);
// if there is no last quote calculate from bid and ask
if (lq == null) {
return (bid.first().limit + ask.first().limit) / 2.0;
}
//if (lq == null) {
double rc =(bid.first().limit + ask.first().limit) / 2.0;
System.out.printf("RCRC2.0: %f\n",rc);
return rc;
// }
/*
if (lq.price < b.limit) {
return b.limit;
@ -554,6 +556,7 @@ public class Exchange {
}
return lq.price;
*/
}
if (a != null) {
@ -617,12 +620,12 @@ public class Exchange {
Quote q = new Quote();
// if there is no last quote calculate from bid and ask
if (lq == null) {
// if (lq == null) {
q.price = (bid.first().limit + ask.first().limit) / 2.0;
return q;
}
// }
if (lq.price < b.limit) {
/* if (lq.price < b.limit) {
q.price = b.limit;
return q;
}
@ -631,6 +634,7 @@ public class Exchange {
return q;
}
return lq;
*/
}
if (a != null) {

View File

@ -344,9 +344,9 @@ public class Scheduler extends Thread {
Iterator<TimerTaskDef> it = s.iterator();
while (it.hasNext()) {
TimerTaskDef e = it.next();
if (s.size() > 1) {
System.out.printf("Sicku: %d %d\n", e.id, e.curevtime);
}
// if (s.size() > 1) {
// System.out.printf("Sicku: %d %d\n", e.id, e.curevtime);
// }
long next_t = this.fireEvent(e.taskRunner);
e.newevtime = next_t + t;

View File

@ -379,6 +379,8 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
double limit;
limit = lp + getRandomAmmount(lp, buy_limit);
System.out.printf("Creating Buy Order from lp: %f, %f\n",lp,limit);
double volume = money / limit;
@ -392,7 +394,8 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
}
se.createOrder(account_id, type, volume, limit);
System.out.printf("Creating Sell Order from lp: %f, %f\n",lp,limit);
return true;
}