Current section

Files

Jump to
ex_oanda lib models definitions trade calculated_trade_state.ex
Raw

lib/models/definitions/trade/calculated_trade_state.ex

defmodule ExOanda.CalculatedTradeState do
@moduledoc """
Schema for Oanda calculated trade state.
[Oanda Docs](https://developer.oanda.com/rest-live-v20/trade-df/)
"""
use TypedEctoSchema
import Ecto.Changeset
@primary_key false
typed_embedded_schema do
field(:id, :string)
field(:unrealized_pl, :float)
field(:margin_used, :float)
end
@doc false
def changeset(struct, params) do
struct
|> cast(params, [:id, :unrealized_pl, :margin_used])
|> validate_required([:id, :unrealized_pl, :margin_used])
end
end