Moonshot Not Trading on Last Row?

It seems Moonshot is not trading based on the last row of the frame. Here the setup for the situation. I have the following order:

You see the submitted is at 18:11:09. I have noticed a consistency with order timing. The submit time of orders seems to happen a few seconds (5-15s) after the NEXT minute. So with this assumption, I converted the submit time to EST as I am working with US Stocks and checked my logs for 13:10:00 for that SID:

Which shows that my signal for that minute is 0.

So, I check 18:11:00 (13:11:00) just in case my assumption is wrong, which provides this frame:

Which still provides a 0 signal in the final row. Note though, that 13:10's signal did change between the minute. I know why this is happening. I am using alpaca's live data feed and not using minute aggregates. I am instead using the current price (I believe the field is last price) at the moment of trade. I am open to more precise ways to produce the current candle's price for intraday trading using alpaca if anyone has a better idea.

But this isn't my issue. My issue is why is quantrocket/Moonshot placing an order in this situation? It is my understanding that moonshot only uses the last row of the signals frame to dictate if an order should be placed. In this scenario, the last frame of the signal's data frame for both 13:10 and 13:11 was 0. Ergo, Quantrocket shouldn't have placed an order at all.

Open to thoughts on this. Please correct my assumptions if they are wrong.

Thanks in advance!

The order that Moonshot sends depends not only on the signal but on the combination of the signal and current position. A signal of 0 means you want to have no position. If you have an existing position, a signal of 0 will result in Moonshot sending an order to close the position. If you have no position, a signal of 0 will result in Moonshot sending no order. So a signal of 0 and a SELL or BUY order are not incompatiable; consult the existing position too.

To help be sure which row of your DataFrame Moonshot is using, open the detailed logs while trading; Moonshot will print the date and time of the row it is using.

I'm not quite following what you're describing about the Alpaca live data feed, but it strikes me that validating orders against signals will be very hard and confusing if the signal is changing for whatever reason.

Thanks for that Brian! Your first paragraph makes since. I ended up swapping to an Alpaca Aggregate db and live trading on a review date 40s before the current candle. This way, my close prices isn't changing during the following candle.

That's a good tip in paragraph 2!! I hadn't noticed that row being logged during the detailed flight logs.

Just to add clarity on the last paragraph, I add setup my tick db to query alpaca's "LastPrice" field. which is basically the current price at that moment within the candle. So, during the minute that LastPrice can change and the bids and asks change. I had used that field thinking it was like a "Current Price."