work on internal accounts
This commit is contained in:
parent
aae927ae82
commit
a8cf39eaf5
@ -25,15 +25,15 @@ public class Exchange extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iAccount(double money, double shares) {
|
iAccount(double money, double shares) {
|
||||||
next_account_id_locker.lock();
|
NEXT_ACCOUNT_ID_LOCKER.lock();
|
||||||
id = (Math.random() + (next_account_id++));
|
id = (Math.random() + (next_account_id++));
|
||||||
next_account_id_locker.unlock();
|
NEXT_ACCOUNT_ID_LOCKER.unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int next_account_id;
|
private static int next_account_id;
|
||||||
Locker next_account_id_locker = new Locker();
|
private static final Locker NEXT_ACCOUNT_ID_LOCKER = new Locker();
|
||||||
TreeSet<iAccount> accounts;
|
TreeSet<iAccount> accounts;
|
||||||
|
|
||||||
double createAccount(double money, double shares) {
|
double createAccount(double money, double shares) {
|
||||||
@ -56,6 +56,15 @@ public class Exchange extends Thread {
|
|||||||
this.qrlist = new ArrayList<>();
|
this.qrlist = new ArrayList<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class BidBook extends TreeSet{
|
||||||
|
TreeSet t = new TreeSet();
|
||||||
|
boolean hallo(){
|
||||||
|
t.comparator();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -305,7 +314,7 @@ public class Exchange extends Thread {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a match, build price and volume
|
// There is a match, calculate price and volume
|
||||||
double price = b.id < a.id ? b.limit : a.limit;
|
double price = b.id < a.id ? b.limit : a.limit;
|
||||||
long volume = b.volume >= a.volume ? a.volume : b.volume;
|
long volume = b.volume >= a.volume ? a.volume : b.volume;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user