Moved OrderStatus from Exchange to Order
This commit is contained in:
parent
f4d4ba2c46
commit
08c4c5e91d
@ -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=
|
||||
|
@ -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<Order> {
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user