Skip to content

Commit

Permalink
Added Warmup Period
Browse files Browse the repository at this point in the history
  • Loading branch information
evanwporter committed Sep 25, 2023
1 parent 22584ec commit 79bfc0c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions DataHandler/dh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ DataHandler::DataHandler() {
symbols.push_back(std::string(std::string_view(symbol.get_string())));
};

std::string path = std::string(std::string_view(settings["DATA_DIRECTORY"].get_string()));
warmup_period = settings["DATA_WARMUP_PERIOD"].get_uint64();

std::string path = std::string(std::string_view(settings["DATA_DIRECTORY"].get_string()));

quiet = settings["QUIET"].get_bool();
money_mult = settings["MONEY MULTIPLIER"].get_uint64();
// warmup_period = settings["MONEY MULTIPLIER"].get_uint64();

for(std::string symbol : symbols) load_csv(symbol, path);//"C:\\Users\\evanw\\options\\");

Expand Down
1 change: 1 addition & 0 deletions DataHandler/dh.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DataHandler {
sd::ondemand::document settings;
bool quiet = true;
unsigned long money_mult = 1;
unsigned long warmup_period = 1;

unsigned int total_bars, current, data_size;

Expand Down
4 changes: 2 additions & 2 deletions RiskHandler/risk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ double RiskHandler::check_weights(std::string symbol, double weight_adjustment,
else current_weight = (portfolio->holdings[symbol][-1] / portfolio->TE);
potential_weight = current_weight + (weight_adjustment * direction);

std::cout << symbol << " " << current_weight << " " << portfolio->holdings[symbol][-1] << " ";
// std::cout << symbol << " " << current_weight << " " << portfolio->holdings[symbol][-1] << " ";


// Scale quantity down
Expand All @@ -58,6 +58,6 @@ void RiskHandler::on_signal(std::string symbol, Direction direction)

// int quantity = (portfolio->TE * WA / price);
int quantity = 1;
std::cout << portfolio->positions[symbol].quantity * price << " " << WA << " " << portfolio->TE << " " << price << " " << portfolio->positions[symbol].quantity << std::endl;
// std::cout << portfolio->positions[symbol].quantity * price << " " << WA << " " << portfolio->TE << " " << price << " " << portfolio->positions[symbol].quantity << std::endl;
if (quantity != 0) portfolio->on_fill(symbol, price, quantity, direction);
}
Binary file added backtest.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ void engine() {
strategy.dh = &dh;
strategy.rh = &rh;

for(dh.current = 0; dh.current < dh.total_bars; dh.current++) {
if (dh.current > 100) {
for(dh.current = dh.warmup_period; dh.current < dh.total_bars; dh.current++) {
if (dh.current) {
strategy.on_data();
p.update_value();
};
Expand Down
2 changes: 1 addition & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

"DATA_INTERVAL" : "1d",
"TRADING_INTERVAL" : "1d",
"DATA_WARMUP_PERIOD" : 500,
"DATA_WARMUP_PERIOD" : 100,
"DATA_DIRECTORY" : "Data\\",

"STRATEGY" : "UpDownTick",
Expand Down

0 comments on commit 79bfc0c

Please sign in to comment.