CREATE TABLE "grid_lots" (
	"id" serial PRIMARY KEY NOT NULL,
	"pair" varchar(16) NOT NULL,
	"level_idx" integer NOT NULL,
	"qty" double precision NOT NULL,
	"entry_ts" timestamp with time zone NOT NULL,
	"entry_price" double precision NOT NULL,
	"entry_cost" double precision NOT NULL,
	"risk_amount" double precision NOT NULL
);
--> statement-breakpoint
CREATE TABLE "grid_state" (
	"pair" varchar(16) PRIMARY KEY NOT NULL,
	"center" double precision NOT NULL,
	"spacing" double precision NOT NULL,
	"lower_bound" double precision NOT NULL,
	"upper_bound" double precision NOT NULL,
	"budget_per_level" double precision NOT NULL,
	"activated_ts" timestamp with time zone NOT NULL
);
--> statement-breakpoint
ALTER TABLE "equity_snapshots" ADD COLUMN "bot" text DEFAULT 'trend' NOT NULL;--> statement-breakpoint
ALTER TABLE "equity_snapshots" DROP CONSTRAINT "equity_snapshots_pkey";--> statement-breakpoint
ALTER TABLE "equity_snapshots" ADD CONSTRAINT "equity_snapshots_bot_ts_pk" PRIMARY KEY("bot","ts");--> statement-breakpoint
ALTER TABLE "paper_trades" ADD COLUMN "bot" text DEFAULT 'trend' NOT NULL;