| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- #ifndef PLATFORMOBJECT_H
- #define PLATFORMOBJECT_H
- #include <QObject>
- #include <vector>
- #include <QMutex>
- using namespace std;
- class QNetworkAccessManager;
- struct DataPlatform
- {
- QString strPlatformType;
- QString strSymbol;
- __int64 nData; //ms
- float fPrice;
- };
- //开仓
- struct OpenContractInfo
- {
- QString tokenId;
- QString symbolId;
- int businessLine;
- QString secondBusinessLine;
- int businessSource;
- int enterPointSource;
- QString delegateCount;
- int orderType;
- int delegateType;
- QString pricedSymbol;
- int timeInForceValue;
- double delegatePrice;
- int languageType;
- OpenContractInfo()
- {
- tokenId = "USDT";
- symbolId = "BTCUSDT_UMCBL";
- businessLine = 10;
- secondBusinessLine = "N/A";
- businessSource = 0;
- enterPointSource = 1;
- delegateCount = "0.02";
- orderType = 0;
- delegateType = 1;
- pricedSymbol = "USDT";
- timeInForceValue = 0;
- delegatePrice = 0;
- languageType = 1;
- }
- };
- //平仓
- struct CloseContractInfo
- {
- QString tokenId;
- QString symbolId;
- int businessLine;
- int businessSource;
- int enterPointSource;
- QString secondBusinessLine;
- int timeInForceValue;
- bool cancelOrder;
- QString delegateCount;
- int orderType;
- int delegateType;
- int languageType;
- CloseContractInfo()
- {
- tokenId = "USDT";
- symbolId = "BTCUSDT_UMCBL";
- businessLine = 10;
- businessSource = 10;
- enterPointSource = 1;
- secondBusinessLine = "N/A";
- timeInForceValue = 0;
- cancelOrder = true;
- delegateCount = "0.02";
- orderType = 1;
- delegateType = 3;
- languageType = 1;
- }
- };
- //撤单
- struct CancleContractInfo
- {
- int businessLine;
- QString orderId;
- QString tokenId;
- QString symbolId;
- QString secondBusinessLine;
- int languageType;
- CancleContractInfo()
- {
- orderId = "1242653936208982023";
- tokenId = "USDT";
- symbolId = "BTCUSDT_UMCBL";
- businessLine = 10;
-
- secondBusinessLine = "N/A";
-
- languageType = 1;
- }
- };
- class PlatformObject : public QObject
- {
- Q_OBJECT
- public:
- PlatformObject(QObject *parent = nullptr);
- ~PlatformObject();
- private:
- QString m_strPlatName; // 平台名称
- double m_price; // 当前价格
- double m_dBNPrice;//当前bn价格
- double m_deviationCompensation; // 偏差补偿值
- double m_deviationPercentage; // 偏离度百分比
- bool m_isPositionOpen; // 当前是否开仓
- bool m_isDealState;//true:开多 false:开空
- bool m_bOrderDirection; // 下单方向,true :"buy"或 false:"sell"
- double m_dAverage;
- int m_nLever;//杠杆
- bool m_bCon;
- vector<DataPlatform> m_vDataVec;
- QNetworkAccessManager* m_pNetworkManager;
- QMutex m_QMutex;
- public:
- void MinData(const DataPlatform &item);
- void SetPlatformName(QString strName);
- float CalcAverageSelf();
- double GetAverage();
- double GetRealPrice();
- double GetRealNewPrice();
- void CalcdeviationCompensation(double dBinance);
- double GetDeviationCompensation();
- void CalcdeviationPercentage(double dBinancePrice);
- void executeTradingLogic(double entryThreshold);
-
- QByteArray PackJson_Open(const OpenContractInfo &item);
- QByteArray PackJson_Close(const CloseContractInfo &item);
- QByteArray PackJson_Cancle(const CancleContractInfo &item);
- void SetPostionState();
- //开多 - 限价
- void OpenContractMore_XJ();
- //开空 - 限价
- void OpenContractEmpty_XJ();
- //开空 - 市价
- void OpenContractEmpty_SJ();
- //平仓 - 闪现平仓 平多
- void CloseContractMore();
- //平仓 - 闪现平仓 平空
- void CloseContractEmpty();
- void SendPostRequst(QString strUrl,QByteArray &dataArray);
- public slots:
- void ReplyFinshed();
- };
- #endif // PLATFORMOBJECT_H
|