Update added the canFulfillOrder function
This commit is contained in:
@ -83,7 +83,16 @@ void MerkelMain::enterAsk()
|
||||
tokens[0],
|
||||
OrderBookType::ask
|
||||
);
|
||||
orderBook.insertOrder(obe);
|
||||
if(wallet.canFulfillOrder(obe))
|
||||
{
|
||||
std::cout << "Wallet looks good. " << std::endl;
|
||||
orderBook.insertOrder(obe);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Wallet has insufficient asks" << std::endl;
|
||||
}
|
||||
|
||||
}catch (const std::exception& e)
|
||||
{
|
||||
std::cout << " MerkelMain::enterAsk Bad input " << std::endl;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "Wallet.h"
|
||||
#include "CSVReader.h"
|
||||
#include <iostream>
|
||||
|
||||
Wallet::Wallet()
|
||||
{
|
||||
@ -78,6 +79,7 @@ bool Wallet::canFulfillOrder(OrderBookEntry order)
|
||||
{
|
||||
double amount = order.amount;
|
||||
std::string currency = currs[0];
|
||||
std::cout << "Wallet::canFulfillrder " << currency << ":" <<amount << std::endl;
|
||||
return containsCurrency(currency, amount);
|
||||
}
|
||||
if(order.orderType == OrderBookType::bid)
|
||||
|
||||
Binary file not shown.
@ -8,15 +8,15 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
//MerkelMain app{};
|
||||
//app.init();
|
||||
Wallet wallet;
|
||||
wallet.insertCurrency("BTC", 10);
|
||||
wallet.insertCurrency("USDT", 100.83);
|
||||
std::cout << wallet.toString() << std::endl;
|
||||
MerkelMain app{};
|
||||
app.init();
|
||||
// Wallet wallet;
|
||||
// wallet.insertCurrency("BTC", 10);
|
||||
// wallet.insertCurrency("USDT", 100.83);
|
||||
// std::cout << wallet.toString() << std::endl;
|
||||
//std::cout << "Wallet has BTC " << wallet.containsCurrency("USDT", 100.50) << std::endl;
|
||||
wallet.removeCurrency("USDT", 10);
|
||||
std::cout << wallet.toString() << std::endl;
|
||||
// wallet.removeCurrency("USDT", 10);
|
||||
// std::cout << wallet.toString() << std::endl;
|
||||
//CSVReader::readCSV("20200317.csv");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user