#ifndef __StockTwitsDataNode_h_ #define __StockTwitsDataNode_h_ #include "../misc_framework/DataNodes.h" /* This file requests the data which is provided by * ../../stocktwits/Subscriptions.C. The structure of this file is copied * from our code which looks at NASDAQ velocity and forces data, ./VF.[Ch]. * In both cases we have a very simple data node which doesn't do anything * but read from our own proxy. * * This is different from the structure of the proxies we use for our TOS and * L1 data. Those proxies use a convoluted system where the data providor has * to initiate the TCP/IP connection with the data consumer. StockTwits and * NASDAQ VF use the more sensible and traditional model where the data * provider is the TCP/IP server. * * See ../../stocktwits/README.txt for a list of other processes, files, * etc. which are required to support this file. */ struct StockTwitsDataFields { enum Reason { NewMessage, DailyReset, DatabaseInit, ClientRequest } __attribute__ ((packed)); DataNode::Integer messageCount; Reason reason; } __attribute__ ((packed)); class StockTwitsTimeDataNode; class StockTwitsDataNode : public DataNode { private: enum { bmValue, bmDebug }; const std::string _symbol; const double _dailyAverage; StockTwitsTimeDataNode *_stockTwitsTimeData; StockTwitsDataFields _data; bool _valid; virtual void onBroadcast(BroadcastMessage &message, int msgId); StockTwitsDataNode(DataNodeArgument const &args); ~StockTwitsDataNode(); friend class DataNode; public: // This is what comes from the proxy. This is realtime data, which the // proxy accumulates and resets at midnight. bool getValid() const { return _valid; } StockTwitsDataFields const &getData() const { return _data; } // This is based on the overnight processing. It could be stored somewhere // else. But it seems like it's likely to be used by the same code that's // using the live proxy data. double getDailyAverage() const { return _dailyAverage; } // This is a combination of the overnight and live data. This cannot // directly cause a notification. The notifications only come from the proxy // data. void getRelativeVolume(bool &valid, double &value) const; static DataNodeLink *find(DataNodeListener *listener, int msgId, StockTwitsDataNode *&node, std::string const &symbol); static DataNodeLink *find(StockTwitsDataNode *&node, std::string const &symbol) { return find(NULL, 0, node, symbol); } // This is only required to make the debugger available sooner. If you // don't need the debugger, or you can wait until at least one of these // has been created, you don't need to call this. Call this only in the // data node thread. static void init(); }; #endif