refactoring ...
This commit is contained in:
parent
e3ed6d1043
commit
ad3a5a7d32
@ -1,4 +1,4 @@
|
|||||||
#Mon, 11 Dec 2017 16:05:46 +0100
|
#Mon, 11 Dec 2017 23:22:26 +0100
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
@ -683,12 +683,10 @@ public class Exchange {
|
|||||||
|
|
||||||
Order o;
|
Order o;
|
||||||
|
|
||||||
// System.out.printf("Getting executor %d\n", Thread.currentThread().getId());
|
|
||||||
synchronized (stock) {
|
synchronized (stock) {
|
||||||
// System.out.printf("Have executor %d\n", Thread.currentThread().getId());
|
|
||||||
o = a.orders.get(order_id);
|
o = a.orders.get(order_id);
|
||||||
|
|
||||||
// System.out.print("The Order:"+o.limit+"\n");
|
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
SortedSet ob = stock.order_books.get(o.type);
|
SortedSet ob = stock.order_books.get(o.type);
|
||||||
|
|
||||||
@ -709,7 +707,7 @@ public class Exchange {
|
|||||||
|
|
||||||
public boolean cancelOrder(double account_id, Order order) {
|
public boolean cancelOrder(double account_id, Order order) {
|
||||||
|
|
||||||
return cancelOrder(getDefaultStock(), account_id, order.getID());
|
return cancelOrder(order.stock, account_id, order.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
Random random;
|
Random random;
|
||||||
@ -776,8 +774,6 @@ public class Exchange {
|
|||||||
|
|
||||||
s.type = OrderType.SELL;
|
s.type = OrderType.SELL;
|
||||||
stock.addOrderToBook(s);
|
stock.addOrderToBook(s);
|
||||||
|
|
||||||
// System.out.printf("Stoploss hit %f %f\n", s.volume, s.limit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -825,7 +821,7 @@ public class Exchange {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void executeOrders(Stock stock) {
|
private void executeOrders(Stock stock) {
|
||||||
|
|
||||||
SortedSet<Order> bid = stock.order_books.get(OrderType.BUYLIMIT);
|
SortedSet<Order> bid = stock.order_books.get(OrderType.BUYLIMIT);
|
||||||
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
|
SortedSet<Order> ask = stock.order_books.get(OrderType.SELLLIMIT);
|
||||||
@ -854,8 +850,6 @@ public class Exchange {
|
|||||||
money_total += price * volume;
|
money_total += price * volume;
|
||||||
this.checkSLOrders(price);
|
this.checkSLOrders(price);
|
||||||
|
|
||||||
//System.out.printf("Cannot match two unlimited orders!\n");
|
|
||||||
//System.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!ul_buy.isEmpty() && !ask.isEmpty()) {
|
while (!ul_buy.isEmpty() && !ask.isEmpty()) {
|
||||||
@ -902,7 +896,6 @@ public class Exchange {
|
|||||||
volume_total += volume;
|
volume_total += volume;
|
||||||
money_total += price * volume;
|
money_total += price * volume;
|
||||||
|
|
||||||
// num_trades++;
|
|
||||||
statistics.trades++;
|
statistics.trades++;
|
||||||
|
|
||||||
this.checkSLOrders(price);
|
this.checkSLOrders(price);
|
||||||
@ -918,10 +911,6 @@ public class Exchange {
|
|||||||
q.time = timer.currentTimeMillis();
|
q.time = timer.currentTimeMillis();
|
||||||
|
|
||||||
addQuoteToHistory(q);
|
addQuoteToHistory(q);
|
||||||
|
|
||||||
//this.quoteHistory.add(q);
|
|
||||||
//this.updateOHLCData(q);
|
|
||||||
//this.updateQuoteReceivers(q);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long buy_orders = 0;
|
long buy_orders = 0;
|
||||||
|
@ -30,7 +30,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -55,7 +54,7 @@ public class Stock {
|
|||||||
|
|
||||||
// Create an order book for each order type
|
// Create an order book for each order type
|
||||||
for (Order.OrderType type : Order.OrderType.values()) {
|
for (Order.OrderType type : Order.OrderType.values()) {
|
||||||
this.order_books.put(type, new TreeSet(new Exchange.OrderComparator(type)));
|
order_books.put(type, new TreeSet(new Exchange.OrderComparator(type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
quoteHistory = new TreeSet();
|
quoteHistory = new TreeSet();
|
||||||
@ -132,9 +131,8 @@ public class Stock {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param stock
|
|
||||||
* @param type
|
* @param type
|
||||||
* @param depth
|
* @param depth
|
||||||
* @return
|
* @return
|
||||||
@ -164,6 +162,4 @@ public class Stock {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user