diff --git a/nbproject/project.properties b/nbproject/project.properties index 8fef174..98a4926 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -1,4 +1,4 @@ -#Sun, 08 Oct 2017 19:42:34 +0200 +#Sun, 08 Oct 2017 21:13:57 +0200 annotation.processing.enabled=true annotation.processing.enabled.in.editor=false annotation.processing.processors.list= diff --git a/src/sesim/Exchange.java b/src/sesim/Exchange.java index ddff3e0..12a7cc6 100644 --- a/src/sesim/Exchange.java +++ b/src/sesim/Exchange.java @@ -36,6 +36,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.json.JSONArray; import org.json.JSONObject; +import sesim.Order.OrderStatus; /** * @desc Echchange class @@ -294,12 +295,6 @@ public class Exchange { return a.id; } - public enum OrderStatus { - OPEN, - PARTIALLY_EXECUTED, - CLOSED, - CANCELED - } class OrderComparator implements Comparator { diff --git a/src/sesim/Order.java b/src/sesim/Order.java index da9e28a..a08d652 100644 --- a/src/sesim/Order.java +++ b/src/sesim/Order.java @@ -29,80 +29,87 @@ package sesim; * * @author 7u83 <7u83@mail.ru> */ - public class Order { +public class Order { - Stock stock; - Exchange.OrderStatus status; - Exchange.OrderType type; - protected double limit; - protected double volume; - - protected final double initial_volume; - protected final long id; - protected final long created; - - protected final Exchange.Account account; - - double cost; - - Order(long id, long created, Exchange.Account account, Exchange.OrderType type, double volume, double limit) { - //id = order_id_generator.getNext(); - this.id=id; - this.account = account; - this.type = type; - this.limit = limit; - this.volume = volume; - this.initial_volume = this.volume; - this.created = created; - this.status = Exchange.OrderStatus.OPEN; - this.cost = 0; - } - - public long getID() { - return id; - } - - public double getVolume() { - return volume; - } - - public double getLimit() { - return limit; - } - - public Exchange.OrderType getType() { - return type; - } - - public double getExecuted() { - return initial_volume - volume; - } - - public double getInitialVolume() { - return initial_volume; - } - - public double getCost() { - return cost; - } - - public double getAvaragePrice() { - double e = getExecuted(); - if (e <= 0) { - return -1; - } - return cost / e; - } - - public Exchange.Account getAccount() { - return account; - } - - public Exchange.OrderStatus getOrderStatus() { - return status; - } - - public long getCreated() { - return created; - } + public enum OrderStatus { + OPEN, + PARTIALLY_EXECUTED, + CLOSED, + CANCELED } + + Stock stock; + OrderStatus status; + Exchange.OrderType type; + protected double limit; + protected double volume; + + protected final double initial_volume; + protected final long id; + protected final long created; + + protected final Exchange.Account account; + + double cost; + + Order(long id, long created, Exchange.Account account, Exchange.OrderType type, double volume, double limit) { + //id = order_id_generator.getNext(); + this.id = id; + this.account = account; + this.type = type; + this.limit = limit; + this.volume = volume; + this.initial_volume = this.volume; + this.created = created; + this.status = OrderStatus.OPEN; + this.cost = 0; + } + + public long getID() { + return id; + } + + public double getVolume() { + return volume; + } + + public double getLimit() { + return limit; + } + + public Exchange.OrderType getType() { + return type; + } + + public double getExecuted() { + return initial_volume - volume; + } + + public double getInitialVolume() { + return initial_volume; + } + + public double getCost() { + return cost; + } + + public double getAvaragePrice() { + double e = getExecuted(); + if (e <= 0) { + return -1; + } + return cost / e; + } + + public Exchange.Account getAccount() { + return account; + } + + public OrderStatus getOrderStatus() { + return status; + } + + public long getCreated() { + return created; + } +} diff --git a/src/traders/ManTrader/ManTrader.java b/src/traders/ManTrader/ManTrader.java index d05b712..6ee7fbd 100644 --- a/src/traders/ManTrader/ManTrader.java +++ b/src/traders/ManTrader/ManTrader.java @@ -37,7 +37,7 @@ import sesim.AutoTraderGui; import sesim.AutoTraderInterface; import sesim.Exchange; import sesim.Exchange.AccountListener; -import sesim.Exchange.OrderStatus; +import sesim.Order.OrderStatus; import sesim.Order; /** diff --git a/src/traders/RandomTraderA.java b/src/traders/RandomTraderA.java index 73d1d0e..7a19402 100644 --- a/src/traders/RandomTraderA.java +++ b/src/traders/RandomTraderA.java @@ -36,9 +36,10 @@ import sesim.AutoTraderGui; import sesim.Exchange; import sesim.Exchange.Account; import sesim.Exchange.AccountListener; -import sesim.Exchange.OrderStatus; + import sesim.Exchange.OrderType; import sesim.Order; +import sesim.Order.OrderStatus; import sesim.Quote; /**