OverflowError: Can't order 100000000000 shares

Hi folks, 



When I try backtesting of puting equity orders for a very long time on my algorithm, sometimes this OverflowError generates from running order(asset, shares) or order_target_percent(asset, weight)

&nbsp; File &quot;~/zipline/algorithm.py&quot;, line 1919, in order_target_percent(style=style)<br />
&nbsp; File &quot;~/zipline/utils/api_support.py&quot;, line 125, in wrapped_method<br />
&nbsp; &nbsp; return method(self, *args, **kwargs)<br />
&nbsp; File &quot;/~/zipline/algorithm.py&quot;, line 1310, in order<br />
&nbsp; &nbsp; return self.blotter.order(asset, amount, style)<br />
&nbsp; File &quot;~/zipline/finance/blotter/simulation_blotter.py&quot;, line 97, in order<br />
&nbsp; File &quot;~/zipline/finance/blotter/simulation_blotter.py&quot;, line 138, in order<br />
&nbsp; &nbsp; self.max_shares)<br />
<br />
OverflowError: Can&#39;t order more than 100000000000 shares```&nbsp;<br />
<br />
So far, I have tried to specify ordering different stocks, narrowing down the time range(I would like to generate the results of 20 years, but backtesting on only 3-5 years worked), and handling this error as exception. But still it breaks the algo; the problem seems from `data.current(asset, &#39;price&#39;) ?= NaN`, but handling 0 or NA should already be included in the package.<br />
<br />
I hope someone could figure this out, and thanks so so much for the help!&nbsp;

Thanks for raising this issue! It is an interesting aspect how missing data should be handled in a trading algorithm. If the data for the current time is missing, we can either return NaN or last known value. Returning Nan transfer the decision to the user. The user must now decide what to do with Nan (ignore, stop etc.). The other option (return the last known price) sounds nicer, but returning a stale price transparently can be dangerous - the strategy will now make a decision on a stale price to buy and sell. I think this is a tough choice. But I suggest in any case, if you share your strategy that reproduces this error to blueshift-support@quantinsti.com, we can take a look.

Hi Prodipta, Thank you so much for the quick response and helping out. I did bypass that error with replacing with the last know price for now. I was testing on the simple algo from Trading Evolved book, and will definitely email you the entire scripts. 

However, I also took a look at the package, and the current program really couldn't deal with our discussion (and creates a warning to break :(   Hope someone could have a solid idea and improve this part very soon. 



Again, thanks and have a good one!