Returns can not be calculated

Hello Friends, 



Here is my piece of code that seizes upon intruction of return variables below. px values calculated perfectly but after I write the return values blueshift seizes to result anything. Can you help ? Is it not possible to have vectorized calculations in Blueshift ?

 

px = price_data[-33:].values
px_lag = price_data[-34:-1].values
px_lag2 = price_data[-35:-2].values

# below code did not work
returns = px / px_lag - 1
returns_lag = px_lag / px_lag_2 - 1

# this did not work either
returns = np.log(px / px_lag)
returns_lag = np.log(px_lag / px_lag_2)

Your question is not very clear. What you mean by "seizes to result anything"? Are you getting an error? If you are running quick backtest and not getting any results, try to run a full backtest. At present there are some issues showing proper error messages for quick backtests on the platform.



What is in "price_data"? If you get it from data.history, it can return different objects depending on your query. What you attempt to do may not work for multi-indexed data frame. Also, try to use pandas shift method instead of index subsetting. If you do it correctly, the vectorized calculation should work. It should work because it has not much to do with Blueshift. You are using numpy vectorized calculations and Blueshift supports numpy.



In case you still have problems, feel free to write to blueshift-support@quantinsti.com with a (minimal) sample strategy code that can reproduce your observation.