New Alphanaut RAG released

Hello,

We just released a version of our AI agent Alphanaut that uses an improved RAG collection (atm only available in the screener). We had a problem with the previous version where it stopped accessing the RAG entirely and became very dumb all of a sudden. The fix (or hack?) was to force the LLM to make a tool call every time. It seems much smarter at writing formulas now.

The new RAG comprises of:

  • All our reference material
  • Several general FAQs
  • Several formula examples

In my tests it performed flawlessly for these questions:

Screen for biotech companies
How do I setup my account to receive earnings via PayPal?
Screen for stocks that have gapped up

We will continue to make improvements like:

  • Add more RAG from the KB and from the forums.
  • Add more FAQs and examples
  • Add many more tools

Thanks in advance for your feedback.

Cheers

1 Like

I spent a while trying it out. Gave it one of P123’s screens and asked it to make some suggestions working on different universes. It made what seemed like very thoughtful suggestions. Unfortunately, the suggested changes didn’t work. Nevertheless even though this first experiment didn’t work I like the idea of a tool suggesting modifications with actual equations to try out. This is obviously going to improve as it has more data to work off of.

I tried it out a couple of times with decent analysis generated. When tried out in the screen the results were mixed with marginal total return increase in some cases with a slight increase in stability.

However, I did hit the following error when I copied the code:

Aborted! ERROR: Value not set for temp variable @SIChg uid 120212

Building on this:

SetVar(@ShortInterest,(FRank("SI%Float" , #PREVIOUS, #ASC, #ExclNA)))

Between(@ShortInterest, 5, 98)

This was suggested:

5) Consider adding short-interest change (optional but often more informative)

Level alone can be stale. If you want to avoid names where shorts are rapidly covering (or rapidly piling in), add a change rank. Example using your existing SI%FloatPM:

SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)

This targets “not the biggest decreases, not the biggest spikes.”

I corrected it to get it to run:

SetVar(@SIChg2, (((SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))))

SetVar(@RankSIChg, FRank("@SIChg2", #PREVIOUS, #DESC, #ExclNA))

The corrections were to add a “2” to the variable name and amend the parentheses.

I saved the screen fragment that captures this and made it public.

https://www.portfolio123.com/app/screen/summary/330068?mt=1

Hope this helps you track down the issue.

Rich

Is this code supposed to be problematic? A copy/paste into the screener showed no problems.

Yes, I just reran it and got the same error.

Aborted! ERROR: Value not set for temp variable @SIChg uid 120212

However, when I commented out the lines before these lines it ran successfully.

What???

May I login and review the screen?

Yes, please do. Name is “Error 20260417A” and is Public.

https://www.portfolio123.com/app/screen/summary/330075?st=1&mt=1

Looks like a bug to me. Moving Between(@ShortInterest, 5, 98) to the bottom of the rules list, removes the error report.

Ok, not a bug.

SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98) // Move to bottom to work
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)

The FRank function on line 4 requires @SIChg to be defined for every stock in the universe, not just the subset that passed the filter. But line 2's Between check eliminates stocks before @SIChg is assigned on line 3, so those eliminated stocks never get a value. When FRank then tries to rank all stocks by @SIChg , it hits the unassigned stocks and errors out.

We have 4 solutions. Not all solutions are equivalent. Some filter the Ticker list twice, and others filter the Ticker list in sequence.

Solution 1: Pre-assign values to @SIChg

SetVar(@SIChg,NA) // Preload
SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98) 
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)

Solution 2: Move ShortInterest filtering after FRank()

SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #All, #DESC, #ExclNA))
Between(@RankSIChg, 20, 90)
Between(@ShortInterest, 5, 98) // Here I am!

Solution 3: FRank() tickers that pass ShortInterest filter by using #Previous scope

SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98) 
SetVar(@SIChg, (SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1))
SetVar(@RankSIChg, FRank("@SIChg", #Previous, #DESC, #ExclNA)) // Note use of #Previous to define scope
Between(@RankSIChg, 20, 90)

Solution 4: Don't pass a filtered list to FRank() by embedding the formula directly in FRank()

SetVar(@ShortInterest,(FRank("SI%Float", #All, #ASC, #ExclNA)))
Between(@ShortInterest, 5, 98) 
SetVar(@RankSIChg, FRank("(SI%Float - Max(SI%FloatPM,1)) / Max(SI%FloatPM,1)", #All, #DESC, #ExclNA)) // Literal formula
Between(@RankSIChg, 20, 90)

Thank you for investigating. I would tend towards the #PREVIOUS solution based on my style. It just means that in using the RAG recommendations one needs to be aware of the larger context since it seems to return #ALL.

Thanks,

Rich

1 Like

@Marco , when dealing with LLM context sessions, they give the most weight to the beginning of the context and the end of the context. The middle area is the dumb zone. In claude code for example, when the context window gets above 40%, or 80,000 tokens that’s when its time for a refresh. So large plans need to be broken up into sub plans that can be completed in less than 80,0000 tokens for claude code. I use a custom made skill to do this.

1 Like