In some of my algorithms, logs don't get generated even though I am sure the log code gets executed.
I have created a simple example where it happens.
The algo is pretty simple, (in daily mode), I just buy one day and sell the next day and so on
My log code looks like this
stock_order = get_order(context.order_id)
if stock_order:
message = ',buy,price={price},amount={amount}'
message = message.format(amount=stock_order.amount, price=data[context.stock].price)
log.info(message)
record(BUY=data[context.stock].price)
return
If I run it from 11/05/2003 to 11/28/2003, even though buy and sell happens, I don't get the corresponding logs. If I run it over longer periods, logs do get generated, so I am wondering if the log buffer is getting lost or something,
One reason it might not be generating logs is if the stock_order doesn't get filled. If that is the case, then the record() shouldn't get generated either, but it does
If the order gets filled after a delay (due to the function being asynchronous), should add a sleep() before seeing if stock_order is valid? I remember seeing it in some algo, but most sample algos don't seem to have it.
Thanks!
Ajay
PS: Ignore the INTC v/s AAPL flap in the code.