/////////////////////////////////////////////////////////////////////////// //Warnings: //we define 2 variables("DebugMode" and "MyCPP")for debugging the program: //1)if you define "DebugMode" in the project, the program will be compiled // using the short file names(ex. stockmarketdata.h is short to stkmktda.h) // defined in my project(my compiler do not support long name), otherwise, // it will use the orignal long file names; //2)if you define "MyCPP" in the project, the program will ask you to // to input CPPIndex value at each cycle, so that we can do simulation // when writing the code. // //Author: Bo Lian //Date: 4/7/1999 //All Rights Reserved. ////////////////////////////////////////////////////////////////////////// //My Files included:(Total 7) //blian1.h, blian1.cpp: my first class(Named blian1) derived from Trade; //blian2.h, blian2.cpp: my first class(Named blian2) derived from Trade; //blian3.h, blian3.cpp: my first class(Named blian3) derived from Trade; //blian.h: common header file for the 3 classes above. ////////////////////////////////////////////////////////////////////////// #ifndef BLIAN_H #define BLIAN_H //define my type definition here #include #include #include #include "..\market\Trader.h" //#include "Broker.h" /* #ifdef DebugMode #include "stkmktda.h" //my compiler does not support long name #endif #ifndef DebugMode #include "StockMarketData.h" #endif */ #define True 1; #define False 0; #define WAIT_TIME 10; //skip the first 10 trades #define ThirdQtDays 2190 //3/4 of total trades=8*365=2920; #define EndOfPF -1 //end of portfolio list const int NumCPP=24; //24, track 3 days(8 trades/day) how many CPPIndex we are going to track; const int TopNum=100; //top # of stocks const int myMaxStocks=TopNum*3; //maximum # of stocks we are going to invest const int BUY_SIG=1; //buy signal detected const int SELL_SIG=2; //sell signal detected const int HOLD=0; //hold the trade (no buy/sell) const double COMMISSION=14.99; const double MinBuy=COMMISSION*50; extern const double BROKER_INIT_BAL; extern const double BROKER_COMMISSION; struct myCPPIndex{ double lowest; //lowest index in history double highest; //highest index in history double current; //current index }; struct myPrice{ double start_buy; //price I bought first time double last_buy; //price I bought last time double lowest; //lowest price in history double highest; //hightest price in history double currnet; //current index }; //////Class 1 //////////////////////////////////// class blian1:public Trader //long term investor { public: blian1(int TradeNumber); ~blian1(); virtual void Think(); virtual int Trade(); void FindTopEarningStocks(); int BuyOneStock(int Ticker,double AmountToBuy); //buy one stock; int SellOneStock(int Ticker,int SharesToSell); //sell one stock int TradeSignal(); //return "BUY_SIG" for buy, "SELL_SIG" for sell, "HOLD" not trade void MyWorthList(); //output my data; double MyBalanceNWorth(); //calculate the total of my balance and worth and return it; void UpdateMyCppHistory(); //update my file for CPPIndex void RemoveFromList(int Ticker); //remove a stock, whick already sold, from the portfolio list void AddToList(int Ticker); void ListMyPortfolio(); //output my portfolio list double TopEarnStocksIndex();//calculate the stock index in my portfolio void TopStkIndexHistoryUpdate(); //update my stock index of private: long NumStocks; //total numbers of stocks available to buy; int myTradeNum; int num_trade; //how many times the trade was called. int TopEarningStocks[TopNum]; //ten stocks with highest earnings double TopStkIndexHistory[NumCPP]; //record the history of the price index //of top earning stocks. double CPPIndexHistory[NumCPP]; //track values for the last 20 trades; int TradeSig; //TradeSingal long TotalTradeNum; //total # of trade(buy+sell); // double HighestPrice,LowestPrice; double AvgEarnings; //average positive earning of the whole stocks; int myPortfolio[myMaxStocks]; //record my portfolio double CurrentBalance; //my currect cash balance; double myTotal; //balance+assets; Broker *myBroker1; StockMarketInfo myInfo; StockData my_sd; AssetData *myAsset[MAX_STOCKS]; //OK //AssetData **myAsset; }; ////////////////Clase 2//////////////////////// class blian2:public Trader //long term investor { public: blian2(int TradeNumber); ~blian2(); virtual void Think(); virtual int Trade(); void FindTopEarningStocks(); int BuyOneStock(int Ticker,double AmountToBuy); //buy one stock; int SellOneStock(int Ticker,int SharesToSell); //sell one stock int TradeSignal(); //return "BUY_SIG" for buy, "SELL_SIG" for sell, "HOLD" not trade void MyWorthList(); //output my data; double MyBalanceNWorth(); //calculate the total of my balance and worth and return it; void UpdateMyCppHistory(); //update my file for CPPIndex void RemoveFromList(int Ticker); //remove a stock, whick already sold, from the portfolio list void AddToList(int Ticker); void ListMyPortfolio(); //output my portfolio list private: long NumStocks; //total numbers of stocks available to buy; int myTradeNum; int num_trade; //how many times the trade was called. int TopEarningStocks[TopNum]; //ten stocks with highest earnings double CPPIndexHistory[NumCPP]; //track values for the last 20 trades; int TradeSig; //TradeSingal int BigSell; //Big Sell Signal (when stock market up 20%) int BigBuy; //Big buy signal (when stock market down 20% and not close to //the end of the game). long TotalTradeNum; //total # of trade(buy+sell); // double HighestPrice,LowestPrice; double AvgEarnings; //average positive earning of the whole stocks; int myPortfolio[myMaxStocks]; //record my portfolio double CurrentBalance; //my currect cash balance; double myTotal; //balance+assets; Broker *myBroker2; StockMarketInfo myInfo; StockData my_sd; AssetData *myAsset[MAX_STOCKS]; //AssetData **myAsset; }; //////////Class 3///////////////////////////// class blian3:public Trader //long term investor { public: blian3(int TradeNumber); ~blian3(); virtual void Think(); virtual int Trade(); void FindTopEarningStocks();//save result in TopEarningStocks[TopNum]; int BuyOneStock(int Ticker,double AmountToBuy); //buy one stock; int SellOneStock(int Ticker,int SharesToSell); //sell one stock int TradeSignal(); //return "BUY_SIG" for buy, "SELL_SIG" for sell, "HOLD" not trade void MyWorthList(); //output my data; double MyBalanceNWorth(); //calculate the total of my balance and worth and return it; void UpdateMyCppHistory(); //update my file for CPPIndex void RemoveFromList(int Ticker); //remove a stock, whick already sold, from the portfolio list void AddToList(int Ticker); void ListMyPortfolio(); //output my portfolio list double TopEarnStocksIndex();//calculate the stock index in my portfolio void TopStkIndexHistoryUpdate(); //update my stock index of private: long NumStocks; //total numbers of stocks available to buy; int myTradeNum; int num_trade; //how many times the trade was called. int TopEarningStocks[TopNum]; //ten stocks with highest earnings double TopStkIndexHistory[NumCPP]; //record the history of the price index //of top earning stocks. double CPPIndexHistory[NumCPP]; //track values for the last 20 trades; int TradeSig; //TradeSingal int BigSell; //Big Sell Signal (when stock market up 20%) int BigBuy; //Big buy signal (when stock market down 20% and not close to //the end of the game). long TotalTradeNum; //total # of trade(buy+sell); // double HighestPrice,LowestPrice; double AvgEarnings; //average positive earning of the whole stocks; int myPortfolio[myMaxStocks]; //record my portfolio double CurrentBalance; //my currect cash balance; double myTotal; //balance+assets; Broker *myBroker3; StockMarketInfo myInfo; StockData my_sd; AssetData *myAsset[MAX_STOCKS]; //AssetData **myAsset; }; #endif ;