forked from shxhid01/TradingSimulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTradingBot.h
82 lines (65 loc) · 2 KB
/
TradingBot.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef TRADINGBOT_H
#define TRADINGBOT_H
#include <QObject>
#include <string>
#include <fstream>
#include <vector>
#include <QtCharts>
#include <QString>
#include <string>
#include <vector>
class TradingStrategy;
class RiskManagement;
class Market;
class TradingBot : public QObject {
Q_OBJECT
public:
explicit TradingBot(const QString &username, QObject *parent = nullptr);
~TradingBot();
void recordTrade(const std::string& action, double price, int quantity);
void resetToInitialState();
QString username;
// Getters
double getCurrentPrice() const;
double getTotalValue() const;
const std::string& getLastMarketEvent() const;
double getBalance() const;
int getOwnedStocks() const;
double getTotalReturn() const;
double getMaxDrawdown() const;
double getVolatility() const;
double getMarketVolatility() const;
double getSharpeRatio() const;
std::string getCurrentStrategyName() const;
double getProfitLossSinceStart() const;
double getProfitLossSinceLastUpdate() const;
int getCurrentDay() const;
int getLastBuys() const;
int getLastSells() const;
int getLastHolds() const;
int getTotalBuys() const;
int getTotalSells() const;
int getTotalHolds() const;
// Setters and control functions
void setStrategy(int index);
void initializeSimulation(int days);
void executeNextDay();
bool isSimulationComplete() const;
void updateTotalActions();
// New functions for graph generation
void generateBalanceGraph();
void generateStockPriceGraph();
void generateGraphs();
private:
class TradingBotImpl;
TradingBotImpl* pImpl;
std::ofstream tradeFile;
void logTrade(int day, double currentPrice, const std::string& tradeAction, double actionTaken);
// New vectors to store balance and stock price history
std::vector<double> balanceHistory;
std::vector<double> stockPriceHistory;
signals:
void updateUI();
void simulationComplete();
};
#endif // TRADINGBOT_H