Refactoring account_id account_id_generator now

This commit is contained in:
7u83 2017-10-09 15:48:50 +02:00
parent 201709b053
commit dfe4661d11
3 changed files with 12 additions and 14 deletions

View File

@ -112,7 +112,7 @@ public class Exchange {
IDGenerator account_id = new IDGenerator(); IDGenerator account_id_generator = new IDGenerator();
//public static Timer timer = new Timer(); //public static Timer timer = new Timer();
public Scheduler timer; // = new Scheduler(); public Scheduler timer; // = new Scheduler();
@ -230,7 +230,7 @@ public class Exchange {
} }
Account(double money, double shares) { Account(double money, double shares) {
id = (random.nextDouble() + (account_id.getNext())); id = (random.nextDouble() + (account_id_generator.getNext()));
orders = new ConcurrentHashMap(); orders = new ConcurrentHashMap();
this.money = money; this.money = money;
this.shares = shares; this.shares = shares;
@ -1164,16 +1164,16 @@ public class Exchange {
/*public AccountData getAccountData(double account_id) { /*public AccountData getAccountData(double account_id_generator) {
tradelock.lock(); tradelock.lock();
Account a = accounts.get(account_id); Account a = accounts.get(account_id_generator);
tradelock.unlock(); tradelock.unlock();
if (a == null) { if (a == null) {
return null; return null;
} }
AccountData ad = new AccountData(); AccountData ad = new AccountData();
ad.id = account_id; ad.id = account_id_generator;
ad.money = a.money; ad.money = a.money;
ad.shares = a.shares; ad.shares = a.shares;
@ -1202,9 +1202,9 @@ public class Exchange {
return ad; return ad;
} }
*/ */
/* public ArrayList<OrderData> getOpenOrders(double account_id) { /* public ArrayList<OrderData> getOpenOrders(double account_id_generator) {
Account a = accounts.get(account_id); Account a = accounts.get(account_id_generator);
if (a == null) { if (a == null) {
return null; return null;
} }

View File

@ -374,7 +374,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
public boolean doBuy() { public boolean doBuy() {
// AccountData ad = this.se.getAccountData(account_id); // AccountData ad = this.se.getAccountData(account_id_generator);
Account ad = se.getAccount(account_id); Account ad = se.getAccount(account_id);
OrderType type = OrderType.BUYLIMIT; OrderType type = OrderType.BUYLIMIT;
@ -420,7 +420,7 @@ public class RandomTraderA extends AutoTraderBase implements AccountListener {
public boolean doSell() { public boolean doSell() {
// RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig; // RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig;
//AccountData ad = this.se.getAccountData(account_id); //AccountData ad = this.se.getAccountData(account_id_generator);
Account ad = se.getAccount(account_id); Account ad = se.getAccount(account_id);

View File

@ -31,12 +31,10 @@ import java.util.Set;
import javax.swing.JDialog; import javax.swing.JDialog;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
//import sesim.AccountData;
import sesim.AutoTraderBase; import sesim.AutoTraderBase;
import sesim.AutoTraderGui; import sesim.AutoTraderGui;
import sesim.Exchange;
import sesim.Exchange.Account; import sesim.Exchange.Account;
import sesim.Order.OrderType; import sesim.Order.OrderType;
import sesim.Quote; import sesim.Quote;
@ -266,7 +264,7 @@ public class RandomTraderB extends AutoTraderBase {
public boolean doBuy() { public boolean doBuy() {
// AccountData ad = this.se.getAccountData(account_id); // AccountData ad = this.se.getAccountData(account_id_generator);
Account ad = se.getAccount(account_id); Account ad = se.getAccount(account_id);
@ -306,7 +304,7 @@ public class RandomTraderB extends AutoTraderBase {
public boolean doSell() { public boolean doSell() {
// RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig; // RandomTraderConfig myoldconfig = (RandomTraderConfig) this.oldconfig;
//AccountData ad = this.se.getAccountData(account_id); //AccountData ad = this.se.getAccountData(account_id_generator);
Account ad = se.getAccount(account_id); Account ad = se.getAccount(account_id);