1 // This file is part of Qt Bitcoin Trader 2 // https://github.com/JulyIGHOR/QtBitcoinTrader 3 // Copyright (C) 2013-2021 July Ighor <julyighor@gmail.com> 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // In addition, as a special exception, the copyright holders give 11 // permission to link the code of portions of this program with the 12 // OpenSSL library under certain conditions as described in each 13 // individual source file, and distribute linked combinations including 14 // the two. 15 // 16 // You must obey the GNU General Public License in all respects for all 17 // of the code used other than OpenSSL. If you modify file(s) with this 18 // exception, you may extend this exception to your version of the 19 // file(s), but you are not obligated to do so. If you do not wish to do 20 // so, delete this exception statement from your version. If you delete 21 // this exception statement from all source files in the program, then 22 // also delete it here. 23 // 24 // This program is distributed in the hope that it will be useful, 25 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 // GNU General Public License for more details. 28 // 29 // You should have received a copy of the GNU General Public License 30 // along with this program. If not, see <http://www.gnu.org/licenses/>. 31 32 #ifndef EXCHANGE_BITSTAMP_H 33 #define EXCHANGE_BITSTAMP_H 34 35 #include "exchange.h" 36 37 class Exchange_Bitstamp : public Exchange 38 { 39 Q_OBJECT 40 41 public: 42 void filterAvailableUSDAmountValue(double* amount); 43 Exchange_Bitstamp(const QByteArray& pRestSign, const QByteArray& pRestKey); 44 ~Exchange_Bitstamp(); 45 46 private: 47 double accountFee; 48 bool isReplayPending(int); 49 bool lastInfoReceived; 50 51 int apiDownCounter; 52 int secondPart; 53 54 JulyHttp* julyHttp; 55 56 QByteArray privateClientId; 57 58 QList<DepthItem>* depthAsks; 59 QList<DepthItem>* depthBids; 60 QList<QByteArray> cancelingOrderIDs; 61 62 QMap<double, double> lastDepthAsksMap; 63 QMap<double, double> lastDepthBidsMap; 64 QString apiLogin; 65 66 qint64 lastBidAskTimestamp; 67 qint64 lastTickerDate; 68 qint64 lastTradesDate; 69 qint64 privateNonce; 70 71 void clearVariables(); 72 void depthSubmitOrder(const QString&, QMap<double, double>*, double, double, bool); 73 void depthUpdateOrder(const QString&, double, double, bool); 74 void sendToApi(int reqType, const QByteArray& method, bool auth = false, bool sendNow = true, QByteArray commands = nullptr); 75 76 private slots: 77 void reloadDepth(); 78 void sslErrors(const QList<QSslError>&); 79 void dataReceivedAuth(const QByteArray&, int, int); 80 void secondSlot(); 81 void quitThread(); 82 public slots: 83 void clearValues(); 84 void getHistory(bool); 85 void buy(const QString&, double, double); 86 void sell(const QString&, double, double); 87 void cancelOrder(const QString&, const QByteArray&); 88 }; 89 90 #endif // EXCHANGE_BITSTAMP_H 91