/***************************************************************************** * Copyright [2019] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #ifndef CPPSRC_STARQUANT_DATA_DATAMANAGER_H_ #define CPPSRC_STARQUANT_DATA_DATAMANAGER_H_ #include #include #include #include #include #include // #define CEREAL_RAPIDJSON_NAMESPACE creal_rapidjson // #include // #include // #include // #include // #include // #include using std::string; namespace StarQuant { /// DataManager /// 1. provide latest full tick price info -- DataBoard Service /// 2. record data class DataManager { public: static DataManager* pinstance_; static mutex instancelock_; static DataManager& instance(); TickWriter recorder_; uint64_t count_ = 0; bool contractUpdated_ = false; bool saveSecurityFile_ = false; std::map securityDetails_; // ctpsymbol to security std::map orderBook_; std::map ctp2Full_; std::map full2Ctp_; //std::map _5s; //std::map _15s; // std::map _60s; //std::map _1d; DataManager(); ~DataManager(); void reset(); void rebuild(); void updateOrderBook(const Tick& k) { orderBook_[k.fullSymbol_] = k;} void updateOrderBook(const Fill& fill); void saveSecurityToFile(); void loadSecurityFile(); }; } // namespace StarQuant #endif // CPPSRC_STARQUANT_DATA_DATAMANAGER_H_