> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sequency.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Strategy

> Create a new strategy.



## OpenAPI

````yaml /api/openapi.json post /api/graph/v1/strategies
openapi: 3.1.0
info:
  title: Sequency Graph API
  description: >

    # Sequency Graph-Native Trading API


    Graph-native API for trading intelligence, built on FalkorDB.


    ## Features


    - **Screener**: Filter stocks using graph-native queries with relationship
    expansion

    - **Stock Detail**: Complete stock context with all relationships

    - **Confluence Scoring**: Setup quality assessment with weighted components

    - **Strategy Matching**: Find matching options strategies via graph
    traversal

    - **Market Context**: Current market-wide context for trading decisions


    ## Data Sources


    All data is sourced from the FalkorDB knowledge graph, populated by:

    - Pattern detector (Go) - Technical indicators, patterns

    - Graph sync service - Levels, volume profiles, news, day classification
  version: 1.0.0
servers: []
security: []
paths:
  /api/graph/v1/strategies:
    post:
      tags:
        - strategies
      summary: Create Strategy
      description: Create a new strategy.
      operationId: create_strategy_api_graph_v1_strategies_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StrategyCreate'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StrategyResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    StrategyCreate:
      properties:
        name:
          type: string
          maxLength: 200
          title: Name
        archetype:
          $ref: '#/components/schemas/Archetype'
          default: custom
        instrument:
          $ref: '#/components/schemas/Instrument'
          default: stocks
        timeframe:
          $ref: '#/components/schemas/app__models__strategy__Timeframe'
          default: intraday
        automation_level:
          $ref: '#/components/schemas/AutomationLevel'
          default: monitor
        universe:
          $ref: '#/components/schemas/UniverseConfig'
        strategy_kind:
          $ref: '#/components/schemas/StrategyKind'
          default: rule_driven
        rules:
          anyOf:
            - $ref: '#/components/schemas/StrategyRules'
            - type: 'null'
        cross_sectional_spec:
          anyOf:
            - $ref: '#/components/schemas/CrossSectionalSpec'
            - type: 'null'
        risk_controls:
          $ref: '#/components/schemas/RiskControls'
        canvas_layout:
          anyOf:
            - $ref: '#/components/schemas/CanvasLayoutPersisted'
            - type: 'null'
        contract_selection:
          anyOf:
            - $ref: '#/components/schemas/RuleBasedContractConfig'
            - $ref: '#/components/schemas/SpecificContractConfig'
            - type: 'null'
          title: Contract Selection
        forked_from_run_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Forked From Run Id
        derived_from_strategy_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Derived From Strategy Id
      type: object
      required:
        - name
      title: StrategyCreate
    StrategyResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        user_id:
          type: string
          format: uuid
          title: User Id
        name:
          type: string
          title: Name
        archetype:
          anyOf:
            - type: string
            - type: 'null'
          title: Archetype
        instrument:
          $ref: '#/components/schemas/Instrument'
        timeframe:
          $ref: '#/components/schemas/app__models__strategy__Timeframe'
        automation_level:
          $ref: '#/components/schemas/AutomationLevel'
        universe:
          additionalProperties: true
          type: object
          title: Universe
        strategy_kind:
          type: string
          title: Strategy Kind
          default: rule_driven
        rules:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Rules
        cross_sectional_spec:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Cross Sectional Spec
        risk_controls:
          additionalProperties: true
          type: object
          title: Risk Controls
        canvas_layout:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Canvas Layout
        contract_selection:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Contract Selection
        deployment_phase:
          $ref: '#/components/schemas/DeploymentPhase'
        deployment_ramp_pct:
          type: integer
          title: Deployment Ramp Pct
        version:
          type: integer
          title: Version
        is_active:
          type: boolean
          title: Is Active
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        forked_from_run_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Forked From Run Id
        derived_from_strategy_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Derived From Strategy Id
        last_verdict:
          anyOf:
            - type: string
              enum:
                - shown_promise_for_regime
                - not_yet
                - rejected
            - type: 'null'
          title: Last Verdict
      type: object
      required:
        - id
        - user_id
        - name
        - instrument
        - timeframe
        - automation_level
        - universe
        - risk_controls
        - deployment_phase
        - deployment_ramp_pct
        - version
        - is_active
        - created_at
        - updated_at
      title: StrategyResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Archetype:
      type: string
      enum:
        - mean_reversion
        - trend_following
        - momentum
        - volatility
        - custom
      title: Archetype
    Instrument:
      type: string
      enum:
        - stocks
        - options
        - both
      title: Instrument
    app__models__strategy__Timeframe:
      type: string
      enum:
        - scalping
        - intraday
        - swing
      title: Timeframe
    AutomationLevel:
      type: string
      enum:
        - monitor
        - supervised
        - autonomous
      title: AutomationLevel
    UniverseConfig:
      properties:
        type:
          type: string
          title: Type
          default: full_universe
        symbols:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Symbols
        sector:
          anyOf:
            - type: string
            - type: 'null'
          title: Sector
        min_market_cap:
          anyOf:
            - type: number
            - type: 'null'
          title: Min Market Cap
        min_adv:
          anyOf:
            - type: number
            - type: 'null'
          title: Min Adv
        min_price:
          anyOf:
            - type: number
            - type: 'null'
          title: Min Price
        max_price:
          anyOf:
            - type: number
            - type: 'null'
          title: Max Price
      type: object
      title: UniverseConfig
    StrategyKind:
      type: string
      enum:
        - rule_driven
        - cross_sectional
      title: StrategyKind
      description: >-
        Orthogonal structural discriminator (NOT a behavioral archetype).


        rule_driven    -> per-symbol entry/exit rules (StrategyRules)

        cross_sectional -> rank the universe → basket → vol-scale
        (CrossSectionalSpec)
    StrategyRules:
      properties:
        entry_groups:
          items:
            $ref: '#/components/schemas/RuleGroup'
          type: array
          maxItems: 16
          title: Entry Groups
        exit_groups:
          items:
            $ref: '#/components/schemas/RuleGroup'
          type: array
          maxItems: 16
          title: Exit Groups
      type: object
      required:
        - entry_groups
        - exit_groups
      title: StrategyRules
    CrossSectionalSpec:
      properties:
        ranking_metric:
          anyOf:
            - $ref: '#/components/schemas/RankingMetric'
            - type: 'null'
        ranking_feature:
          anyOf:
            - $ref: '#/components/schemas/PITFeatureDefinitionV1'
            - type: 'null'
        lookback_days:
          anyOf:
            - type: integer
              maximum: 504
              exclusiveMinimum: 0
            - type: 'null'
          title: Lookback Days
        rebalance_freq:
          type: string
          enum:
            - daily
            - weekly
            - monthly
          title: Rebalance Freq
          default: monthly
        direction:
          type: string
          enum:
            - long_only
            - long_short
          title: Direction
          default: long_only
        long_fraction:
          type: number
          maximum: 0.5
          exclusiveMinimum: 0
          title: Long Fraction
        short_fraction:
          anyOf:
            - type: number
              maximum: 0.5
              exclusiveMinimum: 0
            - type: 'null'
          title: Short Fraction
        winsor_daily:
          type: number
          maximum: 1
          exclusiveMinimum: 0
          title: Winsor Daily
          default: 0.35
      type: object
      required:
        - long_fraction
      title: CrossSectionalSpec
    RiskControls:
      properties:
        sizing_method:
          type: string
          maxLength: 64
          title: Sizing Method
          default: fixed_risk
        sizing_params:
          additionalProperties: true
          type: object
          title: Sizing Params
        stop_losses:
          items:
            $ref: '#/components/schemas/StopLossConfig'
          type: array
          maxItems: 16
          title: Stop Losses
        max_position_pct:
          type: number
          maximum: 1
          minimum: 0
          title: Max Position Pct
          default: 0.05
        max_total_positions:
          type: integer
          maximum: 1000
          minimum: 0
          title: Max Total Positions
          default: 6
        max_same_direction:
          type: integer
          maximum: 1000
          minimum: 0
          title: Max Same Direction
          default: 3
        max_sector_concentration_pct:
          type: number
          maximum: 1
          minimum: 0
          title: Max Sector Concentration Pct
          default: 0.4
        max_loss_per_trade_dollars:
          type: number
          minimum: 0
          title: Max Loss Per Trade Dollars
          default: 500
        max_overnight_exposure_pct:
          type: number
          maximum: 1
          minimum: 0
          title: Max Overnight Exposure Pct
          default: 0.15
        daily_pnl_limit_pct:
          type: number
          maximum: 1
          minimum: -1
          title: Daily Pnl Limit Pct
          default: -0.02
        consecutive_loss_limit:
          type: integer
          maximum: 1000
          minimum: 0
          title: Consecutive Loss Limit
          default: 3
        drawdown_limit_pct:
          type: number
          maximum: 1
          minimum: -1
          title: Drawdown Limit Pct
          default: -0.08
      type: object
      title: RiskControls
    CanvasLayoutPersisted:
      properties:
        nodes:
          additionalProperties:
            $ref: '#/components/schemas/CanvasLayoutNode'
          type: object
          title: Nodes
        viewport:
          $ref: '#/components/schemas/CanvasLayoutViewport'
        active_group_id:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Active Group Id
        column_hints:
          additionalProperties:
            type: string
            enum:
              - signal
              - filter
              - hub
              - exit
          type: object
          title: Column Hints
      type: object
      title: CanvasLayoutPersisted
      description: |-
        Typed `strategy.canvas_layout` JSONB shape — security review M1 fix.

        The frontend's `CanvasLayoutPersisted` interface in
        `lib/canvas/types.ts` is the source of truth for the shape; this
        Pydantic model enforces the contract at the API boundary so
        malformed writes are rejected with 422 rather than silently
        corrupting the user's canvas state.
    RuleBasedContractConfig:
      properties:
        mode:
          type: string
          const: rule_based
          title: Mode
          default: rule_based
        direction:
          type: string
          enum:
            - bullish
            - bearish
            - auto
          title: Direction
          description: Trade direction. 'auto' infers from entry signal action.
          default: auto
        target_delta:
          type: number
          maximum: 0.95
          minimum: 0.05
          title: Target Delta
          default: 0.3
        delta_tolerance:
          type: number
          maximum: 0.3
          minimum: 0.01
          title: Delta Tolerance
          default: 0.1
        dte_min:
          type: integer
          maximum: 730
          minimum: 0
          title: Dte Min
          default: 7
        dte_max:
          type: integer
          maximum: 730
          minimum: 1
          title: Dte Max
          default: 45
        option_type:
          type: string
          enum:
            - call
            - put
            - auto
          title: Option Type
          description: Contract type. 'auto' derives from resolved direction.
          default: auto
        min_open_interest:
          type: integer
          minimum: 0
          title: Min Open Interest
          default: 10
        max_spread_pct:
          type: number
          maximum: 0.5
          minimum: 0.01
          title: Max Spread Pct
          default: 0.1
        prefer_weekly:
          type: boolean
          title: Prefer Weekly
          default: false
      type: object
      title: RuleBasedContractConfig
      description: |-
        Rule-based options contract selection.

        Maps directly to ContractCriteria in contract_recommender.py
        via contract_selection_bridge.config_to_criteria().
    SpecificContractConfig:
      properties:
        mode:
          type: string
          const: specific
          title: Mode
          default: specific
        contracts:
          items:
            $ref: '#/components/schemas/SpecificContract'
          type: array
          maxItems: 20
          title: Contracts
        expiry_handling:
          type: string
          enum:
            - roll_same_params
            - close_and_notify
            - manual
          title: Expiry Handling
          default: close_and_notify
      type: object
      required:
        - contracts
      title: SpecificContractConfig
      description: Specific contract selection (Phase 2 — stub for forward compat).
    DeploymentPhase:
      type: string
      enum:
        - backtest
        - paper
        - shadow
        - live
      title: DeploymentPhase
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    RuleGroup:
      properties:
        id:
          type: string
          maxLength: 128
          pattern: ^[A-Za-z0-9_\-]+$
          title: Id
          description: >-
            Alphanumeric id (underscores + hyphens allowed) — used as a nodeId
            prefix in the canvas
        label:
          type: string
          maxLength: 200
          title: Label
          default: ''
        conditions:
          items:
            $ref: '#/components/schemas/RuleCondition'
          type: array
          maxItems: 32
          title: Conditions
        action:
          type: string
          maxLength: 32
          title: Action
      type: object
      required:
        - id
        - conditions
        - action
      title: RuleGroup
    RankingMetric:
      type: string
      enum:
        - proximity_to_high
        - relative_return
      title: RankingMetric
    PITFeatureDefinitionV1:
      properties:
        schema_version:
          type: string
          const: pit-feature-v1
          title: Schema Version
          default: pit-feature-v1
        source:
          type: string
          maxLength: 128
          minLength: 1
          title: Source
        field:
          type: string
          maxLength: 128
          minLength: 1
          title: Field
        value_kind:
          type: string
          enum:
            - number
            - flag
          title: Value Kind
        sort_direction:
          type: string
          enum:
            - descending
            - ascending
          title: Sort Direction
        missing_policy:
          type: string
          const: fail_batch
          title: Missing Policy
          default: fail_batch
      additionalProperties: false
      type: object
      required:
        - source
        - field
        - value_kind
        - sort_direction
      title: PITFeatureDefinitionV1
      description: One point-in-time ranking feature selected through a registered adapter.
    StopLossConfig:
      properties:
        id:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Id
        type:
          type: string
          enum:
            - atr
            - trailing
            - target
            - conviction_drop
            - regime_flip
            - time
          title: Type
        params:
          additionalProperties: true
          type: object
          title: Params
      type: object
      required:
        - type
      title: StopLossConfig
    CanvasLayoutNode:
      properties:
        x:
          type: number
          maximum: 1000000
          minimum: -1000000
          title: X
        'y':
          type: number
          maximum: 1000000
          minimum: -1000000
          title: 'Y'
        column:
          type: string
          enum:
            - signal
            - filter
            - hub
            - exit
          title: Column
      type: object
      required:
        - x
        - 'y'
        - column
      title: CanvasLayoutNode
    CanvasLayoutViewport:
      properties:
        x:
          type: number
          maximum: 1000000
          minimum: -1000000
          title: X
        'y':
          type: number
          maximum: 1000000
          minimum: -1000000
          title: 'Y'
        zoom:
          type: number
          maximum: 100
          minimum: 0.001
          title: Zoom
      type: object
      required:
        - x
        - 'y'
        - zoom
      title: CanvasLayoutViewport
    SpecificContract:
      properties:
        contract_symbol:
          type: string
          maxLength: 30
          title: Contract Symbol
        label:
          anyOf:
            - type: string
              maxLength: 100
            - type: 'null'
          title: Label
      type: object
      required:
        - contract_symbol
      title: SpecificContract
    RuleCondition:
      properties:
        id:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Id
        source:
          $ref: '#/components/schemas/ConditionSource'
        indicator:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Indicator
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
        field:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Field
        update_frequency:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Update Frequency
        staleness_warn_sec:
          anyOf:
            - type: integer
              maximum: 86400
              minimum: 0
            - type: 'null'
          title: Staleness Warn Sec
        type:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Type
        operator:
          anyOf:
            - $ref: '#/components/schemas/Operator'
            - type: 'null'
        value:
          anyOf:
            - type: number
            - type: integer
            - type: string
            - items: {}
              type: array
            - type: 'null'
          title: Value
        ref:
          anyOf:
            - type: string
              maxLength: 256
            - type: 'null'
          title: Ref
        ref_offset:
          anyOf:
            - $ref: '#/components/schemas/RefOffset'
            - type: 'null'
      type: object
      required:
        - source
      title: RuleCondition
    ConditionSource:
      type: string
      enum:
        - indicator
        - graph_field
        - mse_signal
        - price_action
        - volume
        - options
        - stop_loss
        - time_exit
        - regime
      title: ConditionSource
    Operator:
      type: string
      enum:
        - gt
        - lt
        - gte
        - lte
        - eq
        - neq
        - in
        - not_in
        - crosses_above
        - crosses_below
      title: Operator
    RefOffset:
      properties:
        op:
          type: string
          enum:
            - +
            - '-'
          title: Op
        coef:
          type: number
          maximum: 1000
          minimum: -1000
          title: Coef
        ref:
          type: string
          maxLength: 256
          title: Ref
      type: object
      required:
        - op
        - coef
        - ref
      title: RefOffset
      description: >-
        Structured arithmetic offset for a condition's reference target.


        Lets a condition compare against ``base ± coef * offset`` where both

        ``base`` (RuleCondition.ref) and ``offset`` (this.ref) are resolved by
        the

        rule engine's ref grammar (``price.<field>`` /
        ``indicator.<name>.<key>`` /

        ``graph_field.<field>``). This makes setups like EQ-7 ("price > 2×ATR
        from

        VWAP") expressible without a string-math expression parser — Pydantic
        gives

        free type-validation (``op`` constrained to ±, ``coef`` bounded, ``ref``

        length-capped), so there is no injection surface.

````