1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.emarket.order.domain;
21
22 import java.sql.Timestamp;
23
24 import javax.persistence.Entity;
25 import javax.persistence.Id;
26
27 @Entity
28 public class Order {
29
30 public static final String TYPE_SELL = "SELL";
31 public static final String TYPE_BUY = "BUY";
32 public static final String TYPE_SHORT_SELL = "SHORT_SELL";
33
34 public static final String TERM_GOOD_FOR_DAY ="GOOD_FOR_DAY";
35 public static final String TERM_GOOD_TILL_CANCELLED ="GOOD_TILL_CANCELLED";
36
37 public static final String PRICE_TYPE_MARKET = "MARKET";
38 public static final String PRICE_TYPE_LIMIT = "LIMIT";
39
40 public static final String STATUS_VERIFIED = "VERIFIED";
41 public static final String STATUS_OPEN = "OPEN";
42 public static final String STATUS_CLOSED = "CLOSED";
43 public static final String STATUS_CANCELLED = "CANCELLED";
44 public static final String STATUS_PARTIALLY_FILLED = "PARTIALLY_FILLED";
45 public static final String STATUS_FILLED = "FILLED";
46
47 @Id
48 private String id=null;
49 private long quoteId = 0l;
50 private String acctId =null;
51 private String symbol =null;
52 private String exchange = null;
53 private String orderType = null;
54 private int quantity =0;
55 private int filledQuantity = 0;
56 private String orderTerm = null;
57 private String priceType = PRICE_TYPE_LIMIT;
58 private float limitPrice = 0f;
59 private String status = null;
60 private float commission = 0f;
61 private float totalCost = 0f;
62 private Timestamp creationTime = null;
63 private Timestamp time = null;
64
65 public void setId( String id){
66 this.id =id;
67 }
68 public String getId(){
69 return id;
70 }
71 public String getAcctId() {
72 return acctId;
73 }
74 public void setAcctId(String acctId) {
75 this.acctId = acctId;
76 }
77 public long getQuoteId() {
78 return quoteId;
79 }
80 public void setQuoteId(long quoteId) {
81 this.quoteId = quoteId;
82 }
83 public String getSymbol() {
84 return symbol;
85 }
86 public void setSymbol(String symbol) {
87 this.symbol = symbol;
88 }
89 public String getExchange() {
90 return exchange;
91 }
92 public void setExchange(String exchange) {
93 this.exchange = exchange;
94 }
95 public String getOrderType() {
96 return orderType;
97 }
98 public void setOrderType(String orderType) {
99 this.orderType = orderType;
100 }
101 public int getQuantity() {
102 return quantity;
103 }
104 public void setQuantity(int quantity) {
105 this.quantity = quantity;
106 }
107 public int getFilledQuantity() {
108 return filledQuantity;
109 }
110 public void setFilledQuantity(int filledQuantity) {
111 this.filledQuantity = filledQuantity;
112 }
113 public String getOrderTerm() {
114 return orderTerm;
115 }
116 public void setOrderTerm(String orderTerm) {
117 this.orderTerm = orderTerm;
118 }
119 public String getPriceType() {
120 return priceType;
121 }
122 public void setPriceType(String priceType) {
123 this.priceType = priceType;
124 }
125 public String getStatus() {
126 return status;
127 }
128 public void setStatus(String status) {
129 this.status = status;
130 }
131 public float getCommission() {
132 return commission;
133 }
134 public void setCommission(float commission) {
135 this.commission = commission;
136 }
137 public float getTotalCost() {
138 return totalCost;
139 }
140 public void setTotalCost(float totalCost) {
141 this.totalCost = totalCost;
142 }
143 public Timestamp getCreationTime() {
144 return creationTime;
145 }
146 public void setCreationTime(Timestamp creationTime) {
147 this.creationTime = creationTime;
148 }
149 public Timestamp getTime() {
150 return time;
151 }
152 public void setTime(Timestamp time) {
153 this.time = time;
154 }
155 public float getLimitPrice() {
156 return limitPrice;
157 }
158 public void setLimitPrice(float limitPrice) {
159 this.limitPrice = limitPrice;
160 }
161
162
163 public boolean isBuy(){
164 boolean result = false;
165
166 if( getOrderType().equalsIgnoreCase( TYPE_BUY) ){
167 result = true;
168 }
169 return result;
170 }
171
172 public boolean isSell(){
173 boolean result = false;
174
175 if( getOrderType().equalsIgnoreCase( TYPE_SELL) ||
176 getOrderType().equalsIgnoreCase(TYPE_SHORT_SELL)){
177 result = true;
178 }
179 return result;
180 }
181
182 public boolean isLimitOrder(){
183 boolean result = false;
184
185 if( getPriceType().equalsIgnoreCase(PRICE_TYPE_LIMIT)){
186 result = true;
187 }
188 return result;
189 }
190
191 public boolean isMarketOrder(){
192 boolean result = false;
193
194 if( getPriceType().equalsIgnoreCase(PRICE_TYPE_MARKET)){
195 result = true;
196 }
197 return result;
198 }
199
200
201 }