【发布时间】:2018-04-19 04:56:47
【问题描述】:
我有一个项目编译后在ubuntu上运行良好,sn-p是这样的:
void Backtest::start()
{
std::cout << "start !!" << std::endl;
std::cout << bars.size()<< std::endl;
int jj=0;
while(jj<bars.size()){
std::cout << "on bar " << jj<<std::endl;
newBar(&bars[jj]);
jj++;
}
}
在 ubuntu 上一切正常,条形大小约为 3020,但在 centOS 7 上它仅在 jj =3 处终止,gdb 输出:
(gdb) next
start !!
3020
407 count = 0;
(gdb)
408 jj=0;
(gdb)
409 while(jj<bars.size()){
(gdb)
410 std::cout << "on bar " << jj<<std::endl;
(gdb)
on bar 0
411 newBar(&bars[jj]);
(gdb)
412 jj++;
(gdb)
409 while(jj<bars.size()){
(gdb)
410 std::cout << "on bar " << jj<<std::endl;
(gdb)
on bar 1
411 newBar(&bars[jj]);
(gdb)
412 jj++;
(gdb)
409 while(jj<bars.size()){
(gdb)
410 std::cout << "on bar " << jj<<std::endl;
(gdb)
on bar 2
411 newBar(&bars[jj]);
(gdb)
412 jj++;
(gdb)
409 while(jj<bars.size()){
(gdb)
410 std::cout << "on bar " << jj<<std::endl;
(gdb)
on bar 3
411 newBar(&bars[jj]);
(gdb)
asd
|100000.000000,100000.000000|
get cash 100000.0
412 jj++;
(gdb)
409 while(jj<bars.size()){
(gdb)
415 }
在 gdb 409 它奇怪地给出了空循环并终止,这里可能有什么问题???
void Backtest::newBar(Bar* b)
{
if(Number == count+1){
tempbars.push_back(*b);
crossLimitOrder();
strategyPy->onBar(tempbars);
tempbars.clear();
count = 0;
}else{
tempbars.push_back(*b);
count ++;
}
}
PS newBar 是项目中的其他东西,它基本上是调用一个 strategyPy 来做某事,这将调用一个 boost python 模块来调用 C++ 函数(它为 python 提供了一些 API,包括 getCash(),这就是它的原因在调试信息中打印出来)
【问题讨论】:
-
什么是
newBar()?此外,如果该函数是非静态成员,则Backtest实例最好是有效的。 -
你有另一个线程在运行吗? “拿钱”从何而来?
-
刚刚更新了新栏