Impelemented enterBid

This commit is contained in:
Lev
2021-06-12 22:36:17 -05:00
parent c0552cb3b7
commit 8f47d171f0
2 changed files with 35 additions and 1 deletions

View File

@ -104,7 +104,41 @@ void MerkelMain::enterAsk()
void MerkelMain::enterBid()
{
std::cout << "Make a bid - enter the amount" << std::endl;
std::cout << "Make a bid - enter the amount: product,price, amount, eg ETH/BTC,200,0.5" << std::endl;
std::string input;
std::getline(std::cin, input);
std::vector<std::string> tokens = CSVReader::tokenise(input, ',');
if (tokens.size() != 3)
{
std::cout << "MerkelMain::enterBid Bad input! " << input << std::endl;
}
else {
try {
OrderBookEntry obe = CSVReader::stringsToOBE(
tokens[1],
tokens[2],
currentTime,
tokens[0],
OrderBookType::bid
);
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::enterBid Bad input " << std::endl;
}
}
std::cout << "You typed: " << input << std::endl;
}
void MerkelMain::printWallet()