· 7 years ago · Apr 26, 2018, 07:14 PM
1#ifndef backTest_h
2#define backTest_h
3
4#include <cpprest/http_client.h>
5#include <cpprest/filestream.h>
6#include <cpprest/ws_client.h>
7#include <openssl/hmac.h>
8#include <iostream>
9#include <string>
10#include <chrono>
11#include <sstream>
12#include <stdio.h>
13#include <iomanip> //Allows one to see prices of small satoshi's worth coins.
14#include <fstream> //File opens/closes
15#include <vector>
16#include <boost/algorithm/string.hpp> //Boost::erase
17#include <stdlib.h> //abs val
18#include <map>
19
20using namespace utility; // Common utilities like string conversions
21using namespace web; // Common features like URIs.
22using namespace web::http; // Common HTTP functionality
23using namespace web::http::client; // HTTP client features
24using namespace concurrency::streams; // Asynchronous streams
25using namespace std;
26using namespace std::chrono; //Allows us to get epoch time without having to ping Binance server for it
27
28#define RESTfulHost "https://api.binance.com/"
29
30class botData{
31 double price,pastPrice,sellPercent, USDT, BTC=0, LTC=0, ETH=0, BCC=0, BNB=0, NEO=0, ADA=0, QTUM=0, total;
32 vector<long> openTime,closeTime,numTrades;
33 vector <long double> open, high, low, close, volume, quoteAssetVolume,takerBuyAssetVol,takerBuyQuoteAssetVol,ignore, RSI, stochRSI;
34 bool algoCheck,algoBuy;
35 string pair;
36 string epochTime;
37 string signature; //THIS IS THE HMAC SHA256 SIGNATURE. USES MESSAGE AND YOUR SECRET API KEY
38 string secretKey = "YOUR SECRET KEY HERE"; //THIS IS THE KEY FOR THE HMAC SHA256
39 string APIKEY = "YOUR KEY HERE";
40
41public:
42 void setPair();
43 void setPrice(double foundPrice);
44 void setSellPercent();
45 void init();
46 void tradingBot();
47 void algoBot();
48 void getPrice();
49 void formatPrice(json::value const &);
50 void getTime(); //Get epoch time (It will be needed for the signature)
51 void HMACsha256(string const&, string const&);
52 void checkBuy();
53 void checkSell();
54 void getHistoricalPrices();
55 void formatHistoricalPrices(json::value const &);
56 void calcRSI();
57 void calcStochRSI();
58 void backTest();//temp
59 void clearVecs();
60 void simBuy();
61 void simSell();
62 void getTotal();
63
64}bot;
65#endif /* BinanceBot_h */