#ifndef __AverageHistoricalVolume_h_ #define __AverageHistoricalVolume_h_ #include "../../shared/MarketHours.h" #include "../misc_framework/DataNodes.h" #include "../misc_framework/CsvFileDataNodes.h" // Historical volume data is based on 15 minute intervals. #define AHV_PERIOD (MARKET_HOURS_MINUTE * 15) // This is the number of periods in a trading day. This is 26 for the // normal US markets. #define AHV_PERIODS ((MARKET_HOURS_CLOSE - MARKET_HOURS_OPEN) / AHV_PERIOD) // These two special periods describe all the time before the market offically // opens, and after it closes. In TAL this data was not really accessible to // us. In eSignal it was. Having the premarket data is especially helpful // in the first few minutes of the market. #define AHV_PRE_MARKET 0 #define AHV_POST_MARKET (AHV_PERIODS + 1) // This period is never used. This value is useful in caching scenarios where // you initialize your cache to this so you know it's empty. #define AHV_NONE -1 class AverageHistoricalData : public DataNode { private: FileOwnerDataNode *_volumeData; const std::string _symbol; //Integer _values[AHV_POST_MARKET+1]; Integer *_values; bool _valid; void updateValues(); void onWakeup(int msgId); AverageHistoricalData(DataNodeArgument const &args); ~AverageHistoricalData(); friend class DataNode; public: bool isValid() const { return _valid; } Integer getVolume(int period) const; Integer getPreMarketVolume() const { return _values[AHV_PRE_MARKET]; } Integer getPostMarketVolume() const { return _values[AHV_POST_MARKET]; } static DataNodeLink *find(DataNodeListener *listener, int msgId, AverageHistoricalData *&node, std::string const &symbol); static DataNodeLink *find(AverageHistoricalData *&node, std::string const &symbol) { return find(NULL, 0, node, symbol); } // Returns the period that contains the time. If the time is on the boundary // of two periods, it chooses the higher one. static int higherTimeFrame(time_t dateTime); // This returns latest time in the given time frame, and the first time in // the next time frame. This is just a time, with no date. static time_t timeFrameEnd(int period); }; #endif