Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the bug is fixed : " context_.feed" is empty, in the method "void StrategyCD::on_start(void)" #1

Open
rendezvoush opened this issue Sep 7, 2024 · 0 comments

Comments

@rendezvoush
Copy link

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;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant