Maybe we could find a place to nominate Quantopian for an engineering award.
"Quantopian takes end of day leverage into account only" ... is correct. Made a thread for my algo, can discuss there.
On limit orders, would they see those and disqualify? Otherwise, one could, for example:
1. optimize early
2. set limits when orders are filled
3. near the end of the day, look at winners (pnl = pos[s].amount * (data.current(s, 'price') - pos[s].cost_basis)), place them in a Series, sort_values(), select some of the best, and use opt with freeze to add value to them, so long as each would not exceed risk thresholds. Except for the last part, I have code that turns out to be surprisingly efficient at bringing leverage near 1, just that with certain algorithms I would have to run it earlier than I'd like, say, 20 minutes before close, and sometimes then again around 10 if still too close to upper or lower bounds.
Or with opt later in the day, just cancel all [stop, limit] orders before it runs and re-make them after.
Maybe they will add stop & limit. It's pretty complex & processor intensive. For example, have to modify their amounts with each partial fill.
Thx for the notebook.