Query editor
-- TSI v2 | Tokenized Capital Opportunity ScoreWITH b AS (SELECT a.*, c.instrument_type,c.leveraged_flag,c.narrative_bucketFROM query_8542360 aJOIN query_8542347 c USING(contract_address)), breadth AS (SELECT underlying_ticker,count(DISTINCT issuer) live_issuersFROM query_8541922WHERE registry_quality_status='PASS' AND current_aum_usd IS NOT NULLGROUP BY 1), rot AS (SELECT underlying_ticker,issuer_share_change,rotation_stateFROM query_8541931 WHERE issuer='BSTOCKS'), features AS (SELECT b.*,coalesce(d.live_issuers,1) live_issuers,r.issuer_share_change,r.rotation_state,CASE WHEN previous_day IS NULL THEN NULL ELSE supply_effect_usd/nullif(previous_aum,0) END supply_effect_ratio,CASE WHEN previous_day IS NULL THEN NULL ELSE (price-previous_price)/nullif(previous_price,0) END price_returnFROM bLEFT JOIN breadth d USING(underlying_ticker)LEFT JOIN rot r USING(underlying_ticker)), scored AS (SELECT *,CASE WHEN previous_day IS NULL OR leveraged_flag THEN NULL ELSEleast(30.0,greatest(0.0,15.0+1500.0*coalesce(supply_effect_ratio,0)))+least(20.0,greatest(0.0,10.0+1000.0*coalesce(issuer_share_change,0)))+CASE WHEN live_issuers>=4 THEN 15.0 WHEN live_issuers=3 THEN 12.0 WHEN live_issuers=2 THEN 8.0 ELSE 3.0 END+CASE WHEN aum>=50000000 THEN 15.0 WHEN aum>=10000000 THEN 12.0 WHEN aum>=1000000 THEN 8.0 ELSE 4.0 END+CASE WHEN coalesce(supply_effect_ratio,0)>0.0025 AND coalesce(price_return,0)<0 THEN 20.0WHEN coalesce(supply_effect_ratio,0)>0 THEN 10.0 ELSE 0.0 ENDEND opportunity_scoreFROM features)SELECT *,CASE WHEN leveraged_flag THEN 'LEVERAGED_INSTRUMENT_EXCLUDED'WHEN previous_day IS NULL THEN 'BASELINE_ONLY'WHEN opportunity_score>=80 THEN 'ACCUMULATION_CONFIRMED'WHEN opportunity_score>=60 THEN 'ACCUMULATION_WATCH'WHEN opportunity_score<=35 THEN 'DISTRIBUTION_OR_WEAK'ELSE 'NEUTRAL' END opportunity_state,CASE WHEN previous_day IS NULL THEN 'Wait for the next adjacent daily snapshot'WHEN leveraged_flag THEN 'Track separately; do not treat leverage-product issuance as direct equity allocation'ELSE 'Score is research prioritization, not a buy or sell instruction' END guardrailFROM scoredORDER BY opportunity_score DESC NULLS LAST,aum DESC NULLS LAST