how to define a "class" for "stock" using c++ language? The class should include the method of "meanvalue" and "variance", meanwhile it should also contain "trading volume" and some historical data. Thank you very much.
+3
A:
Here's a start:
class Stock
{
public:
Stock();
~Stock();
int MeanValue();
int Variance();
private:
int mMeanValue;
int mVariance;
};
I'll leave the implementation of the methods in this class up to you.
LeopardSkinPillBoxHat
2010-02-22 03:00:44
Missing that final semi.
just_wes
2010-02-22 03:01:40
@just_wes - fixed.
LeopardSkinPillBoxHat
2010-02-22 03:02:44
And a container for historical data.
Duck
2010-02-22 03:02:46
@Duck - And I quote: Here's a *start* :-)
LeopardSkinPillBoxHat
2010-02-22 03:03:12
@LeopardSkinPillBoxHat - Just busting you. You put more into it than I would have.
Duck
2010-02-22 03:04:34
ints for mean values? You can't be serious...
Tim
2010-02-22 04:07:04
@tim - Yes, I only put in a fraction more thought into my answer than the poster did for the original question!
LeopardSkinPillBoxHat
2010-02-22 04:09:00
Stock also should have instrument ID and at least one symbol name I think. But that should be derived from Instrument class, which also would be a base for Option, for example.
Vlad Lazarenko
2010-08-06 13:24:03
A:
You'll probably want to have a name property, and perhaps an exchange property, method to handle updates to specific things like volume, quotes, trade prices, etc. You can do this with key/value pairs or define methods for each.
For things like variance and history, you will have to have methods that are triggered by the updates so you can change the calculated values.
You really should consider showing us what you have, then we'll be more likely to help...
Tim
2010-02-22 04:12:42