· 7 years ago · Apr 26, 2018, 11:30 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 TechnicalAnalysis{
31 vector<long double> RSI, stochRSI;
32 public:
33 void calcRSI();
34 void calcStochRSI();
35}TechnicalAnalysisCalcs;
36
37class serverData{
38 double price;
39 string pair;
40 string epochTime;
41 string signature; //THIS IS THE HMAC SHA256 SIGNATURE. USES MESSAGE AND YOUR SECRET API KEY
42 string secretKey = "YOUR SECRET KEY HERE"; //THIS IS THE KEY FOR THE HMAC SHA256
43 string APIKEY = "YOUR KEY HERE";
44public:
45 void setPair();
46 void getPrice();
47 void setPrice(double foundPrice);
48 void getTime(); //Get epoch time (It will be needed for the signature)
49 void HMACsha256(string const&, string const&);
50}servData;
51
52class algorithmBot{
53 double sellPercent;
54 bool algoCheck,algoBuy;
55
56public:
57 void setSellPercent();
58 void checkBuy();
59 void checkSell();
60
61}algoBot;
62
63class backTesting{
64 double USDT, BTC=0, LTC=0, ETH=0, BCC=0, BNB=0, NEO=0, ADA=0, QTUM=0, total;
65 double pastPrice;
66
67public:
68 void backTest();//temp
69 void simBuy();
70 void simSell();
71 void getTotal();
72}backTest;
73
74class pricingData{
75 vector<long> openTime,closeTime,numTrades;
76 vector <long double> open, high, low, close, volume, quoteAssetVolume,takerBuyAssetVol,takerBuyQuoteAssetVol,ignore;
77
78public:
79 friend class TechnicalAnalysis;
80
81 void tradingBot();
82 void formatPrice(json::value const &);
83 void getHistoricalPrices();
84 void formatHistoricalPrices(json::value const &);
85 void clearVecs();
86
87
88}priceData;
89#endif /* BinanceBot_h */