geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjbly...@apache.org
Subject svn commit: r508426 - in /geronimo/daytrader/branches/1.2/modules: ejb/src/main/java/org/apache/geronimo/samples/daytrader/ ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/ ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/ web...
Date Fri, 16 Feb 2007 14:47:20 GMT
Author: cjblythe
Date: Fri Feb 16 06:47:19 2007
New Revision: 508426

URL: http://svn.apache.org/viewvc?view=rev&rev=508426
Log:
DAYTRADER-25 Updated indexes and decimal precision in ddls and modified quote prices update
logic (400 max and +/- 20% delta)

Modified:
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
    geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/TradeBean.java
    geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/db2/Table.ddl
    geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/derby/Table.ddl
    geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/oracle/Table.ddl

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
(original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
Fri Feb 16 06:47:19 2007
@@ -128,6 +128,20 @@
 			BigDecimal.ROUND_HALF_UP);
 	}
 
+	/* CJB (DAYTRADER-25) - Also need to impose a ceiling on the quote price to ensure
+	 * prevent account and holding balances from exceeding the databases decimal precision.
+	 * At some point, this maximum value can be used to trigger a stock split.
+	 */
+
+	public static BigDecimal MAXIMUM_STOCK_PRICE;
+	public static BigDecimal MAXIMUM_STOCK_SPLIT_MULTIPLIER;
+	static {
+		MAXIMUM_STOCK_PRICE = new BigDecimal(400);
+		MAXIMUM_STOCK_PRICE.setScale(2, BigDecimal.ROUND_HALF_UP);
+		MAXIMUM_STOCK_SPLIT_MULTIPLIER = new BigDecimal(0.5);
+		MAXIMUM_STOCK_SPLIT_MULTIPLIER.setScale(2, BigDecimal.ROUND_HALF_UP);
+	}
+
 	/* Trade Scenario actions mixes. Each of the array rows represents a specific Trade Scenario
Mix. 
 	   The columns give the percentages for each action in the column header. Note: "login"
is always 0. 
 	   logout represents both login and logout (because each logout operation will cause a new
login when
@@ -383,9 +397,13 @@
 	}
 	private final static BigDecimal ONE = new BigDecimal(1.0);
 	public static BigDecimal getRandomPriceChangeFactor() {
-		//stocks are equally likely to go up or down
-		double percentGain = rndFloat(1) + 0.5;
-		// change factor is between +/- 50%
+		// CJB (DAYTRADER-25) - Vary change factor between 1.2 and 0.8
+		double percentGain = rndFloat(1) * 0.2;
+		if (random() < .5)
+			percentGain *= -1;
+		percentGain += 1;
+
+		// change factor is between +/- 20%
 		BigDecimal percentGainBD =
 			(new BigDecimal(percentGain)).setScale(2, BigDecimal.ROUND_HALF_UP);
 		if (percentGainBD.doubleValue() <= 0.0)

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
(original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/direct/TradeDirect.java
Fri Feb 16 06:47:19 2007
@@ -1460,6 +1460,8 @@
 
 			if (oldPrice.equals(TradeConfig.PENNY_STOCK_PRICE)) {
 				changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
+			} else if (oldPrice.compareTo(TradeConfig.MAXIMUM_STOCK_PRICE) > 0) {
+				changeFactor = TradeConfig.MAXIMUM_STOCK_SPLIT_MULTIPLIER;
 			}
 
 			BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);

Modified: geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/TradeBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/TradeBean.java?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/TradeBean.java
(original)
+++ geronimo/daytrader/branches/1.2/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/TradeBean.java
Fri Feb 16 06:47:19 2007
@@ -291,7 +291,9 @@
 
 			if (quote.getPrice().equals(TradeConfig.PENNY_STOCK_PRICE)) {
 				changeFactor = TradeConfig.PENNY_STOCK_RECOVERY_MIRACLE_MULTIPLIER;
-			}
+			} else if (oldPrice.compareTo(TradeConfig.MAXIMUM_STOCK_PRICE) > 0) {
+                                changeFactor = TradeConfig.MAXIMUM_STOCK_SPLIT_MULTIPLIER;
+                        }
 
 			BigDecimal newPrice = changeFactor.multiply(oldPrice).setScale(2, BigDecimal.ROUND_HALF_UP);
 

Modified: geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/db2/Table.ddl
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/db2/Table.ddl?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/db2/Table.ddl (original)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/db2/Table.ddl Fri
Feb 16 06:47:19 2007
@@ -99,11 +99,9 @@
 ALTER TABLE KEYGENEJB VOLATILE;
 ALTER TABLE ACCOUNTEJB VOLATILE;
 ALTER TABLE ORDEREJB VOLATILE;
-    
-CREATE INDEX a.profile_userid on accountejb(profile_userid);
-CREATE INDEX h.account_accountid on holdingejb(account_accountid);
-CREATE INDEX o.account_accountid on orderejb(account_accountid);
-CREATE INDEX o.holding_holdingid on orderejb(holding_holdingid);
-CREATE INDEX o.closed_orders on orderejb(orderstatus,account_accountid);
 
-  
\ No newline at end of file
+CREATE INDEX ACCOUNT_USERID ON ACCOUNTEJB(PROFILE_USERID);
+CREATE INDEX HOLDING_ACCOUNTID ON HOLDINGEJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_ACCOUNTID ON ORDEREJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_HOLDINGID ON ORDEREJB(HOLDING_HOLDINGID);
+CREATE INDEX CLOSED_ORDERS ON ORDEREJB(ACCOUNT_ACCOUNTID,ORDERSTATUS);

Modified: geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/derby/Table.ddl
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/derby/Table.ddl?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/derby/Table.ddl
(original)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/derby/Table.ddl
Fri Feb 16 06:47:19 2007
@@ -22,80 +22,79 @@
 DROP TABLE ACCOUNTEJB;
 DROP TABLE ORDEREJB;
 
-create table holdingejb
-(purchaseprice decimal(10, 2),
-holdingid integer not null,
-quantity double not null,
-purchasedate timestamp,
-account_accountid integer,
-quote_symbol varchar(250));
-
-alter table holdingejb
-add constraint pk_holdingejb primary key (holdingid);
-
-create table accountprofileejb
-(address varchar(250),
-passwd varchar(250),
-userid varchar(250) not null,
-email varchar(250),
-creditcard varchar(250),
-fullname varchar(250));
-
-alter table accountprofileejb
-add constraint pk_accountprofile2 primary key (userid);
-
-create table quoteejb
-(low decimal(10, 2),
-open1 decimal(10, 2),
-volume double not null,
-price decimal(10, 2),
-high decimal(10, 2),
-companyname varchar(250),
-symbol varchar(250) not null,
-change1 double not null);
-
-alter table quoteejb
-add constraint pk_quoteejb primary key (symbol);
-
-create table keygenejb
-(keyval integer not null,
-keyname varchar(250) not null);
-
-alter table keygenejb
-add constraint pk_keygenejb primary key (keyname);
-
-create table accountejb
-(creationdate timestamp,
-openbalance decimal(10, 2),
-logoutcount integer not null,
-balance decimal(10, 2),
-accountid integer not null,
-lastlogin timestamp,
-logincount integer not null,
-PROFILE_USERID VARCHAR(250));
-
-alter table accountejb
-add constraint pk_accountejb primary key (accountid);
-
-create table orderejb
-(orderfee decimal(10, 2),
-completiondate timestamp,
-ordertype varchar(250),
-orderstatus varchar(250),
-price decimal(10, 2),
-quantity double not null,
-opendate timestamp,
-orderid integer not null,
-account_accountid integer,
-quote_symbol varchar(250),
-holding_holdingid integer);
-
-alter table orderejb
-add constraint pk_orderejb primary key (orderid);
-
-create index profile_userid on accountejb(profile_userid);
-create index account_accountid on holdingejb(account_accountid);
-create index account_accountidt on orderejb(account_accountid);
-create index holding_holdingid on orderejb(holding_holdingid);
-create index orderstatus on orderejb(orderstatus);
-create index ordertype on orderejb(ordertype);
+CREATE TABLE HOLDINGEJB
+  (PURCHASEPRICE DECIMAL(14, 2),
+   HOLDINGID INTEGER NOT NULL,
+   QUANTITY DOUBLE NOT NULL,
+   PURCHASEDATE TIMESTAMP,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250));
+
+ALTER TABLE HOLDINGEJB
+  ADD CONSTRAINT PK_HOLDINGEJB PRIMARY KEY (HOLDINGID);
+
+CREATE TABLE ACCOUNTPROFILEEJB
+  (ADDRESS VARCHAR(250),
+   PASSWD VARCHAR(250),
+   USERID VARCHAR(250) NOT NULL,
+   EMAIL VARCHAR(250),
+   CREDITCARD VARCHAR(250),
+   FULLNAME VARCHAR(250));
+
+ALTER TABLE ACCOUNTPROFILEEJB
+  ADD CONSTRAINT PK_ACCOUNTPROFILE2 PRIMARY KEY (USERID);
+
+CREATE TABLE QUOTEEJB
+  (LOW DECIMAL(14, 2),
+   OPEN1 DECIMAL(14, 2),
+   VOLUME DOUBLE NOT NULL,
+   PRICE DECIMAL(14, 2),
+   HIGH DECIMAL(14, 2),
+   COMPANYNAME VARCHAR(250),
+   SYMBOL VARCHAR(250) NOT NULL,
+   CHANGE1 DOUBLE NOT NULL);
+
+ALTER TABLE QUOTEEJB
+  ADD CONSTRAINT PK_QUOTEEJB PRIMARY KEY (SYMBOL);
+
+CREATE TABLE KEYGENEJB
+  (KEYVAL INTEGER NOT NULL,
+   KEYNAME VARCHAR(250) NOT NULL);
+
+ALTER TABLE KEYGENEJB
+  ADD CONSTRAINT PK_KEYGENEJB PRIMARY KEY (KEYNAME);
+
+CREATE TABLE ACCOUNTEJB
+  (CREATIONDATE TIMESTAMP,
+   OPENBALANCE DECIMAL(14, 2),
+   LOGOUTCOUNT INTEGER NOT NULL,
+   BALANCE DECIMAL(14, 2),
+   ACCOUNTID INTEGER NOT NULL,
+   LASTLOGIN TIMESTAMP,
+   LOGINCOUNT INTEGER NOT NULL,
+   PROFILE_USERID VARCHAR(250));
+
+ALTER TABLE ACCOUNTEJB
+  ADD CONSTRAINT PK_ACCOUNTEJB PRIMARY KEY (ACCOUNTID);
+
+CREATE TABLE ORDEREJB
+  (ORDERFEE DECIMAL(14, 2),
+   COMPLETIONDATE TIMESTAMP,
+   ORDERTYPE VARCHAR(250),
+   ORDERSTATUS VARCHAR(250),
+   PRICE DECIMAL(14, 2),
+   QUANTITY DOUBLE NOT NULL,
+   OPENDATE TIMESTAMP,
+   ORDERID INTEGER NOT NULL,
+   ACCOUNT_ACCOUNTID INTEGER,
+   QUOTE_SYMBOL VARCHAR(250),
+   HOLDING_HOLDINGID INTEGER);
+
+ALTER TABLE ORDEREJB
+  ADD CONSTRAINT PK_ORDEREJB PRIMARY KEY (ORDERID);
+
+CREATE INDEX ACCOUNT_USERID ON ACCOUNTEJB(PROFILE_USERID);
+CREATE INDEX HOLDING_ACCOUNTID ON HOLDINGEJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_ACCOUNTID ON ORDEREJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_HOLDINGID ON ORDEREJB(HOLDING_HOLDINGID);
+CREATE INDEX CLOSED_ORDERS ON ORDEREJB(ACCOUNT_ACCOUNTID,ORDERSTATUS);

Modified: geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/oracle/Table.ddl
URL: http://svn.apache.org/viewvc/geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/oracle/Table.ddl?view=diff&rev=508426&r1=508425&r2=508426
==============================================================================
--- geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/oracle/Table.ddl
(original)
+++ geronimo/daytrader/branches/1.2/modules/web/src/main/webapp/dbscripts/oracle/Table.ddl
Fri Feb 16 06:47:19 2007
@@ -22,7 +22,6 @@
 DROP TABLE ACCOUNTEJB cascade constraints;
 DROP TABLE ORDEREJB cascade constraints;
 
-
 CREATE TABLE HOLDINGEJB
   (PURCHASEPRICE DECIMAL(14, 2) NULL,
    HOLDINGID INTEGER NOT NULL,
@@ -94,11 +93,8 @@
 ALTER TABLE ORDEREJB
   ADD CONSTRAINT PK_ORDEREJB PRIMARY KEY (ORDERID);
 
-CREATE INDEX a_profile_userid on accountejb(profile_userid);
-CREATE INDEX h_account_accountid on holdingejb(account_accountid);
-CREATE INDEX o_account_accountid on orderejb(account_accountid);
-CREATE INDEX o_holding_holdingid on orderejb(holding_holdingid);
-CREATE INDEX o_closed_orders on orderejb(orderstatus,account_accountid);
-
-
-  
+CREATE INDEX ACCOUNT_USERID ON ACCOUNTEJB(PROFILE_USERID);
+CREATE INDEX HOLDING_ACCOUNTID ON HOLDINGEJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_ACCOUNTID ON ORDEREJB(ACCOUNT_ACCOUNTID);
+CREATE INDEX ORDER_HOLDINGID ON ORDEREJB(HOLDING_HOLDINGID);
+CREATE INDEX CLOSED_ORDERS ON ORDEREJB(ACCOUNT_ACCOUNTID,ORDERSTATUS);



Mime
View raw message