117 {
"GE",
"SUNW",
"QCOM",
"BRCM",
"TYC",
"IBM",
"AMAT",
"C",
"PFE",
"HD"};
130 fDate = fVol = fOpen = fHigh = fLow = fClose = fCloseAdj = 0;
132 virtual ~TStockDaily() {}
147 TStockDaily *data = 0;
155 for (
Int_t i = 0; i < nrEntries; i++) {
158 if (data->fDate >= sDay && data->fDate <= eDay)
160 closeAdj.
AddAt(data->fCloseAdj/100. , i );
162 closeAdj[i] = data->fCloseAdj/100.;
167 for (
Int_t i = 1; i < nrEntries; i++)
170 r->
AddAt(closeAdj[i]/closeAdj[i-1],1);
172 (*r)[i-1] = closeAdj[i]/closeAdj[i-1];
199 const Int_t nrEqual = 1;
200 const Int_t nrInEqual = 0;
242 TQpDataDens *prob = (
TQpDataDens *)qp->
MakeData(c,Q,xlo,ixlo,xup,ixup,A,b,C,clo,iclo,cup,icup);
258 delete qp;
delete prob;
delete vars;
delete resid;
delete s;
260 cout <<
"Could not solve this problem." <<endl;
271 const Int_t sDay = 20000809;
272 const Int_t eDay = 20040602;
274 const char *fname =
"stock.root";
279 printf(
"accessing %s file from http://root.cern.ch/files\n",fname);
294 r[i] = data[i].GetSum()/nrData;
298 for (
Int_t j = 0; j <= i; j++) {
300 for (
Int_t k = 0; k < nrData; k++)
301 sum += (data[i][k]-r[i])*(data[j][k]-r[j]);
302 Covar(i,j) = Covar(j,i) = sum/nrData;
309 cout <<
"stock daily daily w1 w2" <<endl;
310 cout <<
"symb return sdv " <<endl;
337 legend1->
AddEntry(f1,
"1-exp(-2.0*x)",
"l");
338 legend1->
AddEntry(f2,
"1-exp(-10.*x)",
"l");
344 TH1F *
h1 =
new TH1F(
"h1",
"Portfolio Distribution",nrStocks,0,0);
345 TH1F *
h2 =
new TH1F(
"h2",
"Portfolio Distribution",nrStocks,0,0);
358 h1->
Draw(
"BAR2 HIST");
359 h2->
Draw(
"BAR2SAME HIST");
362 legend2->
AddEntry(h1,
"high risk",
"f");
363 legend2->
AddEntry(h2,
"low risk",
"f");
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual void SetBarOffset(Float_t offset=0.25)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetMaximum(Double_t maximum=-1111)
This class displays a legend box (TPaveText) containing several legend entries.
void AddAt(Float_t c, Int_t i)
Add float c at position i. Check for out of bounds.
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual void SetMinimum(Double_t minimum=-1111)
1-D histogram with a float per channel (see TH1 documentation)}
Array of floats (32 bits per element).
virtual TQpResidual * MakeResiduals(const TQpDataBase *data)
Setup the residuals.
virtual void SetYTitle(const char *title)
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to vusualize the function.
virtual void SetBarWidth(Float_t width=0.5)
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
#define ClassDef(name, id)
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
TVectorT< Double_t > TVectorD
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
static const Char_t * stocks[]
virtual void SetLineColor(Color_t lcolor)
virtual Int_t Solve(TQpDataBase *prob, TQpVar *iterate, TQpResidual *resid)
Solve the quadratic programming problem as formulated through prob, store the final solution in itera...
R__EXTERN TSystem * gSystem
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void SetFillColor(Color_t fcolor)
char * Form(const char *fmt,...)
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
Double_t RiskProfile(Double_t *x, Double_t *par)
TVectorD OptimalInvest(Double_t riskFactor, TVectorD r, TMatrixDSym Covar)
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
TArrayF & StockReturn(TFile *f, const TString &name, Int_t sDay, Int_t eDay)
virtual void SetXTitle(const char *title)
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
virtual void SetParameter(Int_t param, Double_t value)
Double_t Sqrt(Double_t x)
virtual TQpDataBase * MakeData(Double_t *c, Double_t *Q, Double_t *xlo, Bool_t *ixlo, Double_t *xup, Bool_t *ixup, Double_t *A, Double_t *bA, Double_t *C, Double_t *clo, Bool_t *iclo, Double_t *cup, Bool_t *icup)
Setup the data.
A TTree is a list of TBranches.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
virtual TQpVar * MakeVariables(const TQpDataBase *data)
Setup the variables.