#include #include #include #include #include "helpers.h" #include "argh.h" #include "common.h" int main(int argc, const char* argv[]) { argh::parser args; args.add_params({ "s", "stock" }); args.add_params({ "m", "money" }); args.parse(argc, argv); std::string network, input; args(1) >> network; args(2) >> input; double money, start_money; unsigned stock, start_stock; args({"s", "stock"}, 1000) >> stock; args({"m", "money"}, 1000.) >> money; start_money = money; start_stock = stock; std::function normalizer = [](const double& result) -> double { return erf(result); }; current_decider decider(normalizer); std::ifstream network_file(network, std::ios::in | std::ios::binary); std::ifstream input_file(input); decider.load(network_file); double price; decider.start_money = money; decider.start_stock = stock; std::cout << "x,price,decsion,money,stock" << std::endl; input_file >> price; decider.reset(price); int i = 0; do { auto decision = decider.decide(price, money, stock); auto current = price * stock + money; auto max_credit = std::max(current * 0.05, -1e4); if (decision < 0) { decision = std::max(decision, -stock); // cannot sell more than we actually have } else if (decision > 0) { decision = std::min(floor((money + max_credit) / price), decision); } money -= price * decision; stock += decision; std::cout << ++i << "," << price << "," << decision << "," << money << "," << stock << std::endl; } while(input_file >> price); std::cout << "Koniec: " << money + stock*price << std::showpos << "(" << (money + stock*price) / (start_money + start_stock*price) << ")"; /* decider.network.save(std::cout); */ }