-- AutoHedge: complete database setup (tables, permissions, starter data). Run once.
-- AutoHedge schema for a plain PostgreSQL database (Namecheap cPanel).
-- Run once on an EMPTY database:  psql "$DATABASE_URL" -f schema-postgres.sql
SET client_min_messages = warning;

-- gen_random_uuid(): built into PostgreSQL 13+, fallback for older servers.
DO $do$ BEGIN
  IF NOT EXISTS (SELECT 1 FROM pg_proc WHERE proname = 'gen_random_uuid') THEN
    EXECUTE $f$CREATE FUNCTION public.gen_random_uuid() RETURNS uuid LANGUAGE sql VOLATILE AS
      'SELECT (md5(random()::text || clock_timestamp()::text)::uuid)'$f$;
  END IF;
END $do$;

CREATE SCHEMA IF NOT EXISTS auth;
CREATE TABLE IF NOT EXISTS auth.users (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  email text NOT NULL UNIQUE,
  encrypted_password text NOT NULL,
  raw_user_meta_data jsonb NOT NULL DEFAULT '{}'::jsonb,
  created_at timestamptz NOT NULL DEFAULT now()
);
CREATE OR REPLACE FUNCTION auth.uid() RETURNS uuid LANGUAGE sql STABLE AS
  $$ SELECT nullif(current_setting('request.jwt.claim.sub', true), '')::uuid $$;

-- 20260903175947_35ab462e-5b07-4812-a52b-1c79a58ecafc.sql
-- ROLES ---------------------------------------------------------------
CREATE TYPE public.app_role AS ENUM ('admin', 'user');

CREATE TABLE public.user_roles (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
  role public.app_role NOT NULL,
  created_at timestamptz NOT NULL DEFAULT now(),
  UNIQUE (user_id, role)
);


ALTER TABLE public.user_roles ENABLE ROW LEVEL SECURITY;

CREATE OR REPLACE FUNCTION public.has_role(_user_id uuid, _role public.app_role)
RETURNS boolean LANGUAGE sql STABLE SECURITY DEFINER SET search_path = public AS $$
  SELECT EXISTS (SELECT 1 FROM public.user_roles WHERE user_id = _user_id AND role = _role)
$$;

CREATE POLICY "users read own roles" ON public.user_roles FOR SELECT TO public
  USING (auth.uid() = user_id OR public.has_role(auth.uid(), 'admin'));

-- shared updated_at trigger fn
CREATE OR REPLACE FUNCTION public.update_updated_at_column()
RETURNS TRIGGER LANGUAGE plpgsql SET search_path = public AS $$
BEGIN NEW.updated_at = now(); RETURN NEW; END; $$;

-- PROFILES ------------------------------------------------------------
CREATE TABLE public.profiles (
  id uuid PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
  display_name text,
  demo_cash numeric(18,2) NOT NULL DEFAULT 100000,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
CREATE POLICY "read own profile" ON public.profiles FOR SELECT TO public
  USING (auth.uid() = id OR public.has_role(auth.uid(), 'admin'));
CREATE POLICY "update own profile" ON public.profiles FOR UPDATE TO public
  USING (auth.uid() = id) WITH CHECK (auth.uid() = id);
CREATE POLICY "insert own profile" ON public.profiles FOR INSERT TO public
  WITH CHECK (auth.uid() = id);
CREATE TRIGGER profiles_updated_at BEFORE UPDATE ON public.profiles
  FOR EACH ROW EXECUTE PROCEDURE public.update_updated_at_column();

CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS TRIGGER LANGUAGE plpgsql SECURITY DEFINER SET search_path = public AS $$
BEGIN
  INSERT INTO public.profiles (id, display_name)
  VALUES (NEW.id, COALESCE(NEW.raw_user_meta_data->>'display_name', split_part(NEW.email, '@', 1)))
  ON CONFLICT (id) DO NOTHING;
  INSERT INTO public.user_roles (user_id, role) VALUES (NEW.id, 'user')
  ON CONFLICT (user_id, role) DO NOTHING;
  RETURN NEW;
END; $$;
CREATE TRIGGER on_auth_user_created AFTER INSERT ON auth.users
  FOR EACH ROW EXECUTE PROCEDURE public.handle_new_user();

-- STRATEGIES ----------------------------------------------------------
CREATE TYPE public.strategy_status AS ENUM ('draft', 'testing', 'published', 'archived');

CREATE TABLE public.strategies (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  created_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
  name text NOT NULL,
  tagline text,
  description text,
  prompt text NOT NULL,
  universe text[] NOT NULL DEFAULT '{}',
  timeframe text NOT NULL DEFAULT '1Day',
  status public.strategy_status NOT NULL DEFAULT 'draft',
  risk_profile text NOT NULL DEFAULT 'balanced',
  max_position_pct numeric(5,2) NOT NULL DEFAULT 20,
  stop_loss_pct numeric(5,2) NOT NULL DEFAULT 5,
  take_profit_pct numeric(5,2) NOT NULL DEFAULT 12,
  min_confidence numeric(4,3) NOT NULL DEFAULT 0.6,
  is_dynamic boolean NOT NULL DEFAULT false,
  published_at timestamptz,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.strategies ENABLE ROW LEVEL SECURITY;
CREATE POLICY "anyone signed in reads published strategies" ON public.strategies FOR SELECT TO public
  USING (status = 'published' OR public.has_role(auth.uid(), 'admin'));
CREATE POLICY "admins insert strategies" ON public.strategies FOR INSERT TO public
  WITH CHECK (public.has_role(auth.uid(), 'admin'));
CREATE POLICY "admins update strategies" ON public.strategies FOR UPDATE TO public
  USING (public.has_role(auth.uid(), 'admin')) WITH CHECK (public.has_role(auth.uid(), 'admin'));
CREATE POLICY "admins delete strategies" ON public.strategies FOR DELETE TO public
  USING (public.has_role(auth.uid(), 'admin'));
CREATE TRIGGER strategies_updated_at BEFORE UPDATE ON public.strategies
  FOR EACH ROW EXECUTE PROCEDURE public.update_updated_at_column();

-- BACKTESTS -----------------------------------------------------------
CREATE TABLE public.backtests (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  strategy_id uuid NOT NULL REFERENCES public.strategies(id) ON DELETE CASCADE,
  created_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
  start_date date NOT NULL,
  end_date date NOT NULL,
  starting_capital numeric(18,2) NOT NULL DEFAULT 100000,
  status text NOT NULL DEFAULT 'running',
  total_return_pct numeric(10,3),
  win_rate numeric(6,3),
  max_drawdown_pct numeric(10,3),
  sharpe numeric(10,3),
  trade_count integer,
  equity_curve jsonb NOT NULL DEFAULT '[]'::jsonb,
  trades jsonb NOT NULL DEFAULT '[]'::jsonb,
  notes text,
  error text,
  created_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.backtests ENABLE ROW LEVEL SECURITY;
CREATE POLICY "read backtests of published or admin" ON public.backtests FOR SELECT TO public
  USING (public.has_role(auth.uid(), 'admin')
    OR EXISTS (SELECT 1 FROM public.strategies s WHERE s.id = strategy_id AND s.status = 'published'));
CREATE POLICY "admins write backtests" ON public.backtests FOR ALL TO public
  USING (public.has_role(auth.uid(), 'admin')) WITH CHECK (public.has_role(auth.uid(), 'admin'));

-- ALLOCATIONS ---------------------------------------------------------
CREATE TABLE public.allocations (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
  strategy_id uuid NOT NULL REFERENCES public.strategies(id) ON DELETE CASCADE,
  allocated numeric(18,2) NOT NULL,
  cash numeric(18,2) NOT NULL,
  status text NOT NULL DEFAULT 'active',
  autotrade boolean NOT NULL DEFAULT false,
  created_at timestamptz NOT NULL DEFAULT now(),
  updated_at timestamptz NOT NULL DEFAULT now(),
  UNIQUE (user_id, strategy_id)
);


ALTER TABLE public.allocations ENABLE ROW LEVEL SECURITY;
CREATE POLICY "users manage own allocations" ON public.allocations FOR ALL TO public
  USING (auth.uid() = user_id OR public.has_role(auth.uid(), 'admin'))
  WITH CHECK (auth.uid() = user_id);
CREATE TRIGGER allocations_updated_at BEFORE UPDATE ON public.allocations
  FOR EACH ROW EXECUTE PROCEDURE public.update_updated_at_column();

-- AGENT RUNS ----------------------------------------------------------
CREATE TABLE public.agent_runs (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  strategy_id uuid REFERENCES public.strategies(id) ON DELETE CASCADE,
  triggered_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
  kind text NOT NULL DEFAULT 'strategy',
  status text NOT NULL DEFAULT 'running',
  symbols text[] NOT NULL DEFAULT '{}',
  market_snapshot jsonb,
  director_output jsonb,
  quant_output jsonb,
  risk_output jsonb,
  execution_output jsonb,
  summary text,
  duration_ms integer,
  error text,
  created_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.agent_runs ENABLE ROW LEVEL SECURITY;
CREATE POLICY "read agent runs" ON public.agent_runs FOR SELECT TO public
  USING (public.has_role(auth.uid(), 'admin')
    OR triggered_by = auth.uid()
    OR EXISTS (SELECT 1 FROM public.strategies s WHERE s.id = strategy_id AND s.status = 'published'));

-- SIGNALS -------------------------------------------------------------
CREATE TABLE public.signals (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  strategy_id uuid NOT NULL REFERENCES public.strategies(id) ON DELETE CASCADE,
  agent_run_id uuid REFERENCES public.agent_runs(id) ON DELETE SET NULL,
  symbol text NOT NULL,
  side text NOT NULL,
  confidence numeric(4,3) NOT NULL DEFAULT 0.5,
  reference_price numeric(18,4),
  target_price numeric(18,4),
  stop_price numeric(18,4),
  quantity_pct numeric(6,3),
  rationale text,
  risk_notes text,
  status text NOT NULL DEFAULT 'open',
  created_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.signals ENABLE ROW LEVEL SECURITY;
CREATE POLICY "read signals of published or own strategies" ON public.signals FOR SELECT TO public
  USING (public.has_role(auth.uid(), 'admin')
    OR EXISTS (SELECT 1 FROM public.strategies s WHERE s.id = strategy_id AND s.status = 'published')
    OR EXISTS (SELECT 1 FROM public.allocations a WHERE a.strategy_id = signals.strategy_id AND a.user_id = auth.uid()));

-- POSITIONS -----------------------------------------------------------
CREATE TABLE public.positions (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  allocation_id uuid NOT NULL REFERENCES public.allocations(id) ON DELETE CASCADE,
  user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
  symbol text NOT NULL,
  quantity numeric(18,6) NOT NULL DEFAULT 0,
  avg_price numeric(18,4) NOT NULL DEFAULT 0,
  realized_pnl numeric(18,2) NOT NULL DEFAULT 0,
  status text NOT NULL DEFAULT 'open',
  opened_at timestamptz NOT NULL DEFAULT now(),
  closed_at timestamptz,
  updated_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.positions ENABLE ROW LEVEL SECURITY;
CREATE POLICY "users manage own positions" ON public.positions FOR ALL TO public
  USING (auth.uid() = user_id OR public.has_role(auth.uid(), 'admin'))
  WITH CHECK (auth.uid() = user_id);
CREATE TRIGGER positions_updated_at BEFORE UPDATE ON public.positions
  FOR EACH ROW EXECUTE PROCEDURE public.update_updated_at_column();

-- TRADES --------------------------------------------------------------
CREATE TABLE public.trades (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  allocation_id uuid NOT NULL REFERENCES public.allocations(id) ON DELETE CASCADE,
  user_id uuid NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
  signal_id uuid REFERENCES public.signals(id) ON DELETE SET NULL,
  position_id uuid REFERENCES public.positions(id) ON DELETE SET NULL,
  symbol text NOT NULL,
  side text NOT NULL,
  quantity numeric(18,6) NOT NULL,
  price numeric(18,4) NOT NULL,
  notional numeric(18,2) NOT NULL,
  realized_pnl numeric(18,2),
  source text NOT NULL DEFAULT 'manual',
  created_at timestamptz NOT NULL DEFAULT now()
);


ALTER TABLE public.trades ENABLE ROW LEVEL SECURITY;
CREATE POLICY "users read own trades" ON public.trades FOR SELECT TO public
  USING (auth.uid() = user_id OR public.has_role(auth.uid(), 'admin'));
CREATE POLICY "users insert own trades" ON public.trades FOR INSERT TO public
  WITH CHECK (auth.uid() = user_id);

CREATE INDEX signals_strategy_created_idx ON public.signals (strategy_id, created_at DESC);
CREATE INDEX agent_runs_strategy_created_idx ON public.agent_runs (strategy_id, created_at DESC);
CREATE INDEX positions_allocation_idx ON public.positions (allocation_id);
CREATE INDEX trades_user_created_idx ON public.trades (user_id, created_at DESC);

-- 20260903180004_e4fe4cd5-37a8-471b-b0ac-1af4be83ab7a.sql





-- 20260916022047_3ab0d564-5e40-4eb6-9531-7a0d7726527e.sql
ALTER TYPE public.strategy_status ADD VALUE IF NOT EXISTS 'submitted' BEFORE 'testing';
ALTER TYPE public.strategy_status ADD VALUE IF NOT EXISTS 'rejected';

ALTER TABLE public.strategies
  ADD COLUMN IF NOT EXISTS submitted_at timestamp with time zone,
  ADD COLUMN IF NOT EXISTS reviewed_at timestamp with time zone,
  ADD COLUMN IF NOT EXISTS reviewed_by uuid REFERENCES auth.users(id) ON DELETE SET NULL,
  ADD COLUMN IF NOT EXISTS review_notes text;

-- 20260916022106_e62c6cd5-d3b2-47ea-82bc-d506063aec79.sql
CREATE POLICY "authors read own strategies"
ON public.strategies FOR SELECT TO public
USING (created_by = auth.uid());

CREATE POLICY "authors submit strategies"
ON public.strategies FOR INSERT TO public
WITH CHECK (
  created_by = auth.uid()
  AND status IN ('draft'::strategy_status, 'submitted'::strategy_status)
);

CREATE POLICY "authors edit own pending strategies"
ON public.strategies FOR UPDATE TO public
USING (
  created_by = auth.uid()
  AND status IN ('draft'::strategy_status, 'submitted'::strategy_status, 'rejected'::strategy_status)
)
WITH CHECK (
  created_by = auth.uid()
  AND status IN ('draft'::strategy_status, 'submitted'::strategy_status, 'rejected'::strategy_status)
);

CREATE POLICY "authors delete own pending strategies"
ON public.strategies FOR DELETE TO public
USING (
  created_by = auth.uid()
  AND status IN ('draft'::strategy_status, 'submitted'::strategy_status, 'rejected'::strategy_status)
);

-- 20260920055408_86e21c45-7fbe-4683-b115-8356572f8d61.sql
ALTER TABLE public.strategies
  ADD COLUMN IF NOT EXISTS admin_rating smallint CHECK (admin_rating BETWEEN 1 AND 5),
  ADD COLUMN IF NOT EXISTS admin_rating_note text,
  ADD COLUMN IF NOT EXISTS rated_at timestamp with time zone,
  ADD COLUMN IF NOT EXISTS rated_by uuid REFERENCES auth.users(id);

-- 20260930034600_273f72dc-f890-4147-be26-d781cb1d1013.sql
CREATE TABLE public.provider_keys (
  name text PRIMARY KEY,
  value text NOT NULL,
  updated_by uuid,
  updated_at timestamptz NOT NULL DEFAULT now()
);

ALTER TABLE public.provider_keys ENABLE ROW LEVEL SECURITY;


-- Trusted server access (sign-up, admin tools) and RLS that also binds the table owner.
DO $do$ DECLARE t text; BEGIN
  FOR t IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' LOOP
    EXECUTE format('ALTER TABLE public.%I ENABLE ROW LEVEL SECURITY', t);
    EXECUTE format('DROP POLICY IF EXISTS "trusted server" ON public.%I', t);
    EXECUTE format($p$CREATE POLICY "trusted server" ON public.%I USING (current_setting('app.service', true) = 'on') WITH CHECK (current_setting('app.service', true) = 'on')$p$, t);
    -- user_roles stays owner-readable so has_role() never recurses into its own policy.
    IF t <> 'user_roles' THEN
      EXECUTE format('ALTER TABLE public.%I FORCE ROW LEVEL SECURITY', t);
    END IF;
  END LOOP;
END $do$;

-- ===== Starter data =====
-- AutoHedge starter data: published strategies and their real-price backtests.
-- Run after schema-postgres.sql:  psql "$DATABASE_URL" -f seed.sql
SET app.service = 'on';
BEGIN;
SELECT set_config('app.service','on',true);
INSERT INTO public.strategies (id,created_by,name,tagline,description,prompt,universe,timeframe,status,risk_profile,max_position_pct,stop_loss_pct,take_profit_pct,min_confidence,is_dynamic,published_at,created_at,updated_at,submitted_at,reviewed_at,reviewed_by,review_notes,admin_rating,admin_rating_note,rated_at,rated_by) VALUES ('a1111111-1111-4111-8111-000000000001',NULL,'Nasdaq-Filtered Tech Momentum','Tech leaders, bought only while the Nasdaq is in an uptrend. Built for drawdowns under 15%.','Tech leaders, bought only while the Nasdaq is in an uptrend. Built for drawdowns under 15%.','Objective: Tech leaders, bought only while the Nasdaq is in an uptrend. Built for drawdowns under 15%.

Entry (all at the close): 3-month change above +10%, close above the 20-day average, RSI(14) above 50.
Market filter: new trades only while QQQ closes above its 200-day average; open positions stay managed by their stops.
Ranking: when several names qualify on the same day, the strongest 3-month trend is bought first. Max 6 positions.
Sizing: up to 15% of equity per position, 3% risk budget per idea.
Exit: 2.5x ATR(14) initial stop that trails under the running peak. No profit target, no time exit.

```rules
{
  "interpretation": "Market-filtered relative-strength trend following with a 2.5x ATR trailing stop.",
  "entry_rules": [
    {
      "indicator": "momentum60",
      "operator": "above",
      "value": 10
    },
    {
      "indicator": "price_vs_sma20",
      "operator": "above",
      "value": 0
    },
    {
      "indicator": "rsi14",
      "operator": "above",
      "value": 50
    }
  ],
  "exit_rules": [],
  "hold_bars_max": 0,
  "trail_atr_multiple": 2.5,
  "stop_atr_multiple": 2.5,
  "confidence_basis": "Strength of 3-month relative strength at entry.",
  "adaptive": {
    "enabled": false,
    "breadth_min_pct": 50,
    "risk_off_trail_multiple": 2,
    "volatility_scaling": true,
    "threshold_flex_pct": 20
  },
  "regime_symbol": "QQQ",
  "regime_sma": 200,
  "rank_by_strength": true
}
```',ARRAY['NVDA','AVGO','MU','META','ANET','NFLX','PLTR','ORCL','NOW','AMD']::text[],'1Day','published','balanced',15.0,6.0,20.0,0.6,true,'2026-10-02T03:00:00+00:00','2026-10-05T22:24:54.874955+00:00','2026-10-05T22:33:23.874374+00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) ON CONFLICT (id) DO NOTHING;
INSERT INTO public.strategies (id,created_by,name,tagline,description,prompt,universe,timeframe,status,risk_profile,max_position_pct,stop_loss_pct,take_profit_pct,min_confidence,is_dynamic,published_at,created_at,updated_at,submitted_at,reviewed_at,reviewed_by,review_notes,admin_rating,admin_rating_note,rated_at,rated_by) VALUES ('a1111111-1111-4111-8111-000000000002',NULL,'Market-Filtered Quality Leaders','Ten blue-chip leaders across sectors, bought on strength while the Nasdaq trend is up.','Ten blue-chip leaders across sectors, bought on strength while the Nasdaq trend is up.','Objective: Ten blue-chip leaders across sectors, bought on strength while the Nasdaq trend is up.

Entry (all at the close): 3-month change above +10%, close above the 20-day average, RSI(14) above 50.
Market filter: new trades only while QQQ closes above its 200-day average; open positions stay managed by their stops.
Ranking: when several names qualify on the same day, the strongest 3-month trend is bought first. Max 6 positions.
Sizing: up to 25% of equity per position, 3% risk budget per idea.
Exit: 2.5x ATR(14) initial stop that trails under the running peak. No profit target, no time exit.

```rules
{
  "interpretation": "Market-filtered relative-strength trend following with a 2.5x ATR trailing stop.",
  "entry_rules": [
    {
      "indicator": "momentum60",
      "operator": "above",
      "value": 10
    },
    {
      "indicator": "price_vs_sma20",
      "operator": "above",
      "value": 0
    },
    {
      "indicator": "rsi14",
      "operator": "above",
      "value": 50
    }
  ],
  "exit_rules": [],
  "hold_bars_max": 0,
  "trail_atr_multiple": 2.5,
  "stop_atr_multiple": 2.5,
  "confidence_basis": "Strength of 3-month relative strength at entry.",
  "adaptive": {
    "enabled": false,
    "breadth_min_pct": 50,
    "risk_off_trail_multiple": 2,
    "volatility_scaling": true,
    "threshold_flex_pct": 20
  },
  "regime_symbol": "QQQ",
  "regime_sma": 200,
  "rank_by_strength": true
}
```',ARRAY['NVDA','AVGO','META','MSFT','LLY','COST','JPM','GS','CAT','XOM']::text[],'1Day','published','conservative',25.0,6.0,20.0,0.6,true,'2026-10-02T03:00:00+00:00','2026-10-05T22:24:55.090717+00:00','2026-10-05T22:33:23.874374+00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) ON CONFLICT (id) DO NOTHING;
INSERT INTO public.strategies (id,created_by,name,tagline,description,prompt,universe,timeframe,status,risk_profile,max_position_pct,stop_loss_pct,take_profit_pct,min_confidence,is_dynamic,published_at,created_at,updated_at,submitted_at,reviewed_at,reviewed_by,review_notes,admin_rating,admin_rating_note,rated_at,rated_by) VALUES ('1c34dcdf-8b75-4f58-baab-81772aaea62a',NULL,'Steady Quality Trend','Ten high-quality large caps, bought when their 3-month trend is up, small positions for a smooth ride.','Ten high-quality large caps, bought when their 3-month trend is up, small positions for a smooth ride.','Ten high-quality large caps, bought when their 3-month trend is up, small positions for a smooth ride.

Entry (at the close): 3-month change above +5%, close above the 50-day average, RSI(14) above 50. Strongest trend bought first.
Sizing: up to 10% of equity per position.
Exit: 3x ATR(14) stop that trails under the running peak. No profit target, no time exit.

```rules
{
  "interpretation": "Ten high-quality large caps, bought when their 3-month trend is up, small positions for a smooth ride.",
  "entry_rules": [
    {
      "indicator": "momentum60",
      "operator": "above",
      "value": 5
    },
    {
      "indicator": "price_vs_sma50",
      "operator": "above",
      "value": 0
    },
    {
      "indicator": "rsi14",
      "operator": "above",
      "value": 50
    }
  ],
  "exit_rules": [],
  "hold_bars_max": 0,
  "trail_atr_multiple": 3,
  "stop_atr_multiple": 3,
  "confidence_basis": "Rule agreement and 3-month trend strength.",
  "adaptive": {
    "enabled": false,
    "breadth_min_pct": 50,
    "risk_off_trail_multiple": 2,
    "volatility_scaling": true,
    "threshold_flex_pct": 20
  },
  "regime_symbol": null,
  "regime_sma": 200,
  "rank_by_strength": true
}
```',ARRAY['MSFT','AAPL','GOOGL','V','MA','COST','JPM','UNH','LLY','HD']::text[],'1Day','published','conservative',10.0,6.0,20.0,0.5,false,'2026-10-06T03:59:22.489+00:00','2026-10-06T03:59:19.825399+00:00','2026-10-06T03:59:22.550051+00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) ON CONFLICT (id) DO NOTHING;
INSERT INTO public.strategies (id,created_by,name,tagline,description,prompt,universe,timeframe,status,risk_profile,max_position_pct,stop_loss_pct,take_profit_pct,min_confidence,is_dynamic,published_at,created_at,updated_at,submitted_at,reviewed_at,reviewed_by,review_notes,admin_rating,admin_rating_note,rated_at,rated_by) VALUES ('a310f750-7afd-4996-adb1-f9e56a4ea88e',NULL,'Quality Trend Core','Same quality trend rules with larger positions — higher return, worst drop close to the 15% limit.','Same quality trend rules with larger positions — higher return, worst drop close to the 15% limit.','Same quality trend rules with larger positions — higher return, worst drop close to the 15% limit.

Entry (at the close): 3-month change above +5%, close above the 50-day average, RSI(14) above 50. Strongest trend bought first.
Sizing: up to 15% of equity per position.
Exit: 3x ATR(14) trailing stop.

```rules
{
  "interpretation": "Same quality trend rules with larger positions — higher return, worst drop close to the 15% limit.",
  "entry_rules": [
    {
      "indicator": "momentum60",
      "operator": "above",
      "value": 5
    },
    {
      "indicator": "price_vs_sma50",
      "operator": "above",
      "value": 0
    },
    {
      "indicator": "rsi14",
      "operator": "above",
      "value": 50
    }
  ],
  "exit_rules": [],
  "hold_bars_max": 0,
  "trail_atr_multiple": 3,
  "stop_atr_multiple": 3,
  "confidence_basis": "Rule agreement and 3-month trend strength.",
  "adaptive": {
    "enabled": false,
    "breadth_min_pct": 50,
    "risk_off_trail_multiple": 2,
    "volatility_scaling": true,
    "threshold_flex_pct": 20
  },
  "regime_symbol": null,
  "regime_sma": 200,
  "rank_by_strength": true
}
```',ARRAY['MSFT','AAPL','GOOGL','V','MA','COST','JPM','UNH','LLY','HD']::text[],'1Day','published','balanced',15.0,6.0,20.0,0.5,false,'2026-10-06T03:59:24.138+00:00','2026-10-06T03:59:22.674816+00:00','2026-10-06T03:59:24.198785+00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) ON CONFLICT (id) DO NOTHING;
INSERT INTO public.strategies (id,created_by,name,tagline,description,prompt,universe,timeframe,status,risk_profile,max_position_pct,stop_loss_pct,take_profit_pct,min_confidence,is_dynamic,published_at,created_at,updated_at,submitted_at,reviewed_at,reviewed_by,review_notes,admin_rating,admin_rating_note,rated_at,rated_by) VALUES ('2ba53985-f9b0-4575-924a-ee074b9eeb12',NULL,'Defensive Dip Buyer','Defensive blue chips bought on short dips inside a long-term uptrend, only while the S&P 500 is above its 200-day average.','Defensive blue chips bought on short dips inside a long-term uptrend, only while the S&P 500 is above its 200-day average.','Defensive blue chips bought on short dips inside a long-term uptrend, only while the S&P 500 is above its 200-day average.

Entry (at the close): close above the 200-day average, RSI(14) below 45, 3-month change above 0%.
Market filter: new trades only while SPY closes above its 200-day average.
Sizing: up to 20% of equity per position.
Exit: 3x ATR(14) trailing stop.

```rules
{
  "interpretation": "Defensive blue chips bought on short dips inside a long-term uptrend, only while the S&P 500 is above its 200-day average.",
  "entry_rules": [
    {
      "indicator": "price_vs_sma200",
      "operator": "above",
      "value": 0
    },
    {
      "indicator": "rsi14",
      "operator": "below",
      "value": 45
    },
    {
      "indicator": "momentum60",
      "operator": "above",
      "value": 0
    }
  ],
  "exit_rules": [],
  "hold_bars_max": 0,
  "trail_atr_multiple": 3,
  "stop_atr_multiple": 3,
  "confidence_basis": "Rule agreement and 3-month trend strength.",
  "adaptive": {
    "enabled": false,
    "breadth_min_pct": 50,
    "risk_off_trail_multiple": 2,
    "volatility_scaling": true,
    "threshold_flex_pct": 20
  },
  "regime_symbol": "SPY",
  "regime_sma": 200,
  "rank_by_strength": true
}
```',ARRAY['KO','PG','JNJ','WMT','COST','PEP','MCD','V','MSFT','BRK.B']::text[],'1Day','published','conservative',20.0,6.0,20.0,0.5,true,'2026-10-06T03:59:26.602+00:00','2026-10-06T03:59:24.320266+00:00','2026-10-06T03:59:26.664131+00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL) ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('b1317312-7648-420d-ae5b-11b8ee4be8b9','1c34dcdf-8b75-4f58-baab-81772aaea62a',NULL,'2025-10-01','2026-10-01',100000.0,'complete',5.989,45.16,-3.874,1.038,31,'[{"date": "2025-10-01", "equity": 100000}, {"date": "2025-10-02", "equity": 99961.19}, {"date": "2025-10-03", "equity": 100424.58}, {"date": "2025-10-06", "equity": 100599.28}, {"date": "2025-10-07", "equity": 100417.68}, {"date": "2025-10-08", "equity": 100525.58}, {"date": "2025-10-09", "equity": 100298.26}, {"date": "2025-10-13", "equity": 99488.49}, {"date": "2025-10-14", "equity": 99346.7}, {"date": "2025-10-15", "equity": 99905.82}, {"date": "2025-10-16", "equity": 99395.64}, {"date": "2025-10-17", "equity": 99500.53}, {"date": "2025-10-20", "equity": 100457.67}, {"date": "2025-10-21", "equity": 100036.8}, {"date": "2025-10-23", "equity": 100056.39}, {"date": "2025-10-24", "equity": 100605.63}, {"date": "2025-10-27", "equity": 101417.85}, {"date": "2025-10-28", "equity": 101529.95}, {"date": "2025-10-29", "equity": 101409.81}, {"date": "2025-10-30", "equity": 101498.44}, {"date": "2025-10-31", "equity": 101553.15}, {"date": "2025-11-04", "equity": 101739.58}, {"date": "2025-11-05", "equity": 102258.55}, {"date": "2025-11-06", "equity": 102423.8}, {"date": "2025-11-07", "equity": 102033.21}, {"date": "2025-11-10", "equity": 103008.89}, {"date": "2025-11-11", "equity": 103464.09}, {"date": "2025-11-12", "equity": 103639.86}, {"date": "2025-11-14", "equity": 102814.61}, {"date": "2025-11-17", "equity": 102843.42}, {"date": "2025-11-18", "equity": 102903.63}, {"date": "2025-11-19", "equity": 103460.89}, {"date": "2025-11-20", "equity": 103196.65}, {"date": "2025-11-21", "equity": 103944.4}, {"date": "2025-11-24", "equity": 104923.86}, {"date": "2025-11-26", "equity": 105420.98}, {"date": "2025-11-28", "equity": 105166.45}, {"date": "2025-12-01", "equity": 104973.66}, {"date": "2025-12-02", "equity": 104989.09}, {"date": "2025-12-03", "equity": 104942.63}, {"date": "2025-12-04", "equity": 104540.65}, {"date": "2025-12-05", "equity": 104584.93}, {"date": "2025-12-09", "equity": 103967.3}, {"date": "2025-12-10", "equity": 104409.75}, {"date": "2025-12-11", "equity": 104285.41}, {"date": "2025-12-12", "equity": 104199.83}, {"date": "2025-12-15", "equity": 104041.53}, {"date": "2025-12-16", "equity": 103861}, {"date": "2025-12-17", "equity": 103364.76}, {"date": "2025-12-19", "equity": 103422.44}, {"date": "2025-12-22", "equity": 103639.73}, {"date": "2025-12-23", "equity": 103669.21}, {"date": "2025-12-24", "equity": 103800.11}, {"date": "2025-12-26", "equity": 103779.15}, {"date": "2025-12-29", "equity": 103678.96}, {"date": "2025-12-31", "equity": 103604.79}, {"date": "2026-01-02", "equity": 103740.51}, {"date": "2026-01-05", "equity": 103669.86}, {"date": "2026-01-06", "equity": 103858.53}, {"date": "2026-01-07", "equity": 104281.54}, {"date": "2026-01-08", "equity": 104262.27}, {"date": "2026-01-09", "equity": 104147.66}, {"date": "2026-01-13", "equity": 103987.45}, {"date": "2026-01-14", "equity": 103946.67}, {"date": "2026-01-15", "equity": 103485.89}, {"date": "2026-01-16", "equity": 103403.43}, {"date": "2026-01-20", "equity": 103155.12}, {"date": "2026-01-21", "equity": 103352.9}, {"date": "2026-01-22", "equity": 103419.24}, {"date": "2026-01-26", "equity": 103236.5}, {"date": "2026-01-27", "equity": 103006.62}, {"date": "2026-01-28", "equity": 102843.36}, {"date": "2026-01-29", "equity": 102840.74}, {"date": "2026-01-30", "equity": 102875.86}, {"date": "2026-02-02", "equity": 103313.39}, {"date": "2026-02-03", "equity": 102920.37}, {"date": "2026-02-05", "equity": 102827.78}, {"date": "2026-02-06", "equity": 103031.32}, {"date": "2026-02-09", "equity": 102829.5}, {"date": "2026-02-10", "equity": 102458.96}, {"date": "2026-02-11", "equity": 102450.35}, {"date": "2026-02-12", "equity": 102815.23}, {"date": "2026-02-13", "equity": 103022.85}, {"date": "2026-02-18", "equity": 102491.5}, {"date": "2026-02-19", "equity": 102339.19}, {"date": "2026-02-20", "equity": 102269.37}, {"date": "2026-02-23", "equity": 102602.44}, {"date": "2026-02-24", "equity": 102732.31}, {"date": "2026-02-25", "equity": 102387.12}, {"date": "2026-02-26", "equity": 102241.53}, {"date": "2026-03-02", "equity": 102238.27}, {"date": "2026-03-03", "equity": 102093.17}, {"date": "2026-03-04", "equity": 102138.86}, {"date": "2026-03-05", "equity": 101768.01}, {"date": "2026-03-06", "equity": 101899.93}, {"date": "2026-03-09", "equity": 101952.73}, {"date": "2026-03-10", "equity": 101892.17}, {"date": "2026-03-12", "equity": 101940.41}, {"date": "2026-03-13", "equity": 101979.61}, {"date": "2026-03-16", "equity": 101928.81}, {"date": "2026-03-17", "equity": 101884.41}, {"date": "2026-03-18", "equity": 101753.61}, {"date": "2026-03-19", "equity": 101712.33}, {"date": "2026-03-20", "equity": 101692.97}, {"date": "2026-03-24", "equity": 101640.89}, {"date": "2026-03-25", "equity": 101640.89}, {"date": "2026-03-26", "equity": 101640.89}, {"date": "2026-03-27", "equity": 101640.89}, {"date": "2026-03-30", "equity": 101640.89}, {"date": "2026-03-31", "equity": 101640.89}, {"date": "2026-04-02", "equity": 101807.21}, {"date": "2026-04-06", "equity": 101839.07}, {"date": "2026-04-07", "equity": 101792.18}, {"date": "2026-04-08", "equity": 101941.49}, {"date": "2026-04-09", "equity": 101960.03}, {"date": "2026-04-10", "equity": 101657}, {"date": "2026-04-13", "equity": 101499.05}, {"date": "2026-04-15", "equity": 101499.05}, {"date": "2026-04-16", "equity": 101499.05}, {"date": "2026-04-17", "equity": 101725.43}, {"date": "2026-04-20", "equity": 101819.48}, {"date": "2026-04-21", "equity": 101486.36}, {"date": "2026-04-22", "equity": 101715.26}, {"date": "2026-04-23", "equity": 101694.05}, {"date": "2026-04-27", "equity": 101502.86}, {"date": "2026-04-28", "equity": 101937.47}, {"date": "2026-04-29", "equity": 101968.46}, {"date": "2026-04-30", "equity": 102102.27}, {"date": "2026-05-01", "equity": 102346.72}, {"date": "2026-05-04", "equity": 102105.58}, {"date": "2026-05-05", "equity": 102282.42}, {"date": "2026-05-07", "equity": 102896.31}, {"date": "2026-05-08", "equity": 103210.34}, {"date": "2026-05-11", "equity": 102926.11}, {"date": "2026-05-12", "equity": 103199.07}, {"date": "2026-05-13", "equity": 103791.72}, {"date": "2026-05-14", "equity": 103765.67}, {"date": "2026-05-15", "equity": 103814.65}, {"date": "2026-05-19", "equity": 103718.53}, {"date": "2026-05-20", "equity": 103576.54}, {"date": "2026-05-21", "equity": 103415.27}, {"date": "2026-05-22", "equity": 103343.86}, {"date": "2026-05-26", "equity": 103047.62}, {"date": "2026-05-27", "equity": 103287.95}, {"date": "2026-05-28", "equity": 103878.89}, {"date": "2026-06-01", "equity": 103504.75}, {"date": "2026-06-02", "equity": 102714.84}, {"date": "2026-06-03", "equity": 102296.58}, {"date": "2026-06-04", "equity": 103224.21}, {"date": "2026-06-05", "equity": 103062.35}, {"date": "2026-06-08", "equity": 103158.59}, {"date": "2026-06-09", "equity": 102951.5}, {"date": "2026-06-11", "equity": 102906.77}, {"date": "2026-06-12", "equity": 102982.47}, {"date": "2026-06-15", "equity": 103065.75}, {"date": "2026-06-16", "equity": 103248.65}, {"date": "2026-06-17", "equity": 102674.72}, {"date": "2026-06-18", "equity": 102459.09}, {"date": "2026-06-22", "equity": 102645.22}, {"date": "2026-06-24", "equity": 103343.88}, {"date": "2026-06-25", "equity": 103735.5}, {"date": "2026-06-26", "equity": 104704.81}, {"date": "2026-06-29", "equity": 104971.68}, {"date": "2026-06-30", "equity": 104623.49}, {"date": "2026-07-01", "equity": 105268.9}, {"date": "2026-07-06", "equity": 106042.25}, {"date": "2026-07-07", "equity": 106267.69}, {"date": "2026-07-08", "equity": 105533.1}, {"date": "2026-07-09", "equity": 106015.62}, {"date": "2026-07-10", "equity": 105737.6}, {"date": "2026-07-13", "equity": 105939}, {"date": "2026-07-14", "equity": 105728.59}, {"date": "2026-07-16", "equity": 106922.83}, {"date": "2026-07-17", "equity": 106622.98}, {"date": "2026-07-20", "equity": 105863.62}, {"date": "2026-07-21", "equity": 106415.81}, {"date": "2026-07-22", "equity": 106043.79}, {"date": "2026-07-23", "equity": 105819.01}, {"date": "2026-07-24", "equity": 106581.6}, {"date": "2026-07-28", "equity": 108055.8}, {"date": "2026-07-29", "equity": 107393.36}, {"date": "2026-07-30", "equity": 107123.14}, {"date": "2026-07-31", "equity": 105997.76}, {"date": "2026-08-03", "equity": 106255.46}, {"date": "2026-08-04", "equity": 106617.69}, {"date": "2026-08-05", "equity": 106776.64}, {"date": "2026-08-07", "equity": 106608.84}, {"date": "2026-08-10", "equity": 106702.25}, {"date": "2026-08-11", "equity": 106658.48}, {"date": "2026-08-12", "equity": 106172.44}, {"date": "2026-08-13", "equity": 106348.56}, {"date": "2026-08-14", "equity": 106023.09}, {"date": "2026-08-17", "equity": 105433.93}, {"date": "2026-08-19", "equity": 106693.52}, {"date": "2026-08-20", "equity": 105964.16}, {"date": "2026-08-21", "equity": 106359.48}, {"date": "2026-08-24", "equity": 107186.67}, {"date": "2026-08-25", "equity": 107220.69}, {"date": "2026-08-26", "equity": 106876.53}, {"date": "2026-08-27", "equity": 106488.59}, {"date": "2026-08-31", "equity": 106521.84}, {"date": "2026-09-01", "equity": 106051.43}, {"date": "2026-09-02", "equity": 106261.29}, {"date": "2026-09-03", "equity": 106767.02}, {"date": "2026-09-04", "equity": 106009.85}, {"date": "2026-09-08", "equity": 105343.85}, {"date": "2026-09-09", "equity": 105269.41}, {"date": "2026-09-11", "equity": 105938.76}, {"date": "2026-09-14", "equity": 106126.92}, {"date": "2026-09-15", "equity": 105904}, {"date": "2026-09-16", "equity": 105670.96}, {"date": "2026-09-17", "equity": 105917.53}, {"date": "2026-09-18", "equity": 105720.29}, {"date": "2026-09-21", "equity": 105987.92}, {"date": "2026-09-23", "equity": 105909}, {"date": "2026-09-24", "equity": 105818.53}, {"date": "2026-09-25", "equity": 106347.28}, {"date": "2026-09-28", "equity": 106133.84}, {"date": "2026-09-29", "equity": 105886.46}, {"date": "2026-09-30", "equity": 106068.26}, {"date": "2026-10-01", "equity": 105989.28}]'::jsonb,'[{"pnl": -430.65, "symbol": "JPM", "exitDate": "2025-10-22", "quantity": 29, "entryDate": "2025-10-01", "exitPrice": 289.98, "returnPct": -4.87, "entryPrice": 304.83, "exitReason": "trailing stop"}, {"pnl": -243.04, "symbol": "UNH", "exitDate": "2025-10-30", "quantity": 28, "entryDate": "2025-10-02", "exitPrice": 335.77, "returnPct": -2.52, "entryPrice": 344.45, "exitReason": "trailing stop"}, {"pnl": -217.6, "symbol": "MSFT", "exitDate": "2025-11-04", "quantity": 16, "entryDate": "2025-10-06", "exitPrice": 510.51, "returnPct": -2.59, "entryPrice": 524.11, "exitReason": "trailing stop"}, {"pnl": -252.28, "symbol": "JPM", "exitDate": "2025-11-17", "quantity": 28, "entryDate": "2025-10-30", "exitPrice": 296.26, "returnPct": -2.95, "entryPrice": 305.27, "exitReason": "trailing stop"}, {"pnl": 1885.7, "symbol": "LLY", "exitDate": "2025-12-04", "quantity": 10, "entryDate": "2025-10-01", "exitPrice": 1009.1, "returnPct": 22.98, "entryPrice": 820.53, "exitReason": "trailing stop"}, {"pnl": 631.56, "symbol": "AAPL", "exitDate": "2025-12-17", "quantity": 38, "entryDate": "2025-10-01", "exitPrice": 271.11, "returnPct": 6.53, "entryPrice": 254.49, "exitReason": "trailing stop"}, {"pnl": 2022.15, "symbol": "GOOGL", "exitDate": "2025-12-17", "quantity": 39, "entryDate": "2025-10-01", "exitPrice": 296.07, "returnPct": 21.23, "entryPrice": 244.22, "exitReason": "trailing stop"}, {"pnl": -105.84, "symbol": "JPM", "exitDate": "2026-01-13", "quantity": 28, "entryDate": "2025-12-04", "exitPrice": 307.91, "returnPct": -1.21, "entryPrice": 311.69, "exitReason": "trailing stop"}, {"pnl": -342.27, "symbol": "LLY", "exitDate": "2026-01-15", "quantity": 9, "entryDate": "2025-12-19", "exitPrice": 1027.64, "returnPct": -3.57, "entryPrice": 1065.67, "exitReason": "trailing stop"}, {"pnl": 103.54, "symbol": "GOOGL", "exitDate": "2026-02-10", "quantity": 31, "entryDate": "2026-01-02", "exitPrice": 317.97, "returnPct": 1.06, "entryPrice": 314.63, "exitReason": "trailing stop"}, {"pnl": -706.14, "symbol": "LLY", "exitDate": "2026-03-03", "quantity": 9, "entryDate": "2026-01-22", "exitPrice": 1003.92, "returnPct": -7.25, "entryPrice": 1082.38, "exitReason": "trailing stop"}, {"pnl": -575.92, "symbol": "HD", "exitDate": "2026-03-05", "quantity": 23, "entryDate": "2026-02-04", "exitPrice": 353.92, "returnPct": -6.61, "entryPrice": 378.96, "exitReason": "trailing stop"}, {"pnl": -128.32, "symbol": "COST", "exitDate": "2026-03-23", "quantity": 8, "entryDate": "2026-01-23", "exitPrice": 962.9, "returnPct": -1.64, "entryPrice": 978.94, "exitReason": "trailing stop"}, {"pnl": -141.84, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 9, "entryDate": "2026-03-31", "exitPrice": 977.65, "returnPct": -1.59, "entryPrice": 993.41, "exitReason": "trailing stop"}, {"pnl": -447.46, "symbol": "JPM", "exitDate": "2026-05-11", "quantity": 26, "entryDate": "2026-04-20", "exitPrice": 298.47, "returnPct": -5.45, "entryPrice": 315.68, "exitReason": "trailing stop"}, {"pnl": -171.28, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 8, "entryDate": "2026-05-15", "exitPrice": 1026.22, "returnPct": -2.04, "entryPrice": 1047.63, "exitReason": "trailing stop"}, {"pnl": -578, "symbol": "GOOGL", "exitDate": "2026-06-02", "quantity": 25, "entryDate": "2026-04-30", "exitPrice": 361.39, "returnPct": -6.01, "entryPrice": 384.51, "exitReason": "trailing stop"}, {"pnl": -462.78, "symbol": "V", "exitDate": "2026-06-03", "quantity": 27, "entryDate": "2026-05-20", "exitPrice": 313.05, "returnPct": -5.19, "entryPrice": 330.19, "exitReason": "trailing stop"}, {"pnl": 77.6, "symbol": "MSFT", "exitDate": "2026-06-05", "quantity": 20, "entryDate": "2026-05-04", "exitPrice": 415.85, "returnPct": 0.94, "entryPrice": 411.97, "exitReason": "trailing stop"}, {"pnl": 899.25, "symbol": "AAPL", "exitDate": "2026-06-09", "quantity": 33, "entryDate": "2026-04-16", "exitPrice": 290.11, "returnPct": 10.37, "entryPrice": 262.86, "exitReason": "trailing stop"}, {"pnl": -104.52, "symbol": "HD", "exitDate": "2026-07-20", "quantity": 26, "entryDate": "2026-06-16", "exitPrice": 330.61, "returnPct": -1.2, "entryPrice": 334.63, "exitReason": "trailing stop"}, {"pnl": 485.86, "symbol": "AAPL", "exitDate": "2026-07-31", "quantity": 34, "entryDate": "2026-07-01", "exitPrice": 308.46, "returnPct": 4.86, "entryPrice": 294.17, "exitReason": "trailing stop"}, {"pnl": 295.2, "symbol": "LLY", "exitDate": "2026-08-03", "quantity": 8, "entryDate": "2026-05-27", "exitPrice": 1119.58, "returnPct": 3.41, "entryPrice": 1082.68, "exitReason": "trailing stop"}, {"pnl": 1391.04, "symbol": "UNH", "exitDate": "2026-08-11", "quantity": 28, "entryDate": "2026-04-23", "exitPrice": 400.03, "returnPct": 14.18, "entryPrice": 350.35, "exitReason": "trailing stop"}, {"pnl": -297.96, "symbol": "HD", "exitDate": "2026-08-27", "quantity": 26, "entryDate": "2026-08-03", "exitPrice": 326.18, "returnPct": -3.39, "entryPrice": 337.64, "exitReason": "trailing stop"}, {"pnl": -298.64, "symbol": "LLY", "exitDate": "2026-08-28", "quantity": 8, "entryDate": "2026-08-11", "exitPrice": 1173.85, "returnPct": -3.08, "entryPrice": 1211.18, "exitReason": "trailing stop"}, {"pnl": 374.32, "symbol": "MA", "exitDate": "2026-09-08", "quantity": 16, "entryDate": "2026-07-20", "exitPrice": 570.95, "returnPct": 4.27, "entryPrice": 547.55, "exitReason": "trailing stop"}, {"pnl": 1179.87, "symbol": "JPM", "exitDate": "2026-09-14", "quantity": 29, "entryDate": "2026-06-04", "exitPrice": 350.19, "returnPct": 13.15, "entryPrice": 309.5, "exitReason": "trailing stop"}, {"pnl": 981.12, "symbol": "V", "exitDate": "2026-09-18", "quantity": 28, "entryDate": "2026-06-16", "exitPrice": 367.63, "returnPct": 10.54, "entryPrice": 332.59, "exitReason": "trailing stop"}, {"pnl": 1026.48, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 21, "entryDate": "2026-07-31", "exitPrice": 512.71, "returnPct": 10.54, "entryPrice": 463.83, "exitReason": "end of test"}, {"pnl": 140.13, "symbol": "AAPL", "exitDate": "2026-10-01", "quantity": 27, "entryDate": "2026-09-01", "exitPrice": 330.44, "returnPct": 1.6, "entryPrice": 325.25, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:21.556642+00:00') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('28d17583-8906-43c0-bed7-cc2340913d6a','1c34dcdf-8b75-4f58-baab-81772aaea62a',NULL,'2021-06-01','2026-10-01',100000.0,'complete',38.822,46.7,-10.06,1.009,182,'[{"date": "2021-06-01", "equity": 100000}, {"date": "2021-06-09", "equity": 100123.82}, {"date": "2021-06-17", "equity": 100045.63}, {"date": "2021-06-25", "equity": 101052.11}, {"date": "2021-07-06", "equity": 102791.02}, {"date": "2021-07-14", "equity": 104180.68}, {"date": "2021-07-22", "equity": 104334.36}, {"date": "2021-07-30", "equity": 105380.02}, {"date": "2021-08-09", "equity": 106584.05}, {"date": "2021-08-17", "equity": 107354.98}, {"date": "2021-08-25", "equity": 107519.39}, {"date": "2021-09-03", "equity": 107919.28}, {"date": "2021-09-14", "equity": 106850.75}, {"date": "2021-09-22", "equity": 106172.05}, {"date": "2021-09-30", "equity": 105176.35}, {"date": "2021-10-08", "equity": 105114.26}, {"date": "2021-10-18", "equity": 106240.03}, {"date": "2021-10-26", "equity": 107615.18}, {"date": "2021-11-03", "equity": 109191.64}, {"date": "2021-11-11", "equity": 109092.21}, {"date": "2021-11-19", "equity": 110828.1}, {"date": "2021-12-01", "equity": 109754.62}, {"date": "2021-12-09", "equity": 110915.32}, {"date": "2021-12-17", "equity": 110253.37}, {"date": "2021-12-28", "equity": 112367.66}, {"date": "2022-01-05", "equity": 109531.13}, {"date": "2022-01-13", "equity": 108030.02}, {"date": "2022-01-24", "equity": 106813.32}, {"date": "2022-02-01", "equity": 107190.18}, {"date": "2022-02-09", "equity": 107320.46}, {"date": "2022-02-17", "equity": 105947.92}, {"date": "2022-02-28", "equity": 104882.18}, {"date": "2022-03-09", "equity": 104789.78}, {"date": "2022-03-17", "equity": 105961.58}, {"date": "2022-03-25", "equity": 106200.98}, {"date": "2022-04-04", "equity": 106224.08}, {"date": "2022-04-12", "equity": 107326.48}, {"date": "2022-04-21", "equity": 106909.81}, {"date": "2022-04-29", "equity": 106231.65}, {"date": "2022-05-09", "equity": 105241.93}, {"date": "2022-05-17", "equity": 105700.93}, {"date": "2022-05-25", "equity": 105895.69}, {"date": "2022-06-06", "equity": 105719.01}, {"date": "2022-06-14", "equity": 103918.58}, {"date": "2022-06-23", "equity": 103918.58}, {"date": "2022-07-01", "equity": 104251.88}, {"date": "2022-07-12", "equity": 104230.88}, {"date": "2022-07-20", "equity": 104183.18}, {"date": "2022-07-28", "equity": 104434.63}, {"date": "2022-08-05", "equity": 103749.89}, {"date": "2022-08-15", "equity": 104815.33}, {"date": "2022-08-23", "equity": 102916.78}, {"date": "2022-08-31", "equity": 102176.47}, {"date": "2022-09-12", "equity": 102274.43}, {"date": "2022-09-20", "equity": 101936.31}, {"date": "2022-09-28", "equity": 101689.04}, {"date": "2022-10-06", "equity": 101689.04}, {"date": "2022-10-14", "equity": 101689.04}, {"date": "2022-10-24", "equity": 101696.15}, {"date": "2022-11-01", "equity": 102231.47}, {"date": "2022-11-09", "equity": 102596.4}, {"date": "2022-11-17", "equity": 102767.58}, {"date": "2022-11-28", "equity": 102947.65}, {"date": "2022-12-07", "equity": 102852.09}, {"date": "2022-12-15", "equity": 102442.5}, {"date": "2022-12-23", "equity": 102217.1}, {"date": "2023-01-04", "equity": 102571.62}, {"date": "2023-01-12", "equity": 103725.32}, {"date": "2023-01-23", "equity": 103002.87}, {"date": "2023-01-31", "equity": 103423.05}, {"date": "2023-02-08", "equity": 104232.61}, {"date": "2023-02-16", "equity": 103222.25}, {"date": "2023-02-27", "equity": 102401.38}, {"date": "2023-03-07", "equity": 102020.53}, {"date": "2023-03-16", "equity": 102401.31}, {"date": "2023-03-24", "equity": 103252.57}, {"date": "2023-04-03", "equity": 103880.17}, {"date": "2023-04-12", "equity": 103387.36}, {"date": "2023-04-20", "equity": 103990.12}, {"date": "2023-04-28", "equity": 105415.44}, {"date": "2023-05-08", "equity": 106275.6}, {"date": "2023-05-16", "equity": 107433.9}, {"date": "2023-05-24", "equity": 106792.03}, {"date": "2023-06-02", "equity": 108772.53}, {"date": "2023-06-13", "equity": 108925.73}, {"date": "2023-06-22", "equity": 108862.29}, {"date": "2023-06-30", "equity": 109901.28}, {"date": "2023-07-11", "equity": 108734.5}, {"date": "2023-07-19", "equity": 111001.7}, {"date": "2023-07-27", "equity": 110619.43}, {"date": "2023-08-04", "equity": 109362.6}, {"date": "2023-08-14", "equity": 111650.05}, {"date": "2023-08-22", "equity": 111156.64}, {"date": "2023-08-30", "equity": 112461.38}, {"date": "2023-09-08", "equity": 112831.83}, {"date": "2023-09-19", "equity": 112530.64}, {"date": "2023-09-27", "equity": 110858.55}, {"date": "2023-10-05", "equity": 110715.07}, {"date": "2023-10-13", "equity": 111562.55}, {"date": "2023-10-23", "equity": 110353.18}, {"date": "2023-10-31", "equity": 109589.69}, {"date": "2023-11-08", "equity": 110064.46}, {"date": "2023-11-16", "equity": 110190.74}, {"date": "2023-11-27", "equity": 110634.56}, {"date": "2023-12-05", "equity": 111216.19}, {"date": "2023-12-14", "equity": 111765.25}, {"date": "2023-12-22", "equity": 112345.68}, {"date": "2024-01-03", "equity": 111975.52}, {"date": "2024-01-11", "equity": 113917.85}, {"date": "2024-01-22", "equity": 114743.87}, {"date": "2024-01-30", "equity": 116058.35}, {"date": "2024-02-07", "equity": 118065.5}, {"date": "2024-02-15", "equity": 118809.57}, {"date": "2024-02-26", "equity": 120046.47}, {"date": "2024-03-05", "equity": 120607.45}, {"date": "2024-03-13", "equity": 120703.5}, {"date": "2024-03-22", "equity": 121896.41}, {"date": "2024-04-02", "equity": 120481.76}, {"date": "2024-04-10", "equity": 120227.08}, {"date": "2024-04-18", "equity": 118647.22}, {"date": "2024-04-26", "equity": 119803.54}, {"date": "2024-05-06", "equity": 119684.13}, {"date": "2024-05-14", "equity": 120605.89}, {"date": "2024-05-22", "equity": 121837.52}, {"date": "2024-05-31", "equity": 121940.52}, {"date": "2024-06-10", "equity": 123422.69}, {"date": "2024-06-20", "equity": 124863.72}, {"date": "2024-06-28", "equity": 125500.98}, {"date": "2024-07-09", "equity": 127757}, {"date": "2024-07-17", "equity": 128283.44}, {"date": "2024-07-25", "equity": 125068.18}, {"date": "2024-08-02", "equity": 125355.93}, {"date": "2024-08-12", "equity": 124162.94}, {"date": "2024-08-20", "equity": 125860.97}, {"date": "2024-08-28", "equity": 126699.07}, {"date": "2024-09-06", "equity": 125247.28}, {"date": "2024-09-16", "equity": 125949.26}, {"date": "2024-09-25", "equity": 125353.53}, {"date": "2024-10-03", "equity": 125468.06}, {"date": "2024-10-11", "equity": 125575.56}, {"date": "2024-10-21", "equity": 124923.83}, {"date": "2024-10-29", "equity": 124349.56}, {"date": "2024-11-06", "equity": 125373.26}, {"date": "2024-11-14", "equity": 124829.38}, {"date": "2024-11-22", "equity": 125221.68}, {"date": "2024-12-03", "equity": 126134.76}, {"date": "2024-12-11", "equity": 126373.21}, {"date": "2024-12-20", "equity": 125577.91}, {"date": "2024-12-31", "equity": 124891.74}, {"date": "2025-01-10", "equity": 123997.34}, {"date": "2025-01-21", "equity": 125740.84}, {"date": "2025-01-29", "equity": 126355.95}, {"date": "2025-02-06", "equity": 128053.14}, {"date": "2025-02-14", "equity": 128045.44}, {"date": "2025-02-25", "equity": 127791.44}, {"date": "2025-03-05", "equity": 127160.34}, {"date": "2025-03-13", "equity": 124200.31}, {"date": "2025-03-21", "equity": 124293.97}, {"date": "2025-04-01", "equity": 124479.72}, {"date": "2025-04-09", "equity": 124577.02}, {"date": "2025-04-17", "equity": 122061.43}, {"date": "2025-04-28", "equity": 122200.57}, {"date": "2025-05-06", "equity": 121831.76}, {"date": "2025-05-14", "equity": 122084.66}, {"date": "2025-05-22", "equity": 121858.91}, {"date": "2025-06-02", "equity": 122472.92}, {"date": "2025-06-10", "equity": 122793.35}, {"date": "2025-06-18", "equity": 121834.75}, {"date": "2025-06-30", "equity": 122814.27}, {"date": "2025-07-09", "equity": 122665.9}, {"date": "2025-07-17", "equity": 122956.17}, {"date": "2025-07-25", "equity": 124856.18}, {"date": "2025-08-04", "equity": 124226.22}, {"date": "2025-08-12", "equity": 125835}, {"date": "2025-08-20", "equity": 124971.72}, {"date": "2025-08-28", "equity": 126572.84}, {"date": "2025-09-08", "equity": 128772.79}, {"date": "2025-09-16", "equity": 131345.17}, {"date": "2025-09-24", "equity": 131818.76}, {"date": "2025-10-03", "equity": 132241.27}, {"date": "2025-10-13", "equity": 130169.02}, {"date": "2025-10-21", "equity": 131012.25}, {"date": "2025-10-29", "equity": 132949.44}, {"date": "2025-11-06", "equity": 134271.92}, {"date": "2025-11-14", "equity": 134796.17}, {"date": "2025-11-24", "equity": 137525.82}, {"date": "2025-12-03", "equity": 137595.7}, {"date": "2025-12-11", "equity": 136712.99}, {"date": "2025-12-19", "equity": 135567.18}, {"date": "2025-12-31", "equity": 135808.6}, {"date": "2026-01-09", "equity": 136525.2}, {"date": "2026-01-20", "equity": 135210.1}, {"date": "2026-01-28", "equity": 134782.22}, {"date": "2026-02-05", "equity": 134775.99}, {"date": "2026-02-13", "equity": 135044.52}, {"date": "2026-02-24", "equity": 134654.6}, {"date": "2026-03-04", "equity": 133876.16}, {"date": "2026-03-12", "equity": 133615.43}, {"date": "2026-03-20", "equity": 133275.2}, {"date": "2026-03-30", "equity": 133203.59}, {"date": "2026-04-09", "equity": 133664.57}, {"date": "2026-04-17", "equity": 133293.69}, {"date": "2026-04-27", "equity": 132997.56}, {"date": "2026-05-05", "equity": 134005.65}, {"date": "2026-05-13", "equity": 135944.02}, {"date": "2026-05-21", "equity": 135470.53}, {"date": "2026-06-01", "equity": 135603.81}, {"date": "2026-06-09", "equity": 134786.68}, {"date": "2026-06-17", "equity": 134446.51}, {"date": "2026-06-26", "equity": 137042.15}, {"date": "2026-07-08", "equity": 138137.1}, {"date": "2026-07-16", "equity": 139995.48}, {"date": "2026-07-24", "equity": 139527.56}, {"date": "2026-08-03", "equity": 139175.56}, {"date": "2026-08-11", "equity": 139722.93}, {"date": "2026-08-19", "equity": 139799.65}, {"date": "2026-08-27", "equity": 139495.72}, {"date": "2026-09-04", "equity": 138847.23}, {"date": "2026-09-15", "equity": 138705.85}, {"date": "2026-09-23", "equity": 138715.12}, {"date": "2026-10-01", "equity": 138822.16}]'::jsonb,'[{"pnl": -539.58, "symbol": "MSFT", "exitDate": "2024-12-27", "quantity": 23, "entryDate": "2024-12-17", "exitPrice": 424.79, "returnPct": -5.23, "entryPrice": 448.25, "exitReason": "trailing stop"}, {"pnl": 394.65, "symbol": "AAPL", "exitDate": "2025-01-02", "quantity": 45, "entryDate": "2024-11-26", "exitPrice": 242.06, "returnPct": 3.76, "entryPrice": 233.29, "exitReason": "trailing stop"}, {"pnl": 75.68, "symbol": "MA", "exitDate": "2025-01-06", "quantity": 22, "entryDate": "2024-11-01", "exitPrice": 506.36, "returnPct": 0.68, "entryPrice": 502.92, "exitReason": "trailing stop"}, {"pnl": 956.08, "symbol": "V", "exitDate": "2025-01-13", "quantity": 38, "entryDate": "2024-10-25", "exitPrice": 302.72, "returnPct": 9.06, "entryPrice": 277.56, "exitReason": "trailing stop"}, {"pnl": -711.39, "symbol": "MSFT", "exitDate": "2025-01-30", "quantity": 23, "entryDate": "2025-01-22", "exitPrice": 409.19, "returnPct": -7.03, "entryPrice": 440.12, "exitReason": "trailing stop"}, {"pnl": 108.8, "symbol": "GOOGL", "exitDate": "2025-02-05", "quantity": 64, "entryDate": "2024-12-13", "exitPrice": 190.37, "returnPct": 0.9, "entryPrice": 188.67, "exitReason": "trailing stop"}, {"pnl": -492.48, "symbol": "HD", "exitDate": "2025-02-19", "quantity": 27, "entryDate": "2025-01-30", "exitPrice": 377.57, "returnPct": -4.61, "entryPrice": 395.81, "exitReason": "trailing stop"}, {"pnl": 1226.55, "symbol": "JPM", "exitDate": "2025-02-20", "quantity": 51, "entryDate": "2025-01-03", "exitPrice": 258.94, "returnPct": 10.24, "entryPrice": 234.89, "exitReason": "trailing stop"}, {"pnl": 620.84, "symbol": "COST", "exitDate": "2025-02-27", "quantity": 11, "entryDate": "2025-01-27", "exitPrice": 1012.65, "returnPct": 5.9, "entryPrice": 956.21, "exitReason": "trailing stop"}, {"pnl": 318.6, "symbol": "MA", "exitDate": "2025-03-06", "quantity": 20, "entryDate": "2025-01-24", "exitPrice": 544.65, "returnPct": 3.01, "entryPrice": 528.72, "exitReason": "trailing stop"}, {"pnl": 975.1, "symbol": "V", "exitDate": "2025-03-06", "quantity": 35, "entryDate": "2025-01-15", "exitPrice": 340.11, "returnPct": 8.92, "entryPrice": 312.25, "exitReason": "trailing stop"}, {"pnl": -840.4, "symbol": "COST", "exitDate": "2025-03-07", "quantity": 10, "entryDate": "2025-02-28", "exitPrice": 955.53, "returnPct": -8.08, "entryPrice": 1039.57, "exitReason": "trailing stop"}, {"pnl": -774.9, "symbol": "AAPL", "exitDate": "2025-03-10", "quantity": 45, "entryDate": "2025-02-19", "exitPrice": 226.18, "returnPct": -7.07, "entryPrice": 243.4, "exitReason": "trailing stop"}, {"pnl": -157.43, "symbol": "LLY", "exitDate": "2025-03-10", "quantity": 13, "entryDate": "2025-02-05", "exitPrice": 820.19, "returnPct": -1.46, "entryPrice": 832.3, "exitReason": "trailing stop"}, {"pnl": -961.62, "symbol": "V", "exitDate": "2025-04-04", "quantity": 31, "entryDate": "2025-03-26", "exitPrice": 309.15, "returnPct": -9.12, "entryPrice": 340.17, "exitReason": "trailing stop"}, {"pnl": -1177.26, "symbol": "UNH", "exitDate": "2025-04-17", "quantity": 21, "entryDate": "2025-03-20", "exitPrice": 436.52, "returnPct": -11.38, "entryPrice": 492.58, "exitReason": "trailing stop"}, {"pnl": -361.36, "symbol": "LLY", "exitDate": "2025-05-01", "quantity": 8, "entryDate": "2025-04-17", "exitPrice": 785.47, "returnPct": -5.44, "entryPrice": 830.64, "exitReason": "trailing stop"}, {"pnl": -401.8, "symbol": "V", "exitDate": "2025-05-23", "quantity": 28, "entryDate": "2025-05-19", "exitPrice": 350.03, "returnPct": -3.94, "entryPrice": 364.38, "exitReason": "trailing stop"}, {"pnl": 37.6, "symbol": "COST", "exitDate": "2025-06-11", "quantity": 10, "entryDate": "2025-04-17", "exitPrice": 989.84, "returnPct": 0.38, "entryPrice": 986.08, "exitReason": "trailing stop"}, {"pnl": -341.88, "symbol": "V", "exitDate": "2025-06-13", "quantity": 28, "entryDate": "2025-06-02", "exitPrice": 349.56, "returnPct": -3.38, "entryPrice": 361.77, "exitReason": "trailing stop"}, {"pnl": -412.93, "symbol": "MA", "exitDate": "2025-06-13", "quantity": 17, "entryDate": "2025-05-19", "exitPrice": 557.67, "returnPct": -4.17, "entryPrice": 581.96, "exitReason": "trailing stop"}, {"pnl": -569.74, "symbol": "GOOGL", "exitDate": "2025-06-20", "quantity": 61, "entryDate": "2025-06-09", "exitPrice": 166.08, "returnPct": -5.32, "entryPrice": 175.42, "exitReason": "trailing stop"}, {"pnl": -565.62, "symbol": "V", "exitDate": "2025-08-01", "quantity": 33, "entryDate": "2025-07-07", "exitPrice": 335.94, "returnPct": -4.85, "entryPrice": 353.08, "exitReason": "trailing stop"}, {"pnl": -552.75, "symbol": "AAPL", "exitDate": "2025-08-01", "quantity": 55, "entryDate": "2025-07-02", "exitPrice": 201.33, "returnPct": -4.75, "entryPrice": 211.38, "exitReason": "trailing stop"}, {"pnl": 1618.74, "symbol": "MSFT", "exitDate": "2025-08-20", "quantity": 23, "entryDate": "2025-05-02", "exitPrice": 500.55, "returnPct": 16.36, "entryPrice": 430.17, "exitReason": "trailing stop"}, {"pnl": 700.23, "symbol": "AAPL", "exitDate": "2025-09-10", "quantity": 51, "entryDate": "2025-08-06", "exitPrice": 225.98, "returnPct": 6.47, "entryPrice": 212.25, "exitReason": "trailing stop"}, {"pnl": -392.19, "symbol": "MA", "exitDate": "2025-09-23", "quantity": 17, "entryDate": "2025-08-20", "exitPrice": 565.95, "returnPct": -3.92, "entryPrice": 589.02, "exitReason": "trailing stop"}, {"pnl": 933.24, "symbol": "HD", "exitDate": "2025-09-30", "quantity": 28, "entryDate": "2025-07-01", "exitPrice": 394.09, "returnPct": 9.24, "entryPrice": 360.76, "exitReason": "trailing stop"}, {"pnl": 4347.42, "symbol": "GOOGL", "exitDate": "2025-10-10", "quantity": 66, "entryDate": "2025-06-25", "exitPrice": 235.96, "returnPct": 38.73, "entryPrice": 170.09, "exitReason": "trailing stop"}, {"pnl": 1544, "symbol": "JPM", "exitDate": "2025-10-10", "quantity": 40, "entryDate": "2025-05-29", "exitPrice": 296.76, "returnPct": 14.95, "entryPrice": 258.16, "exitReason": "trailing stop"}, {"pnl": 1292.55, "symbol": "UNH", "exitDate": "2025-10-30", "quantity": 35, "entryDate": "2025-09-02", "exitPrice": 335.77, "returnPct": 12.36, "entryPrice": 298.84, "exitReason": "trailing stop"}, {"pnl": -285.6, "symbol": "MSFT", "exitDate": "2025-11-04", "quantity": 21, "entryDate": "2025-10-06", "exitPrice": 510.51, "returnPct": -2.59, "entryPrice": 524.11, "exitReason": "trailing stop"}, {"pnl": -333.37, "symbol": "JPM", "exitDate": "2025-11-17", "quantity": 37, "entryDate": "2025-10-30", "exitPrice": 296.26, "returnPct": -2.95, "entryPrice": 305.27, "exitReason": "trailing stop"}, {"pnl": 2451.41, "symbol": "LLY", "exitDate": "2025-12-04", "quantity": 13, "entryDate": "2025-10-01", "exitPrice": 1009.1, "returnPct": 22.98, "entryPrice": 820.53, "exitReason": "trailing stop"}, {"pnl": 2280.5, "symbol": "GOOGL", "exitDate": "2025-12-17", "quantity": 50, "entryDate": "2025-10-15", "exitPrice": 296.07, "returnPct": 18.21, "entryPrice": 250.46, "exitReason": "trailing stop"}, {"pnl": 2482.15, "symbol": "AAPL", "exitDate": "2025-12-17", "quantity": 55, "entryDate": "2025-09-10", "exitPrice": 271.11, "returnPct": 19.97, "entryPrice": 225.98, "exitReason": "trailing stop"}, {"pnl": -139.86, "symbol": "JPM", "exitDate": "2026-01-13", "quantity": 37, "entryDate": "2025-12-04", "exitPrice": 307.91, "returnPct": -1.21, "entryPrice": 311.69, "exitReason": "trailing stop"}, {"pnl": -456.36, "symbol": "LLY", "exitDate": "2026-01-15", "quantity": 12, "entryDate": "2025-12-19", "exitPrice": 1027.64, "returnPct": -3.57, "entryPrice": 1065.67, "exitReason": "trailing stop"}, {"pnl": 136.94, "symbol": "GOOGL", "exitDate": "2026-02-10", "quantity": 41, "entryDate": "2026-01-02", "exitPrice": 317.97, "returnPct": 1.06, "entryPrice": 314.63, "exitReason": "trailing stop"}, {"pnl": -941.52, "symbol": "LLY", "exitDate": "2026-03-03", "quantity": 12, "entryDate": "2026-01-22", "exitPrice": 1003.92, "returnPct": -7.25, "entryPrice": 1082.38, "exitReason": "trailing stop"}, {"pnl": -751.2, "symbol": "HD", "exitDate": "2026-03-05", "quantity": 30, "entryDate": "2026-02-04", "exitPrice": 353.92, "returnPct": -6.61, "entryPrice": 378.96, "exitReason": "trailing stop"}, {"pnl": -176.44, "symbol": "COST", "exitDate": "2026-03-23", "quantity": 11, "entryDate": "2026-01-23", "exitPrice": 962.9, "returnPct": -1.64, "entryPrice": 978.94, "exitReason": "trailing stop"}, {"pnl": -204.88, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 13, "entryDate": "2026-03-31", "exitPrice": 977.65, "returnPct": -1.59, "entryPrice": 993.41, "exitReason": "trailing stop"}, {"pnl": -602.35, "symbol": "JPM", "exitDate": "2026-05-11", "quantity": 35, "entryDate": "2026-04-20", "exitPrice": 298.47, "returnPct": -5.45, "entryPrice": 315.68, "exitReason": "trailing stop"}, {"pnl": -235.51, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 11, "entryDate": "2026-05-15", "exitPrice": 1026.22, "returnPct": -2.04, "entryPrice": 1047.63, "exitReason": "trailing stop"}, {"pnl": -762.96, "symbol": "GOOGL", "exitDate": "2026-06-02", "quantity": 33, "entryDate": "2026-04-30", "exitPrice": 361.39, "returnPct": -6.01, "entryPrice": 384.51, "exitReason": "trailing stop"}, {"pnl": -617.04, "symbol": "V", "exitDate": "2026-06-03", "quantity": 36, "entryDate": "2026-05-20", "exitPrice": 313.05, "returnPct": -5.19, "entryPrice": 330.19, "exitReason": "trailing stop"}, {"pnl": 104.76, "symbol": "MSFT", "exitDate": "2026-06-05", "quantity": 27, "entryDate": "2026-05-04", "exitPrice": 415.85, "returnPct": 0.94, "entryPrice": 411.97, "exitReason": "trailing stop"}, {"pnl": 1171.75, "symbol": "AAPL", "exitDate": "2026-06-09", "quantity": 43, "entryDate": "2026-04-16", "exitPrice": 290.11, "returnPct": 10.37, "entryPrice": 262.86, "exitReason": "trailing stop"}, {"pnl": -136.68, "symbol": "HD", "exitDate": "2026-07-20", "quantity": 34, "entryDate": "2026-06-16", "exitPrice": 330.61, "returnPct": -1.2, "entryPrice": 334.63, "exitReason": "trailing stop"}, {"pnl": 643.05, "symbol": "AAPL", "exitDate": "2026-07-31", "quantity": 45, "entryDate": "2026-07-01", "exitPrice": 308.46, "returnPct": 4.86, "entryPrice": 294.17, "exitReason": "trailing stop"}, {"pnl": 369, "symbol": "LLY", "exitDate": "2026-08-03", "quantity": 10, "entryDate": "2026-05-27", "exitPrice": 1119.58, "returnPct": 3.41, "entryPrice": 1082.68, "exitReason": "trailing stop"}, {"pnl": 1788.48, "symbol": "UNH", "exitDate": "2026-08-11", "quantity": 36, "entryDate": "2026-04-23", "exitPrice": 400.03, "returnPct": 14.18, "entryPrice": 350.35, "exitReason": "trailing stop"}, {"pnl": -401.1, "symbol": "HD", "exitDate": "2026-08-27", "quantity": 35, "entryDate": "2026-08-03", "exitPrice": 326.18, "returnPct": -3.39, "entryPrice": 337.64, "exitReason": "trailing stop"}, {"pnl": -410.63, "symbol": "LLY", "exitDate": "2026-08-28", "quantity": 11, "entryDate": "2026-08-11", "exitPrice": 1173.85, "returnPct": -3.08, "entryPrice": 1211.18, "exitReason": "trailing stop"}, {"pnl": 514.69, "symbol": "MA", "exitDate": "2026-09-08", "quantity": 22, "entryDate": "2026-07-20", "exitPrice": 570.95, "returnPct": 4.27, "entryPrice": 547.55, "exitReason": "trailing stop"}, {"pnl": 1546.03, "symbol": "JPM", "exitDate": "2026-09-14", "quantity": 38, "entryDate": "2026-06-04", "exitPrice": 350.19, "returnPct": 13.15, "entryPrice": 309.5, "exitReason": "trailing stop"}, {"pnl": 1296.48, "symbol": "V", "exitDate": "2026-09-18", "quantity": 37, "entryDate": "2026-06-16", "exitPrice": 367.63, "returnPct": 10.54, "entryPrice": 332.59, "exitReason": "trailing stop"}, {"pnl": 1368.64, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 28, "entryDate": "2026-07-31", "exitPrice": 512.71, "returnPct": 10.54, "entryPrice": 463.83, "exitReason": "end of test"}, {"pnl": 186.84, "symbol": "AAPL", "exitDate": "2026-10-01", "quantity": 36, "entryDate": "2026-09-01", "exitPrice": 330.44, "returnPct": 1.6, "entryPrice": 325.25, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:22.416695+00:00') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('5bde5b70-59cd-4df5-87ea-0fb8e1716253','a310f750-7afd-4996-adb1-f9e56a4ea88e',NULL,'2025-10-01','2026-10-01',100000.0,'complete',9.015,45.16,-5.761,1.039,31,'[{"date": "2025-10-01", "equity": 100000}, {"date": "2025-10-02", "equity": 99940.65}, {"date": "2025-10-03", "equity": 100636.82}, {"date": "2025-10-06", "equity": 100901.74}, {"date": "2025-10-07", "equity": 100626.27}, {"date": "2025-10-08", "equity": 100785.73}, {"date": "2025-10-09", "equity": 100443.97}, {"date": "2025-10-13", "equity": 99231.81}, {"date": "2025-10-14", "equity": 99016.88}, {"date": "2025-10-15", "equity": 99860.27}, {"date": "2025-10-16", "equity": 99091.49}, {"date": "2025-10-17", "equity": 99249.26}, {"date": "2025-10-20", "equity": 100688.97}, {"date": "2025-10-21", "equity": 100052.03}, {"date": "2025-10-23", "equity": 100081.25}, {"date": "2025-10-24", "equity": 100908.55}, {"date": "2025-10-27", "equity": 102131.56}, {"date": "2025-10-28", "equity": 102298.78}, {"date": "2025-10-29", "equity": 102122.23}, {"date": "2025-10-30", "equity": 102258.53}, {"date": "2025-10-31", "equity": 102341.95}, {"date": "2025-11-04", "equity": 102617.83}, {"date": "2025-11-05", "equity": 103402.2}, {"date": "2025-11-06", "equity": 103652.06}, {"date": "2025-11-07", "equity": 103063.95}, {"date": "2025-11-10", "equity": 104535.69}, {"date": "2025-11-11", "equity": 105217.75}, {"date": "2025-11-12", "equity": 105483.95}, {"date": "2025-11-14", "equity": 104224.24}, {"date": "2025-11-17", "equity": 104268.72}, {"date": "2025-11-18", "equity": 104358.69}, {"date": "2025-11-19", "equity": 105198.8}, {"date": "2025-11-20", "equity": 104800.85}, {"date": "2025-11-21", "equity": 105927.52}, {"date": "2025-11-24", "equity": 107406.02}, {"date": "2025-11-26", "equity": 108152.51}, {"date": "2025-11-28", "equity": 107770.71}, {"date": "2025-12-01", "equity": 107479.08}, {"date": "2025-12-02", "equity": 107502.55}, {"date": "2025-12-03", "equity": 107434.81}, {"date": "2025-12-04", "equity": 106830.85}, {"date": "2025-12-05", "equity": 106898.09}, {"date": "2025-12-09", "equity": 105955.28}, {"date": "2025-12-10", "equity": 106629.98}, {"date": "2025-12-11", "equity": 106446.8}, {"date": "2025-12-12", "equity": 106317.99}, {"date": "2025-12-15", "equity": 106081.43}, {"date": "2025-12-16", "equity": 105805.26}, {"date": "2025-12-17", "equity": 105055.52}, {"date": "2025-12-19", "equity": 105144.1}, {"date": "2025-12-22", "equity": 105478.84}, {"date": "2025-12-23", "equity": 105523.12}, {"date": "2025-12-24", "equity": 105725.07}, {"date": "2025-12-26", "equity": 105693.11}, {"date": "2025-12-29", "equity": 105539.47}, {"date": "2025-12-31", "equity": 105424.9}, {"date": "2026-01-02", "equity": 105634.27}, {"date": "2026-01-05", "equity": 105519.36}, {"date": "2026-01-06", "equity": 105812.21}, {"date": "2026-01-07", "equity": 106472.7}, {"date": "2026-01-08", "equity": 106440.45}, {"date": "2026-01-09", "equity": 106261.77}, {"date": "2026-01-13", "equity": 106021.03}, {"date": "2026-01-14", "equity": 105957.61}, {"date": "2026-01-15", "equity": 105241.57}, {"date": "2026-01-16", "equity": 105113.89}, {"date": "2026-01-20", "equity": 104729.41}, {"date": "2026-01-21", "equity": 105035.65}, {"date": "2026-01-22", "equity": 105138.37}, {"date": "2026-01-26", "equity": 104850.46}, {"date": "2026-01-27", "equity": 104488.44}, {"date": "2026-01-28", "equity": 104228.84}, {"date": "2026-01-29", "equity": 104219.86}, {"date": "2026-01-30", "equity": 104268.5}, {"date": "2026-02-02", "equity": 104963.1}, {"date": "2026-02-03", "equity": 104358.23}, {"date": "2026-02-05", "equity": 104225.95}, {"date": "2026-02-06", "equity": 104548.67}, {"date": "2026-02-09", "equity": 104235.96}, {"date": "2026-02-10", "equity": 103639.56}, {"date": "2026-02-11", "equity": 103628.84}, {"date": "2026-02-12", "equity": 104208.75}, {"date": "2026-02-13", "equity": 104541.76}, {"date": "2026-02-18", "equity": 103708.49}, {"date": "2026-02-19", "equity": 103470.68}, {"date": "2026-02-20", "equity": 103357.78}, {"date": "2026-02-23", "equity": 103880.42}, {"date": "2026-02-24", "equity": 104083.48}, {"date": "2026-02-25", "equity": 103551.48}, {"date": "2026-02-26", "equity": 103320.91}, {"date": "2026-03-02", "equity": 103328.08}, {"date": "2026-03-03", "equity": 103107.76}, {"date": "2026-03-04", "equity": 103176.71}, {"date": "2026-03-05", "equity": 102591.82}, {"date": "2026-03-06", "equity": 102806.19}, {"date": "2026-03-09", "equity": 102891.99}, {"date": "2026-03-10", "equity": 102793.58}, {"date": "2026-03-12", "equity": 102871.97}, {"date": "2026-03-13", "equity": 102935.67}, {"date": "2026-03-16", "equity": 102853.12}, {"date": "2026-03-17", "equity": 102780.97}, {"date": "2026-03-18", "equity": 102568.42}, {"date": "2026-03-19", "equity": 102501.34}, {"date": "2026-03-20", "equity": 102469.88}, {"date": "2026-03-24", "equity": 102385.25}, {"date": "2026-03-25", "equity": 102385.25}, {"date": "2026-03-26", "equity": 102385.25}, {"date": "2026-03-27", "equity": 102385.25}, {"date": "2026-03-30", "equity": 102385.25}, {"date": "2026-03-31", "equity": 102385.25}, {"date": "2026-04-02", "equity": 102643.97}, {"date": "2026-04-06", "equity": 102693.53}, {"date": "2026-04-07", "equity": 102620.59}, {"date": "2026-04-08", "equity": 102852.85}, {"date": "2026-04-09", "equity": 102881.69}, {"date": "2026-04-10", "equity": 102410.31}, {"date": "2026-04-13", "equity": 102164.61}, {"date": "2026-04-15", "equity": 102164.61}, {"date": "2026-04-16", "equity": 102164.61}, {"date": "2026-04-17", "equity": 102507.61}, {"date": "2026-04-20", "equity": 102650.11}, {"date": "2026-04-21", "equity": 102142.91}, {"date": "2026-04-22", "equity": 102489.71}, {"date": "2026-04-23", "equity": 102456.81}, {"date": "2026-04-27", "equity": 102167.05}, {"date": "2026-04-28", "equity": 102820.37}, {"date": "2026-04-29", "equity": 102864.31}, {"date": "2026-04-30", "equity": 103069.55}, {"date": "2026-05-01", "equity": 103440.29}, {"date": "2026-05-04", "equity": 103070.93}, {"date": "2026-05-05", "equity": 103341.77}, {"date": "2026-05-07", "equity": 104275.35}, {"date": "2026-05-08", "equity": 104740.65}, {"date": "2026-05-11", "equity": 104303.57}, {"date": "2026-05-12", "equity": 104708.6}, {"date": "2026-05-13", "equity": 105604.62}, {"date": "2026-05-14", "equity": 105568.77}, {"date": "2026-05-15", "equity": 105653.54}, {"date": "2026-05-19", "equity": 105499.87}, {"date": "2026-05-20", "equity": 105292.52}, {"date": "2026-05-21", "equity": 105050.69}, {"date": "2026-05-22", "equity": 104939.37}, {"date": "2026-05-26", "equity": 104491.99}, {"date": "2026-05-27", "equity": 104851.81}, {"date": "2026-05-28", "equity": 105749.81}, {"date": "2026-06-01", "equity": 105208.71}, {"date": "2026-06-02", "equity": 103993.84}, {"date": "2026-06-03", "equity": 103344.78}, {"date": "2026-06-04", "equity": 104737.23}, {"date": "2026-06-05", "equity": 104481.93}, {"date": "2026-06-08", "equity": 104622.65}, {"date": "2026-06-09", "equity": 104307.15}, {"date": "2026-06-11", "equity": 104240.53}, {"date": "2026-06-12", "equity": 104357.65}, {"date": "2026-06-15", "equity": 104482.05}, {"date": "2026-06-16", "equity": 104762.11}, {"date": "2026-06-17", "equity": 103899.57}, {"date": "2026-06-18", "equity": 103568.88}, {"date": "2026-06-22", "equity": 103851.61}, {"date": "2026-06-24", "equity": 104905.33}, {"date": "2026-06-25", "equity": 105491.55}, {"date": "2026-06-26", "equity": 106946.77}, {"date": "2026-06-29", "equity": 107354.24}, {"date": "2026-06-30", "equity": 106831.81}, {"date": "2026-07-01", "equity": 107811.98}, {"date": "2026-07-06", "equity": 109017.22}, {"date": "2026-07-07", "equity": 109346.68}, {"date": "2026-07-08", "equity": 108241.25}, {"date": "2026-07-09", "equity": 108973.73}, {"date": "2026-07-10", "equity": 108556.05}, {"date": "2026-07-13", "equity": 108870.61}, {"date": "2026-07-14", "equity": 108552.42}, {"date": "2026-07-16", "equity": 110389.15}, {"date": "2026-07-17", "equity": 109933.16}, {"date": "2026-07-20", "equity": 108781.38}, {"date": "2026-07-21", "equity": 109590.79}, {"date": "2026-07-22", "equity": 109016.17}, {"date": "2026-07-23", "equity": 108665.22}, {"date": "2026-07-24", "equity": 109857.21}, {"date": "2026-07-28", "equity": 112141.69}, {"date": "2026-07-29", "equity": 111141.57}, {"date": "2026-07-30", "equity": 110754.8}, {"date": "2026-07-31", "equity": 109009.98}, {"date": "2026-08-03", "equity": 109425.98}, {"date": "2026-08-04", "equity": 110000.2}, {"date": "2026-08-05", "equity": 110238.63}, {"date": "2026-08-07", "equity": 109988.28}, {"date": "2026-08-10", "equity": 110128.79}, {"date": "2026-08-11", "equity": 110066.43}, {"date": "2026-08-12", "equity": 109300.69}, {"date": "2026-08-13", "equity": 109576.71}, {"date": "2026-08-14", "equity": 109056.24}, {"date": "2026-08-17", "equity": 108134.44}, {"date": "2026-08-19", "equity": 110164.5}, {"date": "2026-08-20", "equity": 109010.43}, {"date": "2026-08-21", "equity": 109637}, {"date": "2026-08-24", "equity": 110931.42}, {"date": "2026-08-25", "equity": 110976.37}, {"date": "2026-08-26", "equity": 110415.86}, {"date": "2026-08-27", "equity": 109801.73}, {"date": "2026-08-31", "equity": 109848.48}, {"date": "2026-09-01", "equity": 109110.87}, {"date": "2026-09-02", "equity": 109438.83}, {"date": "2026-09-03", "equity": 110220.58}, {"date": "2026-09-04", "equity": 109038.26}, {"date": "2026-09-08", "equity": 107999.9}, {"date": "2026-09-09", "equity": 107882.85}, {"date": "2026-09-11", "equity": 108921.78}, {"date": "2026-09-14", "equity": 109222.1}, {"date": "2026-09-15", "equity": 108872.39}, {"date": "2026-09-16", "equity": 108510.15}, {"date": "2026-09-17", "equity": 108896.68}, {"date": "2026-09-18", "equity": 108589.63}, {"date": "2026-09-21", "equity": 109008.79}, {"date": "2026-09-23", "equity": 108885.67}, {"date": "2026-09-24", "equity": 108743.94}, {"date": "2026-09-25", "equity": 109572.63}, {"date": "2026-09-28", "equity": 109238.35}, {"date": "2026-09-29", "equity": 108853.39}, {"date": "2026-09-30", "equity": 109137.52}, {"date": "2026-10-01", "equity": 109014.58}]'::jsonb,'[{"pnl": -653.4, "symbol": "JPM", "exitDate": "2025-10-22", "quantity": 44, "entryDate": "2025-10-01", "exitPrice": 289.98, "returnPct": -4.87, "entryPrice": 304.83, "exitReason": "trailing stop"}, {"pnl": -364.56, "symbol": "UNH", "exitDate": "2025-10-30", "quantity": 42, "entryDate": "2025-10-02", "exitPrice": 335.77, "returnPct": -2.52, "entryPrice": 344.45, "exitReason": "trailing stop"}, {"pnl": -326.4, "symbol": "MSFT", "exitDate": "2025-11-04", "quantity": 24, "entryDate": "2025-10-06", "exitPrice": 510.51, "returnPct": -2.59, "entryPrice": 524.11, "exitReason": "trailing stop"}, {"pnl": -387.43, "symbol": "JPM", "exitDate": "2025-11-17", "quantity": 43, "entryDate": "2025-10-30", "exitPrice": 296.26, "returnPct": -2.95, "entryPrice": 305.27, "exitReason": "trailing stop"}, {"pnl": 2828.55, "symbol": "LLY", "exitDate": "2025-12-04", "quantity": 15, "entryDate": "2025-10-01", "exitPrice": 1009.1, "returnPct": 22.98, "entryPrice": 820.53, "exitReason": "trailing stop"}, {"pnl": 947.34, "symbol": "AAPL", "exitDate": "2025-12-17", "quantity": 57, "entryDate": "2025-10-01", "exitPrice": 271.11, "returnPct": 6.53, "entryPrice": 254.49, "exitReason": "trailing stop"}, {"pnl": 3059.15, "symbol": "GOOGL", "exitDate": "2025-12-17", "quantity": 59, "entryDate": "2025-10-01", "exitPrice": 296.07, "returnPct": 21.23, "entryPrice": 244.22, "exitReason": "trailing stop"}, {"pnl": -162.54, "symbol": "JPM", "exitDate": "2026-01-13", "quantity": 43, "entryDate": "2025-12-04", "exitPrice": 307.91, "returnPct": -1.21, "entryPrice": 311.69, "exitReason": "trailing stop"}, {"pnl": -532.42, "symbol": "LLY", "exitDate": "2026-01-15", "quantity": 14, "entryDate": "2025-12-19", "exitPrice": 1027.64, "returnPct": -3.57, "entryPrice": 1065.67, "exitReason": "trailing stop"}, {"pnl": 160.32, "symbol": "GOOGL", "exitDate": "2026-02-10", "quantity": 48, "entryDate": "2026-01-02", "exitPrice": 317.97, "returnPct": 1.06, "entryPrice": 314.63, "exitReason": "trailing stop"}, {"pnl": -1098.44, "symbol": "LLY", "exitDate": "2026-03-03", "quantity": 14, "entryDate": "2026-01-22", "exitPrice": 1003.92, "returnPct": -7.25, "entryPrice": 1082.38, "exitReason": "trailing stop"}, {"pnl": -876.4, "symbol": "HD", "exitDate": "2026-03-05", "quantity": 35, "entryDate": "2026-02-04", "exitPrice": 353.92, "returnPct": -6.61, "entryPrice": 378.96, "exitReason": "trailing stop"}, {"pnl": -208.52, "symbol": "COST", "exitDate": "2026-03-23", "quantity": 13, "entryDate": "2026-01-23", "exitPrice": 962.9, "returnPct": -1.64, "entryPrice": 978.94, "exitReason": "trailing stop"}, {"pnl": -220.64, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 14, "entryDate": "2026-03-31", "exitPrice": 977.65, "returnPct": -1.59, "entryPrice": 993.41, "exitReason": "trailing stop"}, {"pnl": -688.4, "symbol": "JPM", "exitDate": "2026-05-11", "quantity": 40, "entryDate": "2026-04-20", "exitPrice": 298.47, "returnPct": -5.45, "entryPrice": 315.68, "exitReason": "trailing stop"}, {"pnl": -256.92, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 12, "entryDate": "2026-05-15", "exitPrice": 1026.22, "returnPct": -2.04, "entryPrice": 1047.63, "exitReason": "trailing stop"}, {"pnl": -878.56, "symbol": "GOOGL", "exitDate": "2026-06-02", "quantity": 38, "entryDate": "2026-04-30", "exitPrice": 361.39, "returnPct": -6.01, "entryPrice": 384.51, "exitReason": "trailing stop"}, {"pnl": -719.88, "symbol": "V", "exitDate": "2026-06-03", "quantity": 42, "entryDate": "2026-05-20", "exitPrice": 313.05, "returnPct": -5.19, "entryPrice": 330.19, "exitReason": "trailing stop"}, {"pnl": 120.28, "symbol": "MSFT", "exitDate": "2026-06-05", "quantity": 31, "entryDate": "2026-05-04", "exitPrice": 415.85, "returnPct": 0.94, "entryPrice": 411.97, "exitReason": "trailing stop"}, {"pnl": 1362.5, "symbol": "AAPL", "exitDate": "2026-06-09", "quantity": 50, "entryDate": "2026-04-16", "exitPrice": 290.11, "returnPct": 10.37, "entryPrice": 262.86, "exitReason": "trailing stop"}, {"pnl": -156.78, "symbol": "HD", "exitDate": "2026-07-20", "quantity": 39, "entryDate": "2026-06-16", "exitPrice": 330.61, "returnPct": -1.2, "entryPrice": 334.63, "exitReason": "trailing stop"}, {"pnl": 757.37, "symbol": "AAPL", "exitDate": "2026-07-31", "quantity": 53, "entryDate": "2026-07-01", "exitPrice": 308.46, "returnPct": 4.86, "entryPrice": 294.17, "exitReason": "trailing stop"}, {"pnl": 442.8, "symbol": "LLY", "exitDate": "2026-08-03", "quantity": 12, "entryDate": "2026-05-27", "exitPrice": 1119.58, "returnPct": 3.41, "entryPrice": 1082.68, "exitReason": "trailing stop"}, {"pnl": 2086.56, "symbol": "UNH", "exitDate": "2026-08-11", "quantity": 42, "entryDate": "2026-04-23", "exitPrice": 400.03, "returnPct": 14.18, "entryPrice": 350.35, "exitReason": "trailing stop"}, {"pnl": -469.86, "symbol": "HD", "exitDate": "2026-08-27", "quantity": 41, "entryDate": "2026-08-03", "exitPrice": 326.18, "returnPct": -3.39, "entryPrice": 337.64, "exitReason": "trailing stop"}, {"pnl": -485.29, "symbol": "LLY", "exitDate": "2026-08-28", "quantity": 13, "entryDate": "2026-08-11", "exitPrice": 1173.85, "returnPct": -3.08, "entryPrice": 1211.18, "exitReason": "trailing stop"}, {"pnl": 608.27, "symbol": "MA", "exitDate": "2026-09-08", "quantity": 26, "entryDate": "2026-07-20", "exitPrice": 570.95, "returnPct": 4.27, "entryPrice": 547.55, "exitReason": "trailing stop"}, {"pnl": 1790.14, "symbol": "JPM", "exitDate": "2026-09-14", "quantity": 44, "entryDate": "2026-06-04", "exitPrice": 350.19, "returnPct": 13.15, "entryPrice": 309.5, "exitReason": "trailing stop"}, {"pnl": 1506.72, "symbol": "V", "exitDate": "2026-09-18", "quantity": 43, "entryDate": "2026-06-16", "exitPrice": 367.63, "returnPct": 10.54, "entryPrice": 332.59, "exitReason": "trailing stop"}, {"pnl": 1613.04, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 33, "entryDate": "2026-07-31", "exitPrice": 512.71, "returnPct": 10.54, "entryPrice": 463.83, "exitReason": "end of test"}, {"pnl": 217.98, "symbol": "AAPL", "exitDate": "2026-10-01", "quantity": 42, "entryDate": "2026-09-01", "exitPrice": 330.44, "returnPct": 1.6, "entryPrice": 325.25, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:23.221313+00:00') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('2dcca563-dd0c-4bf1-82d2-0156cc207988','a310f750-7afd-4996-adb1-f9e56a4ea88e',NULL,'2021-06-01','2026-10-01',100000.0,'complete',62.575,46.7,-14.814,1.014,182,'[{"date": "2021-06-01", "equity": 100000}, {"date": "2021-06-09", "equity": 100189.87}, {"date": "2021-06-17", "equity": 100084.2}, {"date": "2021-06-25", "equity": 101607.4}, {"date": "2021-07-06", "equity": 104236.95}, {"date": "2021-07-14", "equity": 106343.7}, {"date": "2021-07-22", "equity": 106581.69}, {"date": "2021-07-30", "equity": 108163.06}, {"date": "2021-08-09", "equity": 109964.93}, {"date": "2021-08-17", "equity": 111123.22}, {"date": "2021-08-25", "equity": 111379.23}, {"date": "2021-09-03", "equity": 111989.73}, {"date": "2021-09-14", "equity": 110353.59}, {"date": "2021-09-22", "equity": 109320.26}, {"date": "2021-09-30", "equity": 107775.01}, {"date": "2021-10-08", "equity": 107674.33}, {"date": "2021-10-18", "equity": 109394.45}, {"date": "2021-10-26", "equity": 111515.47}, {"date": "2021-11-03", "equity": 113926.3}, {"date": "2021-11-11", "equity": 113774.71}, {"date": "2021-11-19", "equity": 116439.17}, {"date": "2021-12-01", "equity": 114805.41}, {"date": "2021-12-09", "equity": 116632.15}, {"date": "2021-12-17", "equity": 115613.12}, {"date": "2021-12-28", "equity": 118949.37}, {"date": "2022-01-05", "equity": 114484.06}, {"date": "2022-01-13", "equity": 112127.19}, {"date": "2022-01-24", "equity": 110227.87}, {"date": "2022-02-01", "equity": 110815.66}, {"date": "2022-02-09", "equity": 111031.19}, {"date": "2022-02-17", "equity": 108874.48}, {"date": "2022-02-28", "equity": 107209.57}, {"date": "2022-03-09", "equity": 107077.21}, {"date": "2022-03-17", "equity": 108867.37}, {"date": "2022-03-25", "equity": 109231.75}, {"date": "2022-04-04", "equity": 109270.03}, {"date": "2022-04-12", "equity": 110958.77}, {"date": "2022-04-21", "equity": 110322.65}, {"date": "2022-04-29", "equity": 109273.74}, {"date": "2022-05-09", "equity": 107746.49}, {"date": "2022-05-17", "equity": 108473.24}, {"date": "2022-05-25", "equity": 108781.61}, {"date": "2022-06-06", "equity": 108504.96}, {"date": "2022-06-14", "equity": 105708.53}, {"date": "2022-06-23", "equity": 105708.53}, {"date": "2022-07-01", "equity": 106208.48}, {"date": "2022-07-12", "equity": 106176.98}, {"date": "2022-07-20", "equity": 106105.43}, {"date": "2022-07-28", "equity": 106488.41}, {"date": "2022-08-05", "equity": 105455.23}, {"date": "2022-08-15", "equity": 107114.94}, {"date": "2022-08-23", "equity": 104172.45}, {"date": "2022-08-31", "equity": 103018.5}, {"date": "2022-09-12", "equity": 103167.3}, {"date": "2022-09-20", "equity": 102653.7}, {"date": "2022-09-28", "equity": 102278.1}, {"date": "2022-10-06", "equity": 102278.1}, {"date": "2022-10-14", "equity": 102278.1}, {"date": "2022-10-24", "equity": 102288.81}, {"date": "2022-11-01", "equity": 103096.74}, {"date": "2022-11-09", "equity": 103649.9}, {"date": "2022-11-17", "equity": 103907.21}, {"date": "2022-11-28", "equity": 104174.96}, {"date": "2022-12-07", "equity": 104033.99}, {"date": "2022-12-15", "equity": 103408.69}, {"date": "2022-12-23", "equity": 103064.24}, {"date": "2023-01-04", "equity": 103609.97}, {"date": "2023-01-12", "equity": 105382.01}, {"date": "2023-01-23", "equity": 104286.13}, {"date": "2023-01-31", "equity": 104914.47}, {"date": "2023-02-08", "equity": 106146.54}, {"date": "2023-02-16", "equity": 104603.32}, {"date": "2023-02-27", "equity": 103348.07}, {"date": "2023-03-07", "equity": 102772.4}, {"date": "2023-03-16", "equity": 103357.79}, {"date": "2023-03-24", "equity": 104648.21}, {"date": "2023-04-03", "equity": 105605.48}, {"date": "2023-04-12", "equity": 104861.03}, {"date": "2023-04-20", "equity": 105756.93}, {"date": "2023-04-28", "equity": 107936.38}, {"date": "2023-05-08", "equity": 109240.22}, {"date": "2023-05-16", "equity": 110994.57}, {"date": "2023-05-24", "equity": 110006.14}, {"date": "2023-06-02", "equity": 113024.14}, {"date": "2023-06-13", "equity": 113251.84}, {"date": "2023-06-22", "equity": 113133.78}, {"date": "2023-06-30", "equity": 114739.27}, {"date": "2023-07-11", "equity": 112976.95}, {"date": "2023-07-19", "equity": 116472.87}, {"date": "2023-07-27", "equity": 115887.62}, {"date": "2023-08-04", "equity": 113960.93}, {"date": "2023-08-14", "equity": 117548.48}, {"date": "2023-08-22", "equity": 116786.13}, {"date": "2023-08-30", "equity": 118858.03}, {"date": "2023-09-08", "equity": 119430.91}, {"date": "2023-09-19", "equity": 118975.69}, {"date": "2023-09-27", "equity": 116327.16}, {"date": "2023-10-05", "equity": 116100.52}, {"date": "2023-10-13", "equity": 117439.24}, {"date": "2023-10-23", "equity": 115504.14}, {"date": "2023-10-31", "equity": 114272.62}, {"date": "2023-11-08", "equity": 115027.73}, {"date": "2023-11-16", "equity": 115228.61}, {"date": "2023-11-27", "equity": 115940.15}, {"date": "2023-12-05", "equity": 116860.18}, {"date": "2023-12-14", "equity": 117752.93}, {"date": "2023-12-22", "equity": 118703.61}, {"date": "2024-01-03", "equity": 118109.87}, {"date": "2024-01-11", "equity": 121200.99}, {"date": "2024-01-22", "equity": 122520.92}, {"date": "2024-01-30", "equity": 124606.69}, {"date": "2024-02-07", "equity": 127803.49}, {"date": "2024-02-15", "equity": 128985.54}, {"date": "2024-02-26", "equity": 130954.77}, {"date": "2024-03-05", "equity": 131850.51}, {"date": "2024-03-13", "equity": 131982.51}, {"date": "2024-03-22", "equity": 133869.47}, {"date": "2024-04-02", "equity": 131617.34}, {"date": "2024-04-10", "equity": 131202.37}, {"date": "2024-04-18", "equity": 128683.22}, {"date": "2024-04-26", "equity": 130584.02}, {"date": "2024-05-06", "equity": 130413.98}, {"date": "2024-05-14", "equity": 131935.08}, {"date": "2024-05-22", "equity": 133957.34}, {"date": "2024-05-31", "equity": 134111.62}, {"date": "2024-06-10", "equity": 136551.92}, {"date": "2024-06-20", "equity": 138945.74}, {"date": "2024-06-28", "equity": 139974.58}, {"date": "2024-07-09", "equity": 143708.08}, {"date": "2024-07-17", "equity": 144634.26}, {"date": "2024-07-25", "equity": 139288.37}, {"date": "2024-08-02", "equity": 139753.83}, {"date": "2024-08-12", "equity": 137735.8}, {"date": "2024-08-20", "equity": 140586.46}, {"date": "2024-08-28", "equity": 141989.94}, {"date": "2024-09-06", "equity": 139552.85}, {"date": "2024-09-16", "equity": 140723.31}, {"date": "2024-09-25", "equity": 139717.58}, {"date": "2024-10-03", "equity": 139895.05}, {"date": "2024-10-11", "equity": 140082.24}, {"date": "2024-10-21", "equity": 138966.83}, {"date": "2024-10-29", "equity": 138006.95}, {"date": "2024-11-06", "equity": 139729.92}, {"date": "2024-11-14", "equity": 138823.27}, {"date": "2024-11-22", "equity": 139510.24}, {"date": "2024-12-03", "equity": 141043.82}, {"date": "2024-12-11", "equity": 141456.3}, {"date": "2024-12-20", "equity": 140099.19}, {"date": "2024-12-31", "equity": 138936.38}, {"date": "2025-01-10", "equity": 137440.36}, {"date": "2025-01-21", "equity": 140359.1}, {"date": "2025-01-29", "equity": 141376}, {"date": "2025-02-06", "equity": 144222.7}, {"date": "2025-02-14", "equity": 144222.2}, {"date": "2025-02-25", "equity": 143810.46}, {"date": "2025-03-05", "equity": 142723.01}, {"date": "2025-03-13", "equity": 137627.08}, {"date": "2025-03-21", "equity": 137783.18}, {"date": "2025-04-01", "equity": 138093.46}, {"date": "2025-04-09", "equity": 138244.59}, {"date": "2025-04-17", "equity": 134051.94}, {"date": "2025-04-28", "equity": 134319.54}, {"date": "2025-05-06", "equity": 133626.15}, {"date": "2025-05-14", "equity": 134073.25}, {"date": "2025-05-22", "equity": 133667.09}, {"date": "2025-06-02", "equity": 134675.5}, {"date": "2025-06-10", "equity": 135251.63}, {"date": "2025-06-18", "equity": 133642.16}, {"date": "2025-06-30", "equity": 135269.08}, {"date": "2025-07-09", "equity": 135028.91}, {"date": "2025-07-17", "equity": 135496.36}, {"date": "2025-07-25", "equity": 138642.35}, {"date": "2025-08-04", "equity": 137615.56}, {"date": "2025-08-12", "equity": 140265.34}, {"date": "2025-08-20", "equity": 138824.85}, {"date": "2025-08-28", "equity": 141456.51}, {"date": "2025-09-08", "equity": 145088.15}, {"date": "2025-09-16", "equity": 149382.4}, {"date": "2025-09-24", "equity": 150202.51}, {"date": "2025-10-03", "equity": 150948.73}, {"date": "2025-10-13", "equity": 147450.61}, {"date": "2025-10-21", "equity": 148871.58}, {"date": "2025-10-29", "equity": 152192.11}, {"date": "2025-11-06", "equity": 154553.19}, {"date": "2025-11-14", "equity": 155514.88}, {"date": "2025-11-24", "equity": 160192.28}, {"date": "2025-12-03", "equity": 160284.13}, {"date": "2025-12-11", "equity": 158764.54}, {"date": "2025-12-19", "equity": 156813.19}, {"date": "2025-12-31", "equity": 157231.82}, {"date": "2026-01-09", "equity": 158482.96}, {"date": "2026-01-20", "equity": 156193.52}, {"date": "2026-01-28", "equity": 155431.45}, {"date": "2026-02-05", "equity": 155444.59}, {"date": "2026-02-13", "equity": 155928.42}, {"date": "2026-02-24", "equity": 155234.04}, {"date": "2026-03-04", "equity": 153885.62}, {"date": "2026-03-12", "equity": 153430.58}, {"date": "2026-03-20", "equity": 152811.98}, {"date": "2026-03-30", "equity": 152681.78}, {"date": "2026-04-09", "equity": 153461.9}, {"date": "2026-04-17", "equity": 152842.7}, {"date": "2026-04-27", "equity": 152334.51}, {"date": "2026-05-05", "equity": 154081.14}, {"date": "2026-05-13", "equity": 157463.5}, {"date": "2026-05-21", "equity": 156619.6}, {"date": "2026-06-01", "equity": 156820.9}, {"date": "2026-06-09", "equity": 155515.41}, {"date": "2026-06-17", "equity": 154900.69}, {"date": "2026-06-26", "equity": 159479.19}, {"date": "2026-07-08", "equity": 161399.55}, {"date": "2026-07-16", "equity": 164608.6}, {"date": "2026-07-24", "equity": 163815.82}, {"date": "2026-08-03", "equity": 163156.25}, {"date": "2026-08-11", "equity": 164128.63}, {"date": "2026-08-19", "equity": 164222.64}, {"date": "2026-08-27", "equity": 163724.41}, {"date": "2026-09-04", "equity": 162592.18}, {"date": "2026-09-15", "equity": 162350.34}, {"date": "2026-09-23", "equity": 162375.91}, {"date": "2026-10-01", "equity": 162575.32}]'::jsonb,'[{"pnl": -914.94, "symbol": "MSFT", "exitDate": "2024-12-27", "quantity": 39, "entryDate": "2024-12-17", "exitPrice": 424.79, "returnPct": -5.23, "entryPrice": 448.25, "exitReason": "trailing stop"}, {"pnl": 666.52, "symbol": "AAPL", "exitDate": "2025-01-02", "quantity": 76, "entryDate": "2024-11-26", "exitPrice": 242.06, "returnPct": 3.76, "entryPrice": 233.29, "exitReason": "trailing stop"}, {"pnl": 127.28, "symbol": "MA", "exitDate": "2025-01-06", "quantity": 37, "entryDate": "2024-11-01", "exitPrice": 506.36, "returnPct": 0.68, "entryPrice": 502.92, "exitReason": "trailing stop"}, {"pnl": 1585.08, "symbol": "V", "exitDate": "2025-01-13", "quantity": 63, "entryDate": "2024-10-25", "exitPrice": 302.72, "returnPct": 9.06, "entryPrice": 277.56, "exitReason": "trailing stop"}, {"pnl": -1237.2, "symbol": "MSFT", "exitDate": "2025-01-30", "quantity": 40, "entryDate": "2025-01-22", "exitPrice": 409.19, "returnPct": -7.03, "entryPrice": 440.12, "exitReason": "trailing stop"}, {"pnl": 183.6, "symbol": "GOOGL", "exitDate": "2025-02-05", "quantity": 108, "entryDate": "2024-12-13", "exitPrice": 190.37, "returnPct": 0.9, "entryPrice": 188.67, "exitReason": "trailing stop"}, {"pnl": -820.8, "symbol": "HD", "exitDate": "2025-02-19", "quantity": 45, "entryDate": "2025-01-30", "exitPrice": 377.57, "returnPct": -4.61, "entryPrice": 395.81, "exitReason": "trailing stop"}, {"pnl": 2044.25, "symbol": "JPM", "exitDate": "2025-02-20", "quantity": 85, "entryDate": "2025-01-03", "exitPrice": 258.94, "returnPct": 10.24, "entryPrice": 234.89, "exitReason": "trailing stop"}, {"pnl": 1072.36, "symbol": "COST", "exitDate": "2025-02-27", "quantity": 19, "entryDate": "2025-01-27", "exitPrice": 1012.65, "returnPct": 5.9, "entryPrice": 956.21, "exitReason": "trailing stop"}, {"pnl": 525.69, "symbol": "MA", "exitDate": "2025-03-06", "quantity": 33, "entryDate": "2025-01-24", "exitPrice": 544.65, "returnPct": 3.01, "entryPrice": 528.72, "exitReason": "trailing stop"}, {"pnl": 1643.74, "symbol": "V", "exitDate": "2025-03-06", "quantity": 59, "entryDate": "2025-01-15", "exitPrice": 340.11, "returnPct": 8.92, "entryPrice": 312.25, "exitReason": "trailing stop"}, {"pnl": -1512.72, "symbol": "COST", "exitDate": "2025-03-07", "quantity": 18, "entryDate": "2025-02-28", "exitPrice": 955.53, "returnPct": -8.08, "entryPrice": 1039.57, "exitReason": "trailing stop"}, {"pnl": -1325.94, "symbol": "AAPL", "exitDate": "2025-03-10", "quantity": 77, "entryDate": "2025-02-19", "exitPrice": 226.18, "returnPct": -7.07, "entryPrice": 243.4, "exitReason": "trailing stop"}, {"pnl": -266.42, "symbol": "LLY", "exitDate": "2025-03-10", "quantity": 22, "entryDate": "2025-02-05", "exitPrice": 820.19, "returnPct": -1.46, "entryPrice": 832.3, "exitReason": "trailing stop"}, {"pnl": -1613.04, "symbol": "V", "exitDate": "2025-04-04", "quantity": 52, "entryDate": "2025-03-26", "exitPrice": 309.15, "returnPct": -9.12, "entryPrice": 340.17, "exitReason": "trailing stop"}, {"pnl": -1962.1, "symbol": "UNH", "exitDate": "2025-04-17", "quantity": 35, "entryDate": "2025-03-20", "exitPrice": 436.52, "returnPct": -11.38, "entryPrice": 492.58, "exitReason": "trailing stop"}, {"pnl": -632.38, "symbol": "LLY", "exitDate": "2025-05-01", "quantity": 14, "entryDate": "2025-04-17", "exitPrice": 785.47, "returnPct": -5.44, "entryPrice": 830.64, "exitReason": "trailing stop"}, {"pnl": -674.45, "symbol": "V", "exitDate": "2025-05-23", "quantity": 47, "entryDate": "2025-05-19", "exitPrice": 350.03, "returnPct": -3.94, "entryPrice": 364.38, "exitReason": "trailing stop"}, {"pnl": 60.16, "symbol": "COST", "exitDate": "2025-06-11", "quantity": 16, "entryDate": "2025-04-17", "exitPrice": 989.84, "returnPct": 0.38, "entryPrice": 986.08, "exitReason": "trailing stop"}, {"pnl": -573.87, "symbol": "V", "exitDate": "2025-06-13", "quantity": 47, "entryDate": "2025-06-02", "exitPrice": 349.56, "returnPct": -3.38, "entryPrice": 361.77, "exitReason": "trailing stop"}, {"pnl": -704.41, "symbol": "MA", "exitDate": "2025-06-13", "quantity": 29, "entryDate": "2025-05-19", "exitPrice": 557.67, "returnPct": -4.17, "entryPrice": 581.96, "exitReason": "trailing stop"}, {"pnl": -943.34, "symbol": "GOOGL", "exitDate": "2025-06-20", "quantity": 101, "entryDate": "2025-06-09", "exitPrice": 166.08, "returnPct": -5.32, "entryPrice": 175.42, "exitReason": "trailing stop"}, {"pnl": -942.7, "symbol": "V", "exitDate": "2025-08-01", "quantity": 55, "entryDate": "2025-07-07", "exitPrice": 335.94, "returnPct": -4.85, "entryPrice": 353.08, "exitReason": "trailing stop"}, {"pnl": -914.55, "symbol": "AAPL", "exitDate": "2025-08-01", "quantity": 91, "entryDate": "2025-07-02", "exitPrice": 201.33, "returnPct": -4.75, "entryPrice": 211.38, "exitReason": "trailing stop"}, {"pnl": 2744.82, "symbol": "MSFT", "exitDate": "2025-08-20", "quantity": 39, "entryDate": "2025-05-02", "exitPrice": 500.55, "returnPct": 16.36, "entryPrice": 430.17, "exitReason": "trailing stop"}, {"pnl": 1153.32, "symbol": "AAPL", "exitDate": "2025-09-10", "quantity": 84, "entryDate": "2025-08-06", "exitPrice": 225.98, "returnPct": 6.47, "entryPrice": 212.25, "exitReason": "trailing stop"}, {"pnl": -669.03, "symbol": "MA", "exitDate": "2025-09-23", "quantity": 29, "entryDate": "2025-08-20", "exitPrice": 565.95, "returnPct": -3.92, "entryPrice": 589.02, "exitReason": "trailing stop"}, {"pnl": 1566.51, "symbol": "HD", "exitDate": "2025-09-30", "quantity": 47, "entryDate": "2025-07-01", "exitPrice": 394.09, "returnPct": 9.24, "entryPrice": 360.76, "exitReason": "trailing stop"}, {"pnl": 7113.96, "symbol": "GOOGL", "exitDate": "2025-10-10", "quantity": 108, "entryDate": "2025-06-25", "exitPrice": 235.96, "returnPct": 38.73, "entryPrice": 170.09, "exitReason": "trailing stop"}, {"pnl": 2547.6, "symbol": "JPM", "exitDate": "2025-10-10", "quantity": 66, "entryDate": "2025-05-29", "exitPrice": 296.76, "returnPct": 14.95, "entryPrice": 258.16, "exitReason": "trailing stop"}, {"pnl": 2178.87, "symbol": "UNH", "exitDate": "2025-10-30", "quantity": 59, "entryDate": "2025-09-02", "exitPrice": 335.77, "returnPct": 12.36, "entryPrice": 298.84, "exitReason": "trailing stop"}, {"pnl": -489.6, "symbol": "MSFT", "exitDate": "2025-11-04", "quantity": 36, "entryDate": "2025-10-06", "exitPrice": 510.51, "returnPct": -2.59, "entryPrice": 524.11, "exitReason": "trailing stop"}, {"pnl": -576.64, "symbol": "JPM", "exitDate": "2025-11-17", "quantity": 64, "entryDate": "2025-10-30", "exitPrice": 296.26, "returnPct": -2.95, "entryPrice": 305.27, "exitReason": "trailing stop"}, {"pnl": 4337.11, "symbol": "LLY", "exitDate": "2025-12-04", "quantity": 23, "entryDate": "2025-10-01", "exitPrice": 1009.1, "returnPct": 22.98, "entryPrice": 820.53, "exitReason": "trailing stop"}, {"pnl": 3876.85, "symbol": "GOOGL", "exitDate": "2025-12-17", "quantity": 85, "entryDate": "2025-10-15", "exitPrice": 296.07, "returnPct": 18.21, "entryPrice": 250.46, "exitReason": "trailing stop"}, {"pnl": 4242.22, "symbol": "AAPL", "exitDate": "2025-12-17", "quantity": 94, "entryDate": "2025-09-10", "exitPrice": 271.11, "returnPct": 19.97, "entryPrice": 225.98, "exitReason": "trailing stop"}, {"pnl": -241.92, "symbol": "JPM", "exitDate": "2026-01-13", "quantity": 64, "entryDate": "2025-12-04", "exitPrice": 307.91, "returnPct": -1.21, "entryPrice": 311.69, "exitReason": "trailing stop"}, {"pnl": -798.63, "symbol": "LLY", "exitDate": "2026-01-15", "quantity": 21, "entryDate": "2025-12-19", "exitPrice": 1027.64, "returnPct": -3.57, "entryPrice": 1065.67, "exitReason": "trailing stop"}, {"pnl": 240.48, "symbol": "GOOGL", "exitDate": "2026-02-10", "quantity": 72, "entryDate": "2026-01-02", "exitPrice": 317.97, "returnPct": 1.06, "entryPrice": 314.63, "exitReason": "trailing stop"}, {"pnl": -1647.66, "symbol": "LLY", "exitDate": "2026-03-03", "quantity": 21, "entryDate": "2026-01-22", "exitPrice": 1003.92, "returnPct": -7.25, "entryPrice": 1082.38, "exitReason": "trailing stop"}, {"pnl": -1302.08, "symbol": "HD", "exitDate": "2026-03-05", "quantity": 52, "entryDate": "2026-02-04", "exitPrice": 353.92, "returnPct": -6.61, "entryPrice": 378.96, "exitReason": "trailing stop"}, {"pnl": -320.8, "symbol": "COST", "exitDate": "2026-03-23", "quantity": 20, "entryDate": "2026-01-23", "exitPrice": 962.9, "returnPct": -1.64, "entryPrice": 978.94, "exitReason": "trailing stop"}, {"pnl": -346.72, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 22, "entryDate": "2026-03-31", "exitPrice": 977.65, "returnPct": -1.59, "entryPrice": 993.41, "exitReason": "trailing stop"}, {"pnl": -1032.6, "symbol": "JPM", "exitDate": "2026-05-11", "quantity": 60, "entryDate": "2026-04-20", "exitPrice": 298.47, "returnPct": -5.45, "entryPrice": 315.68, "exitReason": "trailing stop"}, {"pnl": -406.79, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 19, "entryDate": "2026-05-15", "exitPrice": 1026.22, "returnPct": -2.04, "entryPrice": 1047.63, "exitReason": "trailing stop"}, {"pnl": -1317.84, "symbol": "GOOGL", "exitDate": "2026-06-02", "quantity": 57, "entryDate": "2026-04-30", "exitPrice": 361.39, "returnPct": -6.01, "entryPrice": 384.51, "exitReason": "trailing stop"}, {"pnl": -1062.68, "symbol": "V", "exitDate": "2026-06-03", "quantity": 62, "entryDate": "2026-05-20", "exitPrice": 313.05, "returnPct": -5.19, "entryPrice": 330.19, "exitReason": "trailing stop"}, {"pnl": 178.48, "symbol": "MSFT", "exitDate": "2026-06-05", "quantity": 46, "entryDate": "2026-05-04", "exitPrice": 415.85, "returnPct": 0.94, "entryPrice": 411.97, "exitReason": "trailing stop"}, {"pnl": 2016.5, "symbol": "AAPL", "exitDate": "2026-06-09", "quantity": 74, "entryDate": "2026-04-16", "exitPrice": 290.11, "returnPct": 10.37, "entryPrice": 262.86, "exitReason": "trailing stop"}, {"pnl": -237.18, "symbol": "HD", "exitDate": "2026-07-20", "quantity": 59, "entryDate": "2026-06-16", "exitPrice": 330.61, "returnPct": -1.2, "entryPrice": 334.63, "exitReason": "trailing stop"}, {"pnl": 1128.91, "symbol": "AAPL", "exitDate": "2026-07-31", "quantity": 79, "entryDate": "2026-07-01", "exitPrice": 308.46, "returnPct": 4.86, "entryPrice": 294.17, "exitReason": "trailing stop"}, {"pnl": 664.2, "symbol": "LLY", "exitDate": "2026-08-03", "quantity": 18, "entryDate": "2026-05-27", "exitPrice": 1119.58, "returnPct": 3.41, "entryPrice": 1082.68, "exitReason": "trailing stop"}, {"pnl": 3129.84, "symbol": "UNH", "exitDate": "2026-08-11", "quantity": 63, "entryDate": "2026-04-23", "exitPrice": 400.03, "returnPct": 14.18, "entryPrice": 350.35, "exitReason": "trailing stop"}, {"pnl": -699.06, "symbol": "HD", "exitDate": "2026-08-27", "quantity": 61, "entryDate": "2026-08-03", "exitPrice": 326.18, "returnPct": -3.39, "entryPrice": 337.64, "exitReason": "trailing stop"}, {"pnl": -709.27, "symbol": "LLY", "exitDate": "2026-08-28", "quantity": 19, "entryDate": "2026-08-11", "exitPrice": 1173.85, "returnPct": -3.08, "entryPrice": 1211.18, "exitReason": "trailing stop"}, {"pnl": 889.01, "symbol": "MA", "exitDate": "2026-09-08", "quantity": 38, "entryDate": "2026-07-20", "exitPrice": 570.95, "returnPct": 4.27, "entryPrice": 547.55, "exitReason": "trailing stop"}, {"pnl": 2685.21, "symbol": "JPM", "exitDate": "2026-09-14", "quantity": 66, "entryDate": "2026-06-04", "exitPrice": 350.19, "returnPct": 13.15, "entryPrice": 309.5, "exitReason": "trailing stop"}, {"pnl": 2242.56, "symbol": "V", "exitDate": "2026-09-18", "quantity": 64, "entryDate": "2026-06-16", "exitPrice": 367.63, "returnPct": 10.54, "entryPrice": 332.59, "exitReason": "trailing stop"}, {"pnl": 2444, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 50, "entryDate": "2026-07-31", "exitPrice": 512.71, "returnPct": 10.54, "entryPrice": 463.83, "exitReason": "end of test"}, {"pnl": 326.97, "symbol": "AAPL", "exitDate": "2026-10-01", "quantity": 63, "entryDate": "2026-09-01", "exitPrice": 330.44, "returnPct": 1.6, "entryPrice": 325.25, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:24.073489+00:00') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('0029ea19-8f5b-4797-85f3-33d098276ea3','2ba53985-f9b0-4575-924a-ee074b9eeb12',NULL,'2021-06-01','2026-10-01',100000.0,'complete',42.286,38.64,-10.225,0.822,176,'[{"date": "2021-06-01", "equity": 100000}, {"date": "2021-06-09", "equity": 99878.66}, {"date": "2021-06-17", "equity": 99249.68}, {"date": "2021-06-25", "equity": 99957.52}, {"date": "2021-07-06", "equity": 100712.9}, {"date": "2021-07-14", "equity": 102912.52}, {"date": "2021-07-22", "equity": 103386.71}, {"date": "2021-07-30", "equity": 105180.49}, {"date": "2021-08-09", "equity": 106166.97}, {"date": "2021-08-17", "equity": 108264.42}, {"date": "2021-08-25", "equity": 106806.12}, {"date": "2021-09-03", "equity": 107017.42}, {"date": "2021-09-14", "equity": 105002.89}, {"date": "2021-09-22", "equity": 103621.4}, {"date": "2021-09-30", "equity": 101041.48}, {"date": "2021-10-08", "equity": 103003.98}, {"date": "2021-10-18", "equity": 104294.66}, {"date": "2021-10-26", "equity": 105840.65}, {"date": "2021-11-03", "equity": 109240.47}, {"date": "2021-11-11", "equity": 109313.24}, {"date": "2021-11-19", "equity": 110917.07}, {"date": "2021-12-01", "equity": 108460.01}, {"date": "2021-12-09", "equity": 111022.39}, {"date": "2021-12-17", "equity": 112126.16}, {"date": "2021-12-28", "equity": 114620.84}, {"date": "2022-01-05", "equity": 114752.83}, {"date": "2022-01-13", "equity": 114065.59}, {"date": "2022-01-24", "equity": 110922.76}, {"date": "2022-02-01", "equity": 111564.61}, {"date": "2022-02-09", "equity": 113001.27}, {"date": "2022-02-17", "equity": 111148.7}, {"date": "2022-02-28", "equity": 110885.63}, {"date": "2022-03-09", "equity": 110435.54}, {"date": "2022-03-17", "equity": 112521.83}, {"date": "2022-03-25", "equity": 113953.71}, {"date": "2022-04-04", "equity": 114092.08}, {"date": "2022-04-12", "equity": 115217.48}, {"date": "2022-04-21", "equity": 115720.97}, {"date": "2022-04-29", "equity": 114528.23}, {"date": "2022-05-09", "equity": 114145.17}, {"date": "2022-05-17", "equity": 114145.17}, {"date": "2022-05-25", "equity": 114145.17}, {"date": "2022-06-06", "equity": 114145.17}, {"date": "2022-06-14", "equity": 114145.17}, {"date": "2022-06-23", "equity": 114145.17}, {"date": "2022-07-01", "equity": 114145.17}, {"date": "2022-07-12", "equity": 114145.17}, {"date": "2022-07-20", "equity": 114145.17}, {"date": "2022-07-28", "equity": 114145.17}, {"date": "2022-08-05", "equity": 114145.17}, {"date": "2022-08-15", "equity": 114145.17}, {"date": "2022-08-23", "equity": 114145.17}, {"date": "2022-08-31", "equity": 114145.17}, {"date": "2022-09-12", "equity": 114145.17}, {"date": "2022-09-20", "equity": 114145.17}, {"date": "2022-09-28", "equity": 114145.17}, {"date": "2022-10-06", "equity": 114145.17}, {"date": "2022-10-14", "equity": 114145.17}, {"date": "2022-10-24", "equity": 114145.17}, {"date": "2022-11-01", "equity": 114145.17}, {"date": "2022-11-09", "equity": 114145.17}, {"date": "2022-11-17", "equity": 114145.17}, {"date": "2022-11-28", "equity": 114145.17}, {"date": "2022-12-07", "equity": 113953.17}, {"date": "2022-12-15", "equity": 113086.51}, {"date": "2022-12-23", "equity": 112732.51}, {"date": "2023-01-04", "equity": 113279.91}, {"date": "2023-01-12", "equity": 113215.47}, {"date": "2023-01-23", "equity": 109225.05}, {"date": "2023-01-31", "equity": 109731.91}, {"date": "2023-02-08", "equity": 108038.45}, {"date": "2023-02-16", "equity": 108260.44}, {"date": "2023-02-27", "equity": 106949.37}, {"date": "2023-03-07", "equity": 107562.1}, {"date": "2023-03-16", "equity": 108028.14}, {"date": "2023-03-24", "equity": 108316.56}, {"date": "2023-04-03", "equity": 109452.33}, {"date": "2023-04-12", "equity": 109103.37}, {"date": "2023-04-20", "equity": 109845.54}, {"date": "2023-04-28", "equity": 111115.56}, {"date": "2023-05-08", "equity": 110577.69}, {"date": "2023-05-16", "equity": 110927.26}, {"date": "2023-05-24", "equity": 108018.52}, {"date": "2023-06-02", "equity": 110414.41}, {"date": "2023-06-13", "equity": 110972.18}, {"date": "2023-06-22", "equity": 112814.38}, {"date": "2023-06-30", "equity": 113497.83}, {"date": "2023-07-11", "equity": 112085.09}, {"date": "2023-07-19", "equity": 114032.67}, {"date": "2023-07-27", "equity": 113865.18}, {"date": "2023-08-04", "equity": 113824.23}, {"date": "2023-08-14", "equity": 114660}, {"date": "2023-08-22", "equity": 112494.28}, {"date": "2023-08-30", "equity": 114114.56}, {"date": "2023-09-08", "equity": 114695.97}, {"date": "2023-09-19", "equity": 114783.44}, {"date": "2023-09-27", "equity": 112159.92}, {"date": "2023-10-05", "equity": 111723.19}, {"date": "2023-10-13", "equity": 112019.07}, {"date": "2023-10-23", "equity": 110718.34}, {"date": "2023-10-31", "equity": 110753.95}, {"date": "2023-11-08", "equity": 111206.53}, {"date": "2023-11-16", "equity": 110623.53}, {"date": "2023-11-27", "equity": 111113.95}, {"date": "2023-12-05", "equity": 111431.08}, {"date": "2023-12-14", "equity": 111938.24}, {"date": "2023-12-22", "equity": 113608.32}, {"date": "2024-01-03", "equity": 113020.1}, {"date": "2024-01-11", "equity": 115192.54}, {"date": "2024-01-22", "equity": 117339.83}, {"date": "2024-01-30", "equity": 118580.66}, {"date": "2024-02-07", "equity": 119015.86}, {"date": "2024-02-15", "equity": 119197.51}, {"date": "2024-02-26", "equity": 121223.07}, {"date": "2024-03-05", "equity": 120556.05}, {"date": "2024-03-13", "equity": 120502.84}, {"date": "2024-03-22", "equity": 120936.11}, {"date": "2024-04-02", "equity": 119603.23}, {"date": "2024-04-10", "equity": 119248.7}, {"date": "2024-04-18", "equity": 116776.98}, {"date": "2024-04-26", "equity": 118347.63}, {"date": "2024-05-06", "equity": 118434.95}, {"date": "2024-05-14", "equity": 119857.98}, {"date": "2024-05-22", "equity": 122830.72}, {"date": "2024-05-31", "equity": 122752.05}, {"date": "2024-06-10", "equity": 124184.3}, {"date": "2024-06-20", "equity": 124651.58}, {"date": "2024-06-28", "equity": 124188.3}, {"date": "2024-07-09", "equity": 126060.77}, {"date": "2024-07-17", "equity": 128313.2}, {"date": "2024-07-25", "equity": 125908.96}, {"date": "2024-08-02", "equity": 125423.83}, {"date": "2024-08-12", "equity": 125815.77}, {"date": "2024-08-20", "equity": 129391.47}, {"date": "2024-08-28", "equity": 132045.05}, {"date": "2024-09-06", "equity": 131939.6}, {"date": "2024-09-16", "equity": 134890.08}, {"date": "2024-09-25", "equity": 133179.69}, {"date": "2024-10-03", "equity": 131552.29}, {"date": "2024-10-11", "equity": 132006.13}, {"date": "2024-10-21", "equity": 132533.42}, {"date": "2024-10-29", "equity": 130574.31}, {"date": "2024-11-06", "equity": 131264.86}, {"date": "2024-11-14", "equity": 131691.33}, {"date": "2024-11-22", "equity": 135118.76}, {"date": "2024-12-03", "equity": 136496}, {"date": "2024-12-11", "equity": 137177.87}, {"date": "2024-12-20", "equity": 134828.9}, {"date": "2024-12-31", "equity": 132836.8}, {"date": "2025-01-10", "equity": 132025.6}, {"date": "2025-01-21", "equity": 134010.78}, {"date": "2025-01-29", "equity": 137252.14}, {"date": "2025-02-06", "equity": 140354.36}, {"date": "2025-02-14", "equity": 141761.78}, {"date": "2025-02-25", "equity": 140062.84}, {"date": "2025-03-05", "equity": 139445.89}, {"date": "2025-03-13", "equity": 133660.98}, {"date": "2025-03-21", "equity": 134194.98}, {"date": "2025-04-01", "equity": 134452.92}, {"date": "2025-04-09", "equity": 130681.89}, {"date": "2025-04-17", "equity": 130681.89}, {"date": "2025-04-28", "equity": 130681.89}, {"date": "2025-05-06", "equity": 130681.89}, {"date": "2025-05-14", "equity": 129882.51}, {"date": "2025-05-22", "equity": 130913.92}, {"date": "2025-06-02", "equity": 131998.64}, {"date": "2025-06-10", "equity": 130261.01}, {"date": "2025-06-18", "equity": 127970.63}, {"date": "2025-06-30", "equity": 130090.92}, {"date": "2025-07-09", "equity": 129582.36}, {"date": "2025-07-17", "equity": 129029.29}, {"date": "2025-07-25", "equity": 129916.33}, {"date": "2025-08-04", "equity": 129378.69}, {"date": "2025-08-12", "equity": 130481.8}, {"date": "2025-08-20", "equity": 131132.73}, {"date": "2025-08-28", "equity": 130105.24}, {"date": "2025-09-08", "equity": 130074.75}, {"date": "2025-09-16", "equity": 130109.86}, {"date": "2025-09-24", "equity": 130403.92}, {"date": "2025-10-03", "equity": 132533.27}, {"date": "2025-10-13", "equity": 133152.05}, {"date": "2025-10-21", "equity": 134529.4}, {"date": "2025-10-29", "equity": 132174.78}, {"date": "2025-11-06", "equity": 130038.42}, {"date": "2025-11-14", "equity": 131603.56}, {"date": "2025-11-24", "equity": 131669.12}, {"date": "2025-12-03", "equity": 134170.31}, {"date": "2025-12-11", "equity": 134713.96}, {"date": "2025-12-19", "equity": 134273.17}, {"date": "2025-12-31", "equity": 133331.32}, {"date": "2026-01-09", "equity": 132688.88}, {"date": "2026-01-20", "equity": 134696.37}, {"date": "2026-01-28", "equity": 136296.17}, {"date": "2026-02-05", "equity": 141970.89}, {"date": "2026-02-13", "equity": 144350.62}, {"date": "2026-02-24", "equity": 143513.2}, {"date": "2026-03-04", "equity": 142510.09}, {"date": "2026-03-12", "equity": 140732.78}, {"date": "2026-03-20", "equity": 135622.84}, {"date": "2026-03-30", "equity": 138214.79}, {"date": "2026-04-09", "equity": 139449.25}, {"date": "2026-04-17", "equity": 137323.84}, {"date": "2026-04-27", "equity": 134319.59}, {"date": "2026-05-05", "equity": 135945.9}, {"date": "2026-05-13", "equity": 136554.79}, {"date": "2026-05-21", "equity": 137358.29}, {"date": "2026-06-01", "equity": 135329.38}, {"date": "2026-06-09", "equity": 137479.12}, {"date": "2026-06-17", "equity": 136589.61}, {"date": "2026-06-26", "equity": 139054.52}, {"date": "2026-07-08", "equity": 139853.37}, {"date": "2026-07-16", "equity": 139107.63}, {"date": "2026-07-24", "equity": 139885.79}, {"date": "2026-08-03", "equity": 141476.97}, {"date": "2026-08-11", "equity": 141922.03}, {"date": "2026-08-19", "equity": 143986.05}, {"date": "2026-08-27", "equity": 144002.97}, {"date": "2026-09-04", "equity": 144426.63}, {"date": "2026-09-15", "equity": 144576.9}, {"date": "2026-09-23", "equity": 143346.37}, {"date": "2026-10-01", "equity": 142285.69}]'::jsonb,'[{"pnl": -653.5, "symbol": "MSFT", "exitDate": "2025-01-30", "quantity": 50, "entryDate": "2025-01-06", "exitPrice": 409.19, "returnPct": -3.1, "entryPrice": 422.26, "exitReason": "trailing stop"}, {"pnl": 2179.32, "symbol": "WMT", "exitDate": "2025-02-20", "quantity": 286, "entryDate": "2024-12-23", "exitPrice": 95.68, "returnPct": 8.65, "entryPrice": 88.06, "exitReason": "trailing stop"}, {"pnl": 2679.6, "symbol": "COST", "exitDate": "2025-02-27", "quantity": 24, "entryDate": "2025-01-02", "exitPrice": 1012.65, "returnPct": 12.39, "entryPrice": 901, "exitReason": "trailing stop"}, {"pnl": 2916.42, "symbol": "V", "exitDate": "2025-03-06", "quantity": 78, "entryDate": "2025-01-13", "exitPrice": 340.11, "returnPct": 12.35, "entryPrice": 302.72, "exitReason": "trailing stop"}, {"pnl": -1313.76, "symbol": "COST", "exitDate": "2025-03-07", "quantity": 23, "entryDate": "2025-02-27", "exitPrice": 955.53, "returnPct": -5.64, "entryPrice": 1012.65, "exitReason": "trailing stop"}, {"pnl": -1779.33, "symbol": "WMT", "exitDate": "2025-03-10", "quantity": 259, "entryDate": "2025-02-21", "exitPrice": 86.43, "returnPct": -7.36, "entryPrice": 93.3, "exitReason": "trailing stop"}, {"pnl": -1593.6, "symbol": "JNJ", "exitDate": "2025-04-01", "quantity": 166, "entryDate": "2025-03-24", "exitPrice": 147.51, "returnPct": -6.11, "entryPrice": 157.11, "exitReason": "trailing stop"}, {"pnl": -2322, "symbol": "V", "exitDate": "2025-04-04", "quantity": 75, "entryDate": "2025-03-06", "exitPrice": 309.15, "returnPct": -9.1, "entryPrice": 340.11, "exitReason": "trailing stop"}, {"pnl": -205.74, "symbol": "KO", "exitDate": "2025-04-07", "quantity": 381, "entryDate": "2025-03-24", "exitPrice": 65.6, "returnPct": -0.82, "entryPrice": 66.14, "exitReason": "trailing stop"}, {"pnl": -915.04, "symbol": "BRK.B", "exitDate": "2025-06-04", "quantity": 43, "entryDate": "2025-05-13", "exitPrice": 490.99, "returnPct": -4.15, "entryPrice": 512.27, "exitReason": "trailing stop"}, {"pnl": -188.94, "symbol": "MCD", "exitDate": "2025-06-06", "quantity": 67, "entryDate": "2025-05-12", "exitPrice": 297.91, "returnPct": -0.94, "entryPrice": 300.73, "exitReason": "trailing stop"}, {"pnl": -220.5, "symbol": "WMT", "exitDate": "2025-06-12", "quantity": 210, "entryDate": "2025-05-22", "exitPrice": 93.82, "returnPct": -1.11, "entryPrice": 94.87, "exitReason": "trailing stop"}, {"pnl": -758.8, "symbol": "MCD", "exitDate": "2025-06-16", "quantity": 70, "entryDate": "2025-06-06", "exitPrice": 287.07, "returnPct": -3.64, "entryPrice": 297.91, "exitReason": "trailing stop"}, {"pnl": 42.28, "symbol": "KO", "exitDate": "2025-06-18", "quantity": 302, "entryDate": "2025-05-12", "exitPrice": 66.9, "returnPct": 0.21, "entryPrice": 66.76, "exitReason": "trailing stop"}, {"pnl": -120.79, "symbol": "WMT", "exitDate": "2025-07-11", "quantity": 257, "entryDate": "2025-06-12", "exitPrice": 93.35, "returnPct": -0.5, "entryPrice": 93.82, "exitReason": "trailing stop"}, {"pnl": -894.72, "symbol": "COST", "exitDate": "2025-07-15", "quantity": 24, "entryDate": "2025-06-09", "exitPrice": 961.13, "returnPct": -3.73, "entryPrice": 998.41, "exitReason": "trailing stop"}, {"pnl": -683, "symbol": "COST", "exitDate": "2025-07-28", "quantity": 20, "entryDate": "2025-07-15", "exitPrice": 926.98, "returnPct": -3.55, "entryPrice": 961.13, "exitReason": "trailing stop"}, {"pnl": -317.79, "symbol": "KO", "exitDate": "2025-07-28", "quantity": 297, "entryDate": "2025-06-18", "exitPrice": 65.83, "returnPct": -1.6, "entryPrice": 66.9, "exitReason": "trailing stop"}, {"pnl": -253.65, "symbol": "V", "exitDate": "2025-08-01", "quantity": 57, "entryDate": "2025-06-23", "exitPrice": 335.94, "returnPct": -1.31, "entryPrice": 340.39, "exitReason": "trailing stop"}, {"pnl": 516, "symbol": "WMT", "exitDate": "2025-08-21", "quantity": 215, "entryDate": "2025-07-14", "exitPrice": 97.14, "returnPct": 2.53, "entryPrice": 94.74, "exitReason": "trailing stop"}, {"pnl": -997.02, "symbol": "PEP", "exitDate": "2025-09-26", "quantity": 174, "entryDate": "2025-09-05", "exitPrice": 134.95, "returnPct": -4.07, "entryPrice": 140.68, "exitReason": "trailing stop"}, {"pnl": -661.64, "symbol": "MCD", "exitDate": "2025-10-06", "quantity": 68, "entryDate": "2025-09-10", "exitPrice": 288.61, "returnPct": -3.26, "entryPrice": 298.34, "exitReason": "trailing stop"}, {"pnl": -201.52, "symbol": "V", "exitDate": "2025-10-16", "quantity": 44, "entryDate": "2025-09-16", "exitPrice": 332.8, "returnPct": -1.36, "entryPrice": 337.38, "exitReason": "trailing stop"}, {"pnl": -794.21, "symbol": "BRK.B", "exitDate": "2025-10-29", "quantity": 43, "entryDate": "2025-10-20", "exitPrice": 475.67, "returnPct": -3.74, "entryPrice": 494.14, "exitReason": "trailing stop"}, {"pnl": 938.4, "symbol": "WMT", "exitDate": "2025-10-29", "quantity": 204, "entryDate": "2025-09-02", "exitPrice": 101.62, "returnPct": 4.74, "entryPrice": 97.02, "exitReason": "trailing stop"}, {"pnl": 892.16, "symbol": "PEP", "exitDate": "2025-10-31", "quantity": 164, "entryDate": "2025-09-30", "exitPrice": 140.41, "returnPct": 4.03, "entryPrice": 134.97, "exitReason": "trailing stop"}, {"pnl": 4488.77, "symbol": "JNJ", "exitDate": "2025-11-03", "quantity": 143, "entryDate": "2025-07-07", "exitPrice": 182.12, "returnPct": 20.83, "entryPrice": 150.73, "exitReason": "trailing stop"}, {"pnl": 488.04, "symbol": "MSFT", "exitDate": "2025-11-04", "quantity": 49, "entryDate": "2025-08-20", "exitPrice": 510.51, "returnPct": 1.99, "entryPrice": 500.55, "exitReason": "trailing stop"}, {"pnl": -701.1, "symbol": "V", "exitDate": "2025-11-14", "quantity": 41, "entryDate": "2025-10-27", "exitPrice": 328.03, "returnPct": -4.95, "entryPrice": 345.13, "exitReason": "trailing stop"}, {"pnl": -1480.44, "symbol": "MSFT", "exitDate": "2025-11-21", "quantity": 39, "entryDate": "2025-11-12", "exitPrice": 469.21, "returnPct": -7.48, "entryPrice": 507.17, "exitReason": "trailing stop"}, {"pnl": -144.53, "symbol": "PEP", "exitDate": "2025-12-23", "quantity": 149, "entryDate": "2025-10-31", "exitPrice": 139.44, "returnPct": -0.69, "entryPrice": 140.41, "exitReason": "trailing stop"}, {"pnl": 1958.16, "symbol": "WMT", "exitDate": "2025-12-31", "quantity": 199, "entryDate": "2025-11-06", "exitPrice": 110.7, "returnPct": 9.76, "entryPrice": 100.86, "exitReason": "trailing stop"}, {"pnl": -637, "symbol": "KO", "exitDate": "2026-01-05", "quantity": 325, "entryDate": "2025-12-05", "exitPrice": 66.68, "returnPct": -2.86, "entryPrice": 68.64, "exitReason": "trailing stop"}, {"pnl": 2385.18, "symbol": "JNJ", "exitDate": "2026-01-05", "quantity": 126, "entryDate": "2025-11-03", "exitPrice": 201.05, "returnPct": 10.39, "entryPrice": 182.12, "exitReason": "trailing stop"}, {"pnl": -711.45, "symbol": "PEP", "exitDate": "2026-01-06", "quantity": 155, "entryDate": "2025-12-23", "exitPrice": 134.85, "returnPct": -3.29, "entryPrice": 139.44, "exitReason": "trailing stop"}, {"pnl": -749.28, "symbol": "BRK.B", "exitDate": "2026-01-20", "quantity": 42, "entryDate": "2025-12-04", "exitPrice": 485.46, "returnPct": -3.54, "entryPrice": 503.3, "exitReason": "trailing stop"}, {"pnl": 2467.42, "symbol": "WMT", "exitDate": "2026-02-20", "quantity": 214, "entryDate": "2025-12-31", "exitPrice": 122.23, "returnPct": 10.42, "entryPrice": 110.7, "exitReason": "trailing stop"}, {"pnl": 2415, "symbol": "KO", "exitDate": "2026-03-05", "quantity": 322, "entryDate": "2026-01-08", "exitPrice": 75.53, "returnPct": 11.02, "entryPrice": 68.03, "exitReason": "trailing stop"}, {"pnl": -1485.8, "symbol": "PEP", "exitDate": "2026-03-18", "quantity": 170, "entryDate": "2026-03-04", "exitPrice": 150.31, "returnPct": -5.5, "entryPrice": 159.05, "exitReason": "trailing stop"}, {"pnl": 3873.2, "symbol": "JNJ", "exitDate": "2026-03-18", "quantity": 115, "entryDate": "2026-01-05", "exitPrice": 234.73, "returnPct": 16.75, "entryPrice": 201.05, "exitReason": "trailing stop"}, {"pnl": 676.28, "symbol": "MCD", "exitDate": "2026-03-18", "quantity": 58, "entryDate": "2025-12-31", "exitPrice": 311.38, "returnPct": 3.89, "entryPrice": 299.72, "exitReason": "trailing stop"}, {"pnl": -1887.6, "symbol": "WMT", "exitDate": "2026-03-20", "quantity": 220, "entryDate": "2026-02-27", "exitPrice": 118.51, "returnPct": -6.75, "entryPrice": 127.09, "exitReason": "trailing stop"}, {"pnl": -14.82, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 13, "entryDate": "2026-03-05", "exitPrice": 977.65, "returnPct": -0.12, "entryPrice": 978.79, "exitReason": "trailing stop"}, {"pnl": -733.37, "symbol": "JNJ", "exitDate": "2026-04-20", "quantity": 113, "entryDate": "2026-03-18", "exitPrice": 228.24, "returnPct": -2.76, "entryPrice": 234.73, "exitReason": "trailing stop"}, {"pnl": -1152.9, "symbol": "MCD", "exitDate": "2026-04-27", "quantity": 70, "entryDate": "2026-04-08", "exitPrice": 286.3, "returnPct": -5.44, "entryPrice": 302.77, "exitReason": "trailing stop"}, {"pnl": -604.94, "symbol": "PEP", "exitDate": "2026-05-11", "quantity": 149, "entryDate": "2026-03-18", "exitPrice": 146.25, "returnPct": -2.7, "entryPrice": 150.31, "exitReason": "trailing stop"}, {"pnl": 689.48, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 22, "entryDate": "2026-04-27", "exitPrice": 1026.22, "returnPct": 3.15, "entryPrice": 994.88, "exitReason": "trailing stop"}, {"pnl": 717.81, "symbol": "KO", "exitDate": "2026-06-01", "quantity": 337, "entryDate": "2026-03-05", "exitPrice": 77.66, "returnPct": 2.82, "entryPrice": 75.53, "exitReason": "trailing stop"}, {"pnl": -984.9, "symbol": "COST", "exitDate": "2026-06-30", "quantity": 21, "entryDate": "2026-06-12", "exitPrice": 933.86, "returnPct": -4.78, "entryPrice": 980.76, "exitReason": "trailing stop"}, {"pnl": 1770.53, "symbol": "JNJ", "exitDate": "2026-07-15", "quantity": 101, "entryDate": "2026-04-20", "exitPrice": 245.77, "returnPct": 7.68, "entryPrice": 228.24, "exitReason": "trailing stop"}, {"pnl": 601.22, "symbol": "BRK.B", "exitDate": "2026-08-14", "quantity": 46, "entryDate": "2026-07-17", "exitPrice": 503.95, "returnPct": 2.66, "entryPrice": 490.88, "exitReason": "trailing stop"}, {"pnl": -664.24, "symbol": "PG", "exitDate": "2026-08-20", "quantity": 152, "entryDate": "2026-07-08", "exitPrice": 142.94, "returnPct": -2.97, "entryPrice": 147.31, "exitReason": "trailing stop"}, {"pnl": 2785.56, "symbol": "KO", "exitDate": "2026-09-01", "quantity": 278, "entryDate": "2026-06-02", "exitPrice": 87.49, "returnPct": 12.93, "entryPrice": 77.47, "exitReason": "trailing stop"}, {"pnl": 1276.8, "symbol": "V", "exitDate": "2026-09-18", "quantity": 76, "entryDate": "2026-07-23", "exitPrice": 367.63, "returnPct": 4.79, "entryPrice": 350.83, "exitReason": "trailing stop"}, {"pnl": 172.96, "symbol": "BRK.B", "exitDate": "2026-09-21", "quantity": 46, "entryDate": "2026-08-17", "exitPrice": 502.09, "returnPct": 0.75, "entryPrice": 498.33, "exitReason": "trailing stop"}, {"pnl": 1129.14, "symbol": "JNJ", "exitDate": "2026-10-01", "quantity": 102, "entryDate": "2026-07-20", "exitPrice": 258.7, "returnPct": 4.47, "entryPrice": 247.63, "exitReason": "trailing stop"}, {"pnl": -265.08, "symbol": "KO", "exitDate": "2026-10-01", "quantity": 282, "entryDate": "2026-09-09", "exitPrice": 86.12, "returnPct": -1.08, "entryPrice": 87.06, "exitReason": "end of test"}, {"pnl": 1098.16, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 56, "entryDate": "2026-09-18", "exitPrice": 512.71, "returnPct": 3.98, "entryPrice": 493.1, "exitReason": "end of test"}, {"pnl": -553.68, "symbol": "V", "exitDate": "2026-10-01", "quantity": 72, "entryDate": "2026-09-18", "exitPrice": 359.94, "returnPct": -2.09, "entryPrice": 367.63, "exitReason": "end of test"}, {"pnl": 0, "symbol": "BRK.B", "exitDate": "2026-10-01", "quantity": 44, "entryDate": "2026-10-01", "exitPrice": 500.67, "returnPct": 0, "entryPrice": 500.67, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:26.541188+00:00') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.backtests (id,strategy_id,created_by,start_date,end_date,starting_capital,status,total_return_pct,win_rate,max_drawdown_pct,sharpe,trade_count,equity_curve,trades,notes,error,created_at) VALUES ('758dc931-7a5f-413e-8400-3d56e810388d','2ba53985-f9b0-4575-924a-ee074b9eeb12',NULL,'2025-10-01','2026-10-01',100000.0,'complete',7.357,45.71,-7.206,0.822,35,'[{"date": "2025-10-01", "equity": 100000}, {"date": "2025-10-02", "equity": 99920.8}, {"date": "2025-10-03", "equity": 100035.75}, {"date": "2025-10-06", "equity": 99866.35}, {"date": "2025-10-07", "equity": 99975.25}, {"date": "2025-10-08", "equity": 99820.15}, {"date": "2025-10-09", "equity": 99597.4}, {"date": "2025-10-13", "equity": 99996.7}, {"date": "2025-10-14", "equity": 101077.45}, {"date": "2025-10-15", "equity": 101411.85}, {"date": "2025-10-16", "equity": 100988.9}, {"date": "2025-10-17", "equity": 101345.3}, {"date": "2025-10-20", "equity": 101214.4}, {"date": "2025-10-21", "equity": 100976.98}, {"date": "2025-10-23", "equity": 101012.15}, {"date": "2025-10-24", "equity": 100902.31}, {"date": "2025-10-27", "equity": 100719.63}, {"date": "2025-10-28", "equity": 100064.24}, {"date": "2025-10-29", "equity": 99240.72}, {"date": "2025-10-30", "equity": 99674.24}, {"date": "2025-10-31", "equity": 99084.74}, {"date": "2025-11-04", "equity": 98480.72}, {"date": "2025-11-05", "equity": 98395.63}, {"date": "2025-11-06", "equity": 98196.79}, {"date": "2025-11-07", "equity": 98410.94}, {"date": "2025-11-10", "equity": 98457.28}, {"date": "2025-11-11", "equity": 99619.5}, {"date": "2025-11-12", "equity": 99624.91}, {"date": "2025-11-14", "equity": 99345.15}, {"date": "2025-11-17", "equity": 99919.13}, {"date": "2025-11-18", "equity": 99434.82}, {"date": "2025-11-19", "equity": 99168.89}, {"date": "2025-11-20", "equity": 99846.05}, {"date": "2025-11-21", "equity": 99508.86}, {"date": "2025-11-24", "equity": 99409.83}, {"date": "2025-11-26", "equity": 100730.43}, {"date": "2025-11-28", "equity": 100956.41}, {"date": "2025-12-01", "equity": 101076.94}, {"date": "2025-12-02", "equity": 101081.07}, {"date": "2025-12-03", "equity": 101314.38}, {"date": "2025-12-04", "equity": 100960.11}, {"date": "2025-12-05", "equity": 100925.9}, {"date": "2025-12-09", "equity": 100304.42}, {"date": "2025-12-10", "equity": 101237.04}, {"date": "2025-12-11", "equity": 101755.53}, {"date": "2025-12-12", "equity": 102775.22}, {"date": "2025-12-15", "equity": 103444.82}, {"date": "2025-12-16", "equity": 102283.88}, {"date": "2025-12-17", "equity": 102632.86}, {"date": "2025-12-19", "equity": 101403.53}, {"date": "2025-12-22", "equity": 101248.99}, {"date": "2025-12-23", "equity": 100401.88}, {"date": "2025-12-24", "equity": 100794.59}, {"date": "2025-12-26", "equity": 100648.72}, {"date": "2025-12-29", "equity": 100965.95}, {"date": "2025-12-31", "equity": 100669.09}, {"date": "2026-01-02", "equity": 100286.23}, {"date": "2026-01-05", "equity": 99367.93}, {"date": "2026-01-06", "equity": 99703.38}, {"date": "2026-01-07", "equity": 99632.84}, {"date": "2026-01-08", "equity": 99851.39}, {"date": "2026-01-09", "equity": 100170.2}, {"date": "2026-01-13", "equity": 102027.58}, {"date": "2026-01-14", "equity": 102370.97}, {"date": "2026-01-15", "equity": 102050.77}, {"date": "2026-01-16", "equity": 102043.85}, {"date": "2026-01-20", "equity": 101698.21}, {"date": "2026-01-21", "equity": 101960.51}, {"date": "2026-01-22", "equity": 101750.43}, {"date": "2026-01-26", "equity": 102404.05}, {"date": "2026-01-27", "equity": 102822.8}, {"date": "2026-01-28", "equity": 102879.19}, {"date": "2026-01-29", "equity": 103151.04}, {"date": "2026-01-30", "equity": 103776.45}, {"date": "2026-02-02", "equity": 105122.28}, {"date": "2026-02-03", "equity": 106314.71}, {"date": "2026-02-05", "equity": 107140.02}, {"date": "2026-02-06", "equity": 108281.4}, {"date": "2026-02-09", "equity": 107491.61}, {"date": "2026-02-10", "equity": 106852.51}, {"date": "2026-02-11", "equity": 107697.82}, {"date": "2026-02-12", "equity": 109255.39}, {"date": "2026-02-13", "equity": 108929.67}, {"date": "2026-02-18", "equity": 108098.72}, {"date": "2026-02-19", "equity": 107804.2}, {"date": "2026-02-20", "equity": 107447.01}, {"date": "2026-02-23", "equity": 108129.88}, {"date": "2026-02-24", "equity": 108276.78}, {"date": "2026-02-25", "equity": 108101.52}, {"date": "2026-02-26", "equity": 108011.56}, {"date": "2026-03-02", "equity": 108253.92}, {"date": "2026-03-03", "equity": 108002.96}, {"date": "2026-03-04", "equity": 107519.78}, {"date": "2026-03-05", "equity": 105486.44}, {"date": "2026-03-06", "equity": 105885.5}, {"date": "2026-03-09", "equity": 106782.95}, {"date": "2026-03-10", "equity": 106735.83}, {"date": "2026-03-12", "equity": 106225.22}, {"date": "2026-03-13", "equity": 106730.67}, {"date": "2026-03-16", "equity": 106579.72}, {"date": "2026-03-17", "equity": 105702.26}, {"date": "2026-03-18", "equity": 103719.28}, {"date": "2026-03-19", "equity": 103364.86}, {"date": "2026-03-20", "equity": 102358.08}, {"date": "2026-03-24", "equity": 102398.71}, {"date": "2026-03-25", "equity": 103066.1}, {"date": "2026-03-26", "equity": 102837.23}, {"date": "2026-03-27", "equity": 103454.53}, {"date": "2026-03-30", "equity": 104337.74}, {"date": "2026-03-31", "equity": 104263.86}, {"date": "2026-04-02", "equity": 104715.26}, {"date": "2026-04-06", "equity": 104665.96}, {"date": "2026-04-07", "equity": 103692.57}, {"date": "2026-04-08", "equity": 104644.79}, {"date": "2026-04-09", "equity": 105310.98}, {"date": "2026-04-10", "equity": 104277.92}, {"date": "2026-04-13", "equity": 103573.98}, {"date": "2026-04-15", "equity": 103335.34}, {"date": "2026-04-16", "equity": 103380.14}, {"date": "2026-04-17", "equity": 103649.04}, {"date": "2026-04-20", "equity": 102987.59}, {"date": "2026-04-21", "equity": 101956.6}, {"date": "2026-04-22", "equity": 101717.41}, {"date": "2026-04-23", "equity": 102818.4}, {"date": "2026-04-27", "equity": 101382.02}, {"date": "2026-04-28", "equity": 102484.02}, {"date": "2026-04-29", "equity": 102541.88}, {"date": "2026-04-30", "equity": 103306.46}, {"date": "2026-05-01", "equity": 102916.2}, {"date": "2026-05-04", "equity": 102304.82}, {"date": "2026-05-05", "equity": 102595.78}, {"date": "2026-05-07", "equity": 102412.86}, {"date": "2026-05-08", "equity": 102070.88}, {"date": "2026-05-11", "equity": 101433.38}, {"date": "2026-05-12", "equity": 102363.76}, {"date": "2026-05-13", "equity": 103046.26}, {"date": "2026-05-14", "equity": 103257.92}, {"date": "2026-05-15", "equity": 103170.82}, {"date": "2026-05-19", "equity": 104435.86}, {"date": "2026-05-20", "equity": 103934.64}, {"date": "2026-05-21", "equity": 103641.76}, {"date": "2026-05-22", "equity": 103566.4}, {"date": "2026-05-26", "equity": 103116.6}, {"date": "2026-05-27", "equity": 103468.96}, {"date": "2026-05-28", "equity": 103133.52}, {"date": "2026-06-01", "equity": 102126.34}, {"date": "2026-06-02", "equity": 102082.26}, {"date": "2026-06-03", "equity": 102208.2}, {"date": "2026-06-04", "equity": 102157.64}, {"date": "2026-06-05", "equity": 103043.76}, {"date": "2026-06-08", "equity": 103007.5}, {"date": "2026-06-09", "equity": 103746.28}, {"date": "2026-06-11", "equity": 104094.98}, {"date": "2026-06-12", "equity": 104305.4}, {"date": "2026-06-15", "equity": 103638.3}, {"date": "2026-06-16", "equity": 103579.78}, {"date": "2026-06-17", "equity": 103073.02}, {"date": "2026-06-18", "equity": 102303.34}, {"date": "2026-06-22", "equity": 102563.34}, {"date": "2026-06-24", "equity": 103666}, {"date": "2026-06-25", "equity": 103615.1}, {"date": "2026-06-26", "equity": 104926.88}, {"date": "2026-06-29", "equity": 105170.26}, {"date": "2026-06-30", "equity": 104371.16}, {"date": "2026-07-01", "equity": 104392.52}, {"date": "2026-07-06", "equity": 105134.4}, {"date": "2026-07-07", "equity": 105944.44}, {"date": "2026-07-08", "equity": 105525.66}, {"date": "2026-07-09", "equity": 104862.87}, {"date": "2026-07-10", "equity": 104904.96}, {"date": "2026-07-13", "equity": 105292.78}, {"date": "2026-07-14", "equity": 104483.61}, {"date": "2026-07-16", "equity": 104967.66}, {"date": "2026-07-17", "equity": 104089.56}, {"date": "2026-07-20", "equity": 104121.21}, {"date": "2026-07-21", "equity": 104063.71}, {"date": "2026-07-22", "equity": 104601.46}, {"date": "2026-07-23", "equity": 104453.77}, {"date": "2026-07-24", "equity": 105553.55}, {"date": "2026-07-28", "equity": 108475.3}, {"date": "2026-07-29", "equity": 108291.24}, {"date": "2026-07-30", "equity": 107011.78}, {"date": "2026-07-31", "equity": 106976.27}, {"date": "2026-08-03", "equity": 106755.98}, {"date": "2026-08-04", "equity": 107436.58}, {"date": "2026-08-05", "equity": 107555.15}, {"date": "2026-08-07", "equity": 107363.27}, {"date": "2026-08-10", "equity": 107817.48}, {"date": "2026-08-11", "equity": 107093.78}, {"date": "2026-08-12", "equity": 106686.06}, {"date": "2026-08-13", "equity": 107186.4}, {"date": "2026-08-14", "equity": 106975.21}, {"date": "2026-08-17", "equity": 106520.77}, {"date": "2026-08-19", "equity": 108646.58}, {"date": "2026-08-20", "equity": 107992.57}, {"date": "2026-08-21", "equity": 108565}, {"date": "2026-08-24", "equity": 109886.54}, {"date": "2026-08-25", "equity": 110030.82}, {"date": "2026-08-26", "equity": 109479.37}, {"date": "2026-08-27", "equity": 108650.77}, {"date": "2026-08-31", "equity": 108574.35}, {"date": "2026-09-01", "equity": 108419.93}, {"date": "2026-09-02", "equity": 109157.83}, {"date": "2026-09-03", "equity": 109500.65}, {"date": "2026-09-04", "equity": 108970.6}, {"date": "2026-09-08", "equity": 108152.11}, {"date": "2026-09-09", "equity": 107954.71}, {"date": "2026-09-11", "equity": 108271.38}, {"date": "2026-09-14", "equity": 108992.77}, {"date": "2026-09-15", "equity": 109076.44}, {"date": "2026-09-16", "equity": 108782.58}, {"date": "2026-09-17", "equity": 108622.56}, {"date": "2026-09-18", "equity": 108502.19}, {"date": "2026-09-21", "equity": 108482.47}, {"date": "2026-09-23", "equity": 108160.86}, {"date": "2026-09-24", "equity": 108503.85}, {"date": "2026-09-25", "equity": 109222.83}, {"date": "2026-09-28", "equity": 108898.43}, {"date": "2026-09-29", "equity": 108368.55}, {"date": "2026-09-30", "equity": 107824.98}, {"date": "2026-10-01", "equity": 107357.13}]'::jsonb,'[{"pnl": -591.04, "symbol": "BRK.B", "exitDate": "2025-10-29", "quantity": 32, "entryDate": "2025-10-20", "exitPrice": 475.67, "returnPct": -3.74, "entryPrice": 494.14, "exitReason": "trailing stop"}, {"pnl": 85.8, "symbol": "WMT", "exitDate": "2025-10-29", "quantity": 165, "entryDate": "2025-10-01", "exitPrice": 101.62, "returnPct": 0.51, "entryPrice": 101.1, "exitReason": "trailing stop"}, {"pnl": -118.8, "symbol": "MCD", "exitDate": "2025-10-31", "quantity": 55, "entryDate": "2025-10-01", "exitPrice": 290.98, "returnPct": -0.74, "entryPrice": 293.14, "exitReason": "trailing stop"}, {"pnl": -786.6, "symbol": "V", "exitDate": "2025-11-14", "quantity": 46, "entryDate": "2025-10-27", "exitPrice": 328.03, "returnPct": -4.95, "entryPrice": 345.13, "exitReason": "trailing stop"}, {"pnl": -1138.8, "symbol": "MSFT", "exitDate": "2025-11-21", "quantity": 30, "entryDate": "2025-11-12", "exitPrice": 469.21, "returnPct": -7.48, "entryPrice": 507.17, "exitReason": "trailing stop"}, {"pnl": -283.22, "symbol": "PEP", "exitDate": "2025-12-23", "quantity": 119, "entryDate": "2025-10-30", "exitPrice": 139.44, "returnPct": -1.68, "entryPrice": 141.82, "exitReason": "trailing stop"}, {"pnl": 1476, "symbol": "WMT", "exitDate": "2025-12-31", "quantity": 150, "entryDate": "2025-11-06", "exitPrice": 110.7, "returnPct": 9.76, "entryPrice": 100.86, "exitReason": "trailing stop"}, {"pnl": -480.2, "symbol": "KO", "exitDate": "2026-01-05", "quantity": 245, "entryDate": "2025-12-05", "exitPrice": 66.68, "returnPct": -2.86, "entryPrice": 68.64, "exitReason": "trailing stop"}, {"pnl": 1808.73, "symbol": "JNJ", "exitDate": "2026-01-05", "quantity": 99, "entryDate": "2025-10-28", "exitPrice": 201.05, "returnPct": 10, "entryPrice": 182.78, "exitReason": "trailing stop"}, {"pnl": -537.03, "symbol": "PEP", "exitDate": "2026-01-06", "quantity": 117, "entryDate": "2025-12-23", "exitPrice": 134.85, "returnPct": -3.29, "entryPrice": 139.44, "exitReason": "trailing stop"}, {"pnl": -570.88, "symbol": "BRK.B", "exitDate": "2026-01-20", "quantity": 32, "entryDate": "2025-12-04", "exitPrice": 485.46, "returnPct": -3.54, "entryPrice": 503.3, "exitReason": "trailing stop"}, {"pnl": 1867.86, "symbol": "WMT", "exitDate": "2026-02-20", "quantity": 162, "entryDate": "2025-12-31", "exitPrice": 122.23, "returnPct": 10.42, "entryPrice": 110.7, "exitReason": "trailing stop"}, {"pnl": 1822.5, "symbol": "KO", "exitDate": "2026-03-05", "quantity": 243, "entryDate": "2026-01-08", "exitPrice": 75.53, "returnPct": 11.02, "entryPrice": 68.03, "exitReason": "trailing stop"}, {"pnl": -1118.72, "symbol": "PEP", "exitDate": "2026-03-18", "quantity": 128, "entryDate": "2026-03-04", "exitPrice": 150.31, "returnPct": -5.5, "entryPrice": 159.05, "exitReason": "trailing stop"}, {"pnl": 2930.16, "symbol": "JNJ", "exitDate": "2026-03-18", "quantity": 87, "entryDate": "2026-01-05", "exitPrice": 234.73, "returnPct": 16.75, "entryPrice": 201.05, "exitReason": "trailing stop"}, {"pnl": 478.06, "symbol": "MCD", "exitDate": "2026-03-18", "quantity": 41, "entryDate": "2025-12-31", "exitPrice": 311.38, "returnPct": 3.89, "entryPrice": 299.72, "exitReason": "trailing stop"}, {"pnl": -1424.28, "symbol": "WMT", "exitDate": "2026-03-20", "quantity": 166, "entryDate": "2026-02-27", "exitPrice": 118.51, "returnPct": -6.75, "entryPrice": 127.09, "exitReason": "trailing stop"}, {"pnl": -12.54, "symbol": "COST", "exitDate": "2026-04-13", "quantity": 11, "entryDate": "2026-03-05", "exitPrice": 977.65, "returnPct": -0.12, "entryPrice": 978.79, "exitReason": "trailing stop"}, {"pnl": -551.65, "symbol": "JNJ", "exitDate": "2026-04-20", "quantity": 85, "entryDate": "2026-03-18", "exitPrice": 228.24, "returnPct": -2.76, "entryPrice": 234.73, "exitReason": "trailing stop"}, {"pnl": -872.91, "symbol": "MCD", "exitDate": "2026-04-27", "quantity": 53, "entryDate": "2026-04-08", "exitPrice": 286.3, "returnPct": -5.44, "entryPrice": 302.77, "exitReason": "trailing stop"}, {"pnl": -454.72, "symbol": "PEP", "exitDate": "2026-05-11", "quantity": 112, "entryDate": "2026-03-18", "exitPrice": 146.25, "returnPct": -2.7, "entryPrice": 150.31, "exitReason": "trailing stop"}, {"pnl": 501.44, "symbol": "COST", "exitDate": "2026-05-22", "quantity": 16, "entryDate": "2026-04-27", "exitPrice": 1026.22, "returnPct": 3.15, "entryPrice": 994.88, "exitReason": "trailing stop"}, {"pnl": 541.02, "symbol": "KO", "exitDate": "2026-06-01", "quantity": 254, "entryDate": "2026-03-05", "exitPrice": 77.66, "returnPct": 2.82, "entryPrice": 75.53, "exitReason": "trailing stop"}, {"pnl": -750.4, "symbol": "COST", "exitDate": "2026-06-30", "quantity": 16, "entryDate": "2026-06-12", "exitPrice": 933.86, "returnPct": -4.78, "entryPrice": 980.76, "exitReason": "trailing stop"}, {"pnl": 1332.28, "symbol": "JNJ", "exitDate": "2026-07-15", "quantity": 76, "entryDate": "2026-04-20", "exitPrice": 245.77, "returnPct": 7.68, "entryPrice": 228.24, "exitReason": "trailing stop"}, {"pnl": 457.45, "symbol": "BRK.B", "exitDate": "2026-08-14", "quantity": 35, "entryDate": "2026-07-17", "exitPrice": 503.95, "returnPct": 2.66, "entryPrice": 490.88, "exitReason": "trailing stop"}, {"pnl": -502.55, "symbol": "PG", "exitDate": "2026-08-20", "quantity": 115, "entryDate": "2026-07-08", "exitPrice": 142.94, "returnPct": -2.97, "entryPrice": 147.31, "exitReason": "trailing stop"}, {"pnl": 2104.2, "symbol": "KO", "exitDate": "2026-09-01", "quantity": 210, "entryDate": "2026-06-02", "exitPrice": 87.49, "returnPct": 12.93, "entryPrice": 77.47, "exitReason": "trailing stop"}, {"pnl": 957.6, "symbol": "V", "exitDate": "2026-09-18", "quantity": 57, "entryDate": "2026-07-23", "exitPrice": 367.63, "returnPct": 4.79, "entryPrice": 350.83, "exitReason": "trailing stop"}, {"pnl": 127.84, "symbol": "BRK.B", "exitDate": "2026-09-21", "quantity": 34, "entryDate": "2026-08-17", "exitPrice": 502.09, "returnPct": 0.75, "entryPrice": 498.33, "exitReason": "trailing stop"}, {"pnl": 852.39, "symbol": "JNJ", "exitDate": "2026-10-01", "quantity": 77, "entryDate": "2026-07-20", "exitPrice": 258.7, "returnPct": 4.47, "entryPrice": 247.63, "exitReason": "trailing stop"}, {"pnl": -200.22, "symbol": "KO", "exitDate": "2026-10-01", "quantity": 213, "entryDate": "2026-09-09", "exitPrice": 86.12, "returnPct": -1.08, "entryPrice": 87.06, "exitReason": "end of test"}, {"pnl": 823.62, "symbol": "MSFT", "exitDate": "2026-10-01", "quantity": 42, "entryDate": "2026-09-18", "exitPrice": 512.71, "returnPct": 3.98, "entryPrice": 493.1, "exitReason": "end of test"}, {"pnl": -415.26, "symbol": "V", "exitDate": "2026-10-01", "quantity": 54, "entryDate": "2026-09-18", "exitPrice": 359.94, "returnPct": -2.09, "entryPrice": 367.63, "exitReason": "end of test"}, {"pnl": 0, "symbol": "BRK.B", "exitDate": "2026-10-01", "quantity": 33, "entryDate": "2026-10-01", "exitPrice": 500.67, "returnPct": 0, "entryPrice": 500.67, "exitReason": "end of test"}]'::jsonb,'Real alpaca daily prices.',NULL,'2026-10-06T03:59:25.239502+00:00') ON CONFLICT (id) DO NOTHING;
COMMIT;

-- Default demo administrator: demo.admin@autohedge.app / AutoHedgeAdmin2026!  (change or delete after first login)
BEGIN;
SELECT set_config('app.service','on',true);
INSERT INTO auth.users (id,email,encrypted_password,raw_user_meta_data) VALUES ('a0000000-0000-4000-8000-00000000ad01','demo.admin@autohedge.app','scrypt$e64024c88185b78eb6fe870bcc63c0a8$cb08a658d44e4ce89cf3dce2468b9b986daff468c001325e8f6eb8dbb71cc63d977be5616160397dac63fa124193f99f9fc3a154ae612546210d69bf82af6bb0','{"display_name":"Demo Admin"}') ON CONFLICT (email) DO NOTHING;
INSERT INTO public.profiles (id,display_name) VALUES ('a0000000-0000-4000-8000-00000000ad01','Demo Admin') ON CONFLICT (id) DO NOTHING;
INSERT INTO public.user_roles (user_id,role) VALUES ('a0000000-0000-4000-8000-00000000ad01','admin') ON CONFLICT DO NOTHING;
COMMIT;
