Open
Description
With the following modification, it will get the bug fixed., "LOGI("on_start id:{} code:{}", id_, context_.feed->config_.code);" where " context_.feed"is empty, in the method "void StrategyCD::on_start(void)",
void Backtest::make_strategy(uint32_t id)
{
struct BtContext ctx;
ctx.broker = std::make_shared();
ctx.stat = std::make_shared();
ctx.data = std::make_shared();
ctx.stat->init(ctx.broker, ctx.data);
ctx.strategy = func_get_strategy_();
ctx.strategy->set_id(id);
ctx.strategy->init(ctx.broker);
**//comment out 09/04/2024
//ctx.strategy->set_context(ctx);**
if (id == 0) {
ctx.strategy->on_create(config_);
}
ctx.broker->init(config_.broker);
struct feed_config feed_cfg = config_.feed;
if (config_.codes.size() > 0) {
feed_cfg.code = config_.[codes.at](http://codes.at/)(id);
}
ctx.feed = mcache::get_feed(feed_cfg);
//after feed init
ctx.data->setup(ctx.broker, ctx.feed, config_.plot);
ctx.data->setup_plot(config_.func.plot);
ctx.strategy->set_code(config_.[codes.at](http://codes.at/)(id));
**//09/07/2024, get to this position to make changes of ctx to visible to ctx.strategy**
ctx.strategy->set_context(ctx);
context_vector_.push_back(ctx);
if (id == 0) {
context_ = ctx;
}
}
Metadata
Metadata
Assignees
Labels
No labels