Running live strategies on basket of 200 stocks using exploration window

I am running a strategy on a basket of 200 stocks using exploration window. The problem i am facing is when a signal is generated on at the same bar i want to use positionscore to decide on which stock to place an order. But in reality my script places order as soon as it finds a signal , so basically stocks whose name is higher in alphabetical order get preference instead.
Any guidance would be appreciated !!

The most obvious solution would be to use a back test to drive your auto trading instead of the exploration. That way the entries will already be ordered by PositionScore.

1 Like

If you want to rank in exploration then check out examples of knowledge base articles and users guide.

1 Like

This would be the ideal soln if i could do it. Any guidance or snippets for help ? No clue on how to use backtest for autotrading !!

Since you have provided no details of how auto trading is implemented, I doubt that anyone will be able to provide guidance on how to change your solution from one that is exploration based to one that is back test based. However, you should definitely consider @codejunkie's solution as well. This would require you to loop through all your symbols at the start of each exploration so that you can do the ranking before the rest of the exploration takes place, but there are lots of examples of how to do this.

1 Like

Below is a very basic structure of my code :

//First generate signals


if (Status("action")==actionExplore)
//Place orders based on buy sell trades


I think implementation of autotrading through exploration is very generic, that's why i did not mention the code before. This code runs every 1 min in autoexploration window, finding signals and placing orders.

Thanks for reply. I was thinking i should first generate buy/sell signals and then use that list of stocks which have buy/sell signals to generate ranking on them. Problem is how i should generate my buy/sell signals and save it in a list, which can be used for ranking..Any help on this would be appreciated.

Basically i would want to generate ranks only for symbols which would have buy/sell signal. Any idea on how to do that ?

Can you explain with a short example what do you mean by following ?

"Use back test to drive your auto trading instead of the exploration"

Since you have not provided any details of your current auto-trading implementation, I don't think anyone will be able to provide a meaningful example of how to do it differently. Conceptually, you would need to write a Custom Back Test (CBT) so that you could look for trade entries and exits that occurred on the last bar, and then use those signals to generate auto-trade orders.

1 Like

Thanks for answering my doubt. I understand we can do in CBT, but the problem here is my autotrading requires to check signals every 1 minute which is easy to do in exploration. But how would i run CBT every 1 minute automated ?

Thanks @mradtke . I implemented the idea of executing autotrading through backtesting and also running the backtest through exploration every 1 minute. My code is much smaller than auto-exploration code which i used before. As of now testing it to see , if any bugs :smiley:.

So i am still trying to figure out the best way to run backtest project every 5 min like exploration. Currently running a batch for backtest, every 5 minutes. Do you have any other suggestions ?

That seems like a reasonable approach. Why are you looking for alternatives?