diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6933d53 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +cpp=cl +link=link + +cppflags=/EHsc /std:c++latest /nologo /O2 +linkflags=/nologo + +all: macd.exe tester.exe trainer.exe + +.cpp.obj: + $(cpp) /c $(cppdebug) $(cppflags) $(cppvars) $*.cpp + +macd.exe: macd.obj + $(link) $(ldebug) $(conflags) /out:macd.exe macd.obj $(conlibs) + +tester.exe: tester.obj decider.obj + $(link) $(ldebug) $(conflags) /out:tester.exe $** $(conlibs) + +trainer.exe: trainer.obj decider.obj + $(link) $(ldebug) $(conflags) /out:trainer.exe $** $(conlibs) + +clean: + del *.obj + del *.lst + del *.exe diff --git a/common.cpp b/common.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/decider.h b/decider.h index e490096..c6f1fb1 100644 --- a/decider.h +++ b/decider.h @@ -115,8 +115,10 @@ private: vector prices; vector tech; + // prices are normalized as percent change value for (int j = 0; j < p; j++) { - prices.set(j, 0, this->prices[j]); + auto diff = this->prices[j] - this->prices[j+1]; + prices.set(j, 0, diff / this->prices[j+1]); } int i = 0; @@ -128,8 +130,6 @@ private: tech.set(i, 0, signal[j]); } - // prices are normalized in their domain - prices = normalize(prices); // analytic data is normalized in its own domain tech = normalize(tech); diff --git a/tester.cpp b/tester.cpp index 3fcce97..a50e927 100644 --- a/tester.cpp +++ b/tester.cpp @@ -69,7 +69,7 @@ int main(int argc, const char* argv[]) } while(input_file >> price); - std::cout << "Koniec: " + std::cout << "Koniec: " << money + stock*price << std::showpos << "(" << (money + stock*price) / (start_money + start_stock*price) << ")"; diff --git a/wtf.cpp b/trainer.cpp similarity index 100% rename from wtf.cpp rename to trainer.cpp diff --git a/trainer.h b/trainer.h index bcf7c97..520e1d4 100644 --- a/trainer.h +++ b/trainer.h @@ -39,7 +39,10 @@ public: : factory(factory), id(0), generation(1), money(money), stock(stock), n(n), random_engine(std::time(0)) { this->q = [=](std::shared_ptr> x, const dataset& input, double money, unsigned stock) { - return (money + stock * input.back()) / (this->money + this->stock * input.front()); }; + auto result = (money + stock * input.back()) / (this->money + this->stock * input.front()); + + return result / (1 + abs(result)); + }; add(n); }