Bourse.Order.Builder (bourse v0.1.0)

Copy Markdown View Source

Fluent builder for unified order creation.

Accumulates order options and submits through Bourse.create_order/6.

Summary

Functions

Turns the order into a limit order with price.

Starts a market order builder for symbol, side, and amount.

Adds a stop-loss price.

Submits the order through Bourse.create_order/6 using credentials.

Adds a take-profit price.

Types

t()

@type t() :: %Bourse.Order.Builder{
  amount: number(),
  params: keyword(),
  side: String.t(),
  symbol: String.t(),
  type: String.t()
}

Functions

limit(builder, price)

@spec limit(t(), number()) :: t()

Turns the order into a limit order with price.

new(symbol, side, amount)

@spec new(String.t(), String.t(), number()) :: t()

Starts a market order builder for symbol, side, and amount.

stop_loss(builder, price)

@spec stop_loss(t(), number()) :: t()

Adds a stop-loss price.

submit(builder, exchange, credentials, opts \\ [])

@spec submit(t(), Bourse.Exchange.t(), Bourse.Credentials.t(), keyword()) ::
  {:ok, map()} | {:ok, map(), [Bourse.Order.Sanity.reason()]} | {:error, term()}

Submits the order through Bourse.create_order/6 using credentials.

take_profit(builder, price)

@spec take_profit(t(), number()) :: t()

Adds a take-profit price.