14 #include <unordered_map>
29 std::vector<OrderDetail> buyHistory;
30 std::vector<OrderDetail> sellHistory;
31 std::vector<MatchedOrderDetail> _purchaseHistory;
32 std::unordered_map<OrderId, OrderDetail> _liveOrders;
35 Price lastPrediction = 0;
36 Price PRICESCALE = 500;
42 std::pair<std::vector<OrderDetail>, std::vector<OrderDetail>> _getLiveOrders()
const;
57 void saveHistoryToJson(
const std::string& filename,
const std::vector<OrderDetail> history);
62 void saveHistoryToJson(
const std::string& filename,
const std::vector<MatchedOrderDetail> history);
67 void _loadJsonLiveOrders(
const std::string& SellFilename,
const std::string& buyFilename);
72 void _printLiveOrders(
const std::string& SellFilename,
const std::string& buyFilename);
77 void _printAHistory(
const std::vector<OrderDetail>& history);
83 double getCurrentTimeAsFractionOfDay();
88 void loadHistoryToNeuralNetwork(std::vector<Price> inputPrice, std::vector<Price> outputPrice);
95 const std::vector<unsigned> topology = { 2, 3, 1 };
135 void saveHistoryToJson(
const std::string& buyfilename,
const std::string& sellfilename,
const std::string& purchasefilename);
140 void saveHistoryToJson(
const std::string& buyfilename =
"BuyHistory.json",
const std::string& sellfilename =
"SellHistory.json",
const std::string& purchasefilename =
"PurchaseHistory.json",
const std::string& liveSellOrdersFilename =
"LiveSellHistory.json",
const std::string& buySellOrdersFilename =
"LiveBuyHistory.json");
Defines the NeuralNetwork class for managing and running a neural network.
Defines the OrderDetail class for storing detailed information about individual orders.
OrderType
Specifies the different types of orders that can be used in a trading system.
Definition: OrderType.hpp:18
Side
Represents the side of an order in a trading system (either buy or sell).
Definition: Side.hpp:16
std::int32_t Price
Represents the price of an order or trade.
Definition: Usings.hpp:21
std::uint32_t Quantity
Represents the quantity or volume of assets in an order or trade.
Definition: Usings.hpp:29
std::uint64_t OrderId
Represents a unique identifier for an order.
Definition: Usings.hpp:37
Manages a neural network's structure, data, and training process.
Definition: NeuralNetwork.hpp:22
void loadTogology(const std::vector< unsigned > &topology)
Loads the topology of the neural network.
Definition: NeuralNetwork.cpp:19
Manages the history of orders and tracks live orders in the orderbook.
Definition: OrderDetailHistory.hpp:27
void addOrderToPurchaseHistory(const Price price, const Quantity qty)
Adds a new purchase order to the purchase history.
Definition: OrderDetailHistory.cpp:91
void removeMatchedOrder(const OrderId bidId, const OrderId askID)
Removes matched orders by IDs from the live orders map.
Definition: OrderDetailHistory.cpp:48
OrderDetailHistory()
Default constructor that initializes the neural network with a predefined topology.
Definition: OrderDetailHistory.hpp:94
std::unordered_map< OrderId, OrderDetail > getLiveOrders()
Retrieves a map of all currently live orders.
Definition: OrderDetailHistory.cpp:194
void _printLiveOrders()
Prints the live orders to the console.
void saveHistoryToJson(const std::string &buyfilename, const std::string &sellfilename, const std::string &purchasefilename)
Saves the buy, sell, and purchase histories to JSON files.
void _printBuyHistory()
Prints the buy history to the console.
Definition: OrderDetailHistory.cpp:107
void addOrderToHistory(const OrderType type, const OrderId id, const Side side, const Price price, const Quantity qty)
Adds an order to the appropriate history (buy or sell) based on its side.
Definition: OrderDetailHistory.cpp:77
int sellHistorySize() const
Returns the size of the sell history.
Price getPrediction()
Retrieves the last prediction from the neural network.
Definition: OrderDetailHistory.cpp:185
void deleteALiveOrder(OrderId id)
Deletes a live order by ID.
Definition: OrderDetailHistory.cpp:203
int buyHistorySize() const
Returns the size of the buy history.
void saveHistoryToJson(const std::string &buyfilename="BuyHistory.json", const std::string &sellfilename="SellHistory.json", const std::string &purchasefilename="PurchaseHistory.json", const std::string &liveSellOrdersFilename="LiveSellHistory.json", const std::string &buySellOrdersFilename="LiveBuyHistory.json")
Saves multiple histories including live orders to JSON files.
void _printSellHistory()
Prints the sell history to the console.
Definition: OrderDetailHistory.cpp:99
Price getVWAP()
Calculates the Volume-Weighted Average Price (VWAP) of all purchases.
Definition: OrderDetailHistory.cpp:130
int purchaseHistorySize() const
Returns the size of the purchase history.
void updateNeutralNetwork(Price price, Quantity quantity)
Updates the neural network with the latest order price and quantity data.
Definition: OrderDetailHistory.cpp:213
void _printPurchaseHistory()
Prints the purchase history to the console.
Definition: OrderDetailHistory.cpp:115