Some reformatting.
This commit is contained in:
parent
c0676d5b03
commit
bdc4f794f5
@ -1,17 +1,15 @@
|
||||
package StockExchange;
|
||||
|
||||
public class BuyOrder extends Order implements Comparable<Order>{
|
||||
public class BuyOrder extends Order implements Comparable<Order> {
|
||||
|
||||
@Override
|
||||
public int compareTo(Order o) {
|
||||
|
||||
|
||||
public int compareTo(Order o){
|
||||
|
||||
if (o.limit < limit)
|
||||
{
|
||||
if (o.limit < limit) {
|
||||
//System.out.println("return 1");
|
||||
return -1;
|
||||
}
|
||||
if (o.limit > limit){
|
||||
if (o.limit > limit) {
|
||||
//System.out.println("return -1");
|
||||
return +1;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Exchange extends Thread {
|
||||
}
|
||||
|
||||
// Here we store the list of quote receivers
|
||||
TreeSet<QuoteReceiver> qrlist = new TreeSet<QuoteReceiver>();
|
||||
TreeSet<QuoteReceiver> qrlist = new TreeSet();
|
||||
|
||||
public void AddQuoteReceiver(QuoteReceiver qr) {
|
||||
qrlist.add(qr);
|
||||
@ -52,7 +52,7 @@ public class Exchange extends Thread {
|
||||
long lastsize;
|
||||
|
||||
// Order orderlist[];
|
||||
TreeSet<BuyOrder> bid = new TreeSet<BuyOrder>();
|
||||
TreeSet<BuyOrder> bid = new TreeSet();
|
||||
TreeSet<SellOrder> ask = new TreeSet<SellOrder>();
|
||||
|
||||
private final Semaphore available = new Semaphore(1, true);
|
||||
|
@ -1,41 +1,44 @@
|
||||
package StockExchange;
|
||||
|
||||
public abstract class Order implements Comparable<Order> {
|
||||
|
||||
public abstract class Order implements Comparable<Order>{
|
||||
public long timestamp=0;
|
||||
/**
|
||||
* when
|
||||
*/
|
||||
public long timestamp = 0;
|
||||
public long size;
|
||||
public double limit;
|
||||
// long time;
|
||||
double money=0;
|
||||
double money = 0;
|
||||
// public long shares=0;
|
||||
public long id=0;
|
||||
public Account account=null;
|
||||
|
||||
public long id = 0;
|
||||
public Account account = null;
|
||||
|
||||
enum OrderStatus {
|
||||
open,executed,canceled
|
||||
open, executed, canceled
|
||||
}
|
||||
|
||||
OrderStatus status=OrderStatus.open;
|
||||
OrderStatus status = OrderStatus.open;
|
||||
|
||||
public long getAge(){
|
||||
if (timestamp==0)
|
||||
public long getAge() {
|
||||
if (timestamp == 0) {
|
||||
return 0;
|
||||
return System.currentTimeMillis()-timestamp;
|
||||
}
|
||||
return System.currentTimeMillis() - timestamp;
|
||||
}
|
||||
|
||||
String format_limit(){
|
||||
if (limit <0.0){
|
||||
String format_limit() {
|
||||
if (limit < 0.0) {
|
||||
return "n.a.";
|
||||
}
|
||||
return String.format("%.2f",limit);
|
||||
return String.format("%.2f", limit);
|
||||
}
|
||||
|
||||
String format_size(){
|
||||
String format_size() {
|
||||
return String.format("%d", size);
|
||||
}
|
||||
|
||||
Order(){
|
||||
Order() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
*/
|
||||
package sesim;
|
||||
|
||||
import StockExchange.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tube
|
||||
@ -15,6 +17,10 @@ public class SeSim {
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Exchange se = new StockExchange.Exchange();
|
||||
se.start();
|
||||
|
||||
|
||||
// TODO code application logic here
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user