#include "../misc_framework/CsvFileDataNodes.h" #include "UseHistory.h" #include "VolumeWeightedDataNodes.h" bool VolumeWeightedDataNode::getHistoryValid() { return !openHasPassed(); } void VolumeWeightedDataNode::onWakeup(int msgId) { if (_tosData->getValid()) { TosData const &last = _tosData->getLast(); if (last.newPrint) { VolumeBlocks::size_type oldCount = getBlockCount(); _volumeBlockFactory.addPrint(last.price, last.size, getSubmitTime()); if (oldCount != getBlockCount()) notifyListeners(); } } } VolumeWeightedDataNode::VolumeWeightedDataNode(DataNodeArgument const &args) : _volumeBlockFactory(args.getListValue()[1].getIntValue()) { std::string const &symbol = args.getListValue()[0].getStringValue(); addAutoLink(GenericTosDataNode::find(this, 0, _tosData, symbol)); if (getHistoryValid()) { // Ideally we start with the history which was automatically prepaired // for us by another task, then add realtime data. But if we start // late there will be a big hole. In that case it's better to use no // history and just the real time. _volumeBlockFactory.initializeWith (FileOwnerDataNode::getStringValue ("VB_OvernightData.csv", "Vol", symbol + '_' + ntoa(_volumeBlockFactory.getGroupBy()))); } } DataNodeLink *VolumeWeightedDataNode::find(DataNodeListener *listener, int msgId, VolumeWeightedDataNode *&node, std::string const &symbol, Integer groupBy) { return findHelper(listener, msgId, node, argList(symbol, groupBy)); }