/*
 * port.h
 */
#define	P_SETUP		1
#define	P_TRANS		2
#define P_PRICE		4
#define P_ALL		7

#define     BUY         'B'
#define	    SELL        'S'
#define	    DIVIDEND    'D'
#define	    EXPENSE    	'X'
#define	    INCOME      'I'
#define	    GROWTH      'G'
#define	    INVESTMENT	'I'
#define	    RRSP        'R'

/* =======================================================
 * Public Type Definitions
 */

/* A fund */
typedef struct {
   char		name[32];		/* Fund's full name */
   char		alias[3];		/* Fund abbreviation 2 characters */
   int		color;			/* Graphing colour */
   float	units;			/* # of units owned in the fund */
   Price	value;			/* Current value of the fund */
   Price	cost;			/* Total purchase cost of current units */
   float	time;			/* Total days invested/dollar */
   char		type;			/* Equity, Income */
} Fund;

/* A transaction */
typedef struct {
   Date		date;			/* Transaction date YYMMDD */
   char		alias[3];		/* Fund alias */
   char		type[2];		/* Transaction code, Buy, Sell, etc. */
   Price	amount;			/* Transaction amount $ or Units for Dividends */
} Transaction;

/* A portfolio */
typedef struct {
   int		fund_no;        /* # of funds in portfolio */
   Fund		*fund;          /* Array of funds */
   int		price_no;       /* # of prices in history */
   Date		*price_dates;   /* Array of price dates */
   Price	*price;	        /* Array of prices for each fund */
   int		trans_no;       /* # of transactions */
   Transaction	*trans;	        /* Array of transactions */
   char         type;           /* Investment, RRSP */
} Account;

#define Account_defaults	{ 0, NULL, 0, NULL, NULL, 0, NULL }

/* =======================================================
 * Public Function Prototypes
 */

extern int PORT_load ( Account *a, char *argv[], int argc );
extern int PORT_setup( Account *a, char *filename );
extern int PORT_price( Account *a, char *filename );
extern int PORT_trans( Account *a, char *filename );
extern int PORT_command( Account *a, char *filename );
extern int PORT_unload ( Account *a, int type );

