Bee Bee

How to print a debug message?

Programming


The python 'print' function doesn't work on the backtest platform. Any one can help?
I tried print("hello world"), but nothing shown in the 'console' session.
 
admin
It is a system design for computational efficiency. When you run a backtest script on the platform, the system will execute and evaluate it in a background process. Therefore, you won't be able to see the message like a usual command-line interface. 
However, the platform supports a python equivalent print function (i.e. self.evt.consoleLog). For your case, you can do something like 
self.evt.consoleLog("hello world")

For more detail, you can refer to the Web API Technical Document "https://algogene.com/TechDoc#Debugging". 
 
Bee Bee
Original Posted by - b'admin':
It is a system design for computational efficiency. When you run a backtest script on the platform, the system will execute and evaluate it in a background process. Therefore, you won't be able to see the message like a usual command-line interface. 
However, the platform supports a python equivalent print function (i.e. self.evt.consoleLog). For your case, you can do something like 
self.evt.consoleLog("hello world")

For more detail, you can refer to the Web API Technical Document "https://algogene.com/TechDoc#Debugging". 
I think that self.evt.print("hello world") is better than self.evt.consoleLog("hello world"), because it is more consistent with the usual python print function.
 
admin
Original Posted by - b'Bee Bee': I think that self.evt.print("hello world") is better than self.evt.consoleLog("hello world"), because it is more consistent with the usual python print function.
Good idea! We will take it into consideration for future release.