Update 更新文档
This commit is contained in:
71
cleaned_source_code/Sqbase/qorderprocessor.h
Normal file
71
cleaned_source_code/Sqbase/qorderprocessor.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef QORDERPROCESSOR_H
|
||||
#define QORDERPROCESSOR_H
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QThreadPool>
|
||||
#include <QMutex>
|
||||
#include <QCache>
|
||||
#include <QtConcurrent\QtConcurrent>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include "BZStruct.h"
|
||||
#include "qeventbus.h"
|
||||
#include "ObjectPool.h"
|
||||
#include "tool.h"
|
||||
#include "..\Sqbase\OrderBookParser.h"
|
||||
class QOrderProcessor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QOrderProcessor(QObject *parent = nullptr);
|
||||
~QOrderProcessor();
|
||||
void setProcessingEnabled(bool enabled);
|
||||
void processOrderBook(const Qot_UpdateOrderBook::Response &stRsp);
|
||||
void setJsonSaveEnabled(bool enabled);
|
||||
bool isJsonSaveEnabled() const { return m_jsonSaveEnabled; }
|
||||
void setreplyCodeQuantity(QMap<QString, float> CodeQuantity)
|
||||
{
|
||||
m_replyCodeQuantity = CodeQuantity;
|
||||
}
|
||||
size_t getCacheHitRate() const { return m_cacheHits; }
|
||||
size_t getCacheMissRate() const { return m_cacheMisses; }
|
||||
double getCacheHitRatio() const {
|
||||
return (m_cacheHits + m_cacheMisses) > 0 ?
|
||||
static_cast<double>(m_cacheHits) / (m_cacheHits + m_cacheMisses) : 0.0;
|
||||
}
|
||||
public:
|
||||
OrderBookParser parser;
|
||||
signals:
|
||||
void maxOrderReady(BigOrderInfo bigOrderInfo);
|
||||
void processingStarted(const QString& code);
|
||||
void processingFinished(const QString& code);
|
||||
void errorOccurred(const QString& code, const QString& error);
|
||||
private:
|
||||
QVector<BigOrderInfo> findExtremeOrders(const OrderBookData& data) const;
|
||||
OrderBookEntry findMaxVolumeItemEx(const QVector<OrderBookEntry>& items, double volumeRatio) const;
|
||||
QVector<BigOrderInfo> findMaxVolumeItem(const OrderBookData& data) const;
|
||||
OrderBookEntry findMinPriceItem(const QVector<OrderBookEntry>& items) const;
|
||||
bool getCachedResult(const QString& cacheKey, QVector<BigOrderInfo>& result) const;
|
||||
void cacheResult(const QString& cacheKey, const QVector<BigOrderInfo>& result) const;
|
||||
double sumQuantity(const QVector<OrderBookEntry>& items) const;
|
||||
void internalProcess(const OrderBookData& orderData);
|
||||
void saveOrderDataAsJson(const OrderBookData& orderData);
|
||||
QJsonObject orderBookDataToJson(const OrderBookData& data) const;
|
||||
QThreadPool m_threadPool;
|
||||
mutable QMutex m_dataMutex;
|
||||
bool m_enabled = true;
|
||||
bool m_jsonSaveEnabled = false;
|
||||
QSet<QString> m_processingCodes;
|
||||
QMap<QString, float> m_replyCodeQuantity;
|
||||
QThreadPool m_jsonSaveThreadPool;
|
||||
mutable QMap<QString, QVector<BigOrderInfo>> m_orderCache;
|
||||
mutable QList<QString> m_cacheKeys;
|
||||
mutable size_t m_cacheHits = 0;
|
||||
mutable size_t m_cacheMisses = 0;
|
||||
mutable QMutex m_cacheMutex;
|
||||
size_t m_cacheMaxSize = 200;
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user