home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / ODesign / SetupPSE.exe / data.z / Top.java < prev    next >
Encoding:
Java Source  |  1997-04-23  |  1.1 KB  |  44 lines

  1. package COM.odi.demo.pport;
  2.  
  3. /**
  4.  *      <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
  5.  *
  6.  * Given the already-loaded database, print out the net asset value of
  7.  * the Benchmark portfolio for every day in the year 1995.
  8.  */
  9.  
  10. import COM.odi.*;
  11.  
  12. final
  13. public class Top
  14. {
  15.  
  16.   public static void main(String argv[]) throws java.io.IOException
  17.   {
  18.     String host = System.getProperty("COM.odi.host");
  19.     String dbpath = System.getProperty("port.dbpath");
  20.  
  21.     if (dbpath == null)
  22.       dbpath = "port.odb";
  23.  
  24.     ObjectStore.initialize(host, null);
  25.     Database db = Database.open(dbpath, ObjectStore.OPEN_READONLY);
  26.  
  27.     Transaction t = Transaction.begin(ObjectStore.UPDATE);
  28.  
  29.     Security.initialize(db);
  30.     Portfolio.initialize(db);
  31.  
  32.     Portfolio b = Portfolio.lookup("Benchmark");
  33.     TradeDate from = new TradeDate("950101");
  34.     TradeDate to = new TradeDate("951229");
  35.     int[] nav = b.computeNAV(from, to);
  36.     for (int i = 0; i < nav.length; i++) {
  37.       System.out.println("NAV on " + from.toString() + " is " + nav[i]);
  38.       from.next();
  39.     }
  40.  
  41.     t.commit();
  42.   }
  43. }
  44.