-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add missing transactions * Fix types * Missed one
- Loading branch information
1 parent
a21e596
commit c742a3e
Showing
18 changed files
with
880 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/models/definitions/transaction/delayed_trade_closure_transaction.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
defmodule Oanda.Transaction.DelayedTradeClosureTransaction do | ||
@moduledoc """ | ||
A DelayedTradeClosureTransaction represents the immediate closure of a Trade that was | ||
requested to be delayed. | ||
""" | ||
|
||
use TypedEctoSchema | ||
import Ecto.Changeset | ||
alias ExOanda.Type.Atom | ||
|
||
@primary_key false | ||
|
||
embedded_schema do | ||
field(:id, :string) | ||
field(:time, :utc_datetime_usec) | ||
field(:user_id, :integer) | ||
field(:account_id, :string) | ||
field(:batch_id, :string) | ||
field(:request_id, :string) | ||
field(:type, Atom, default: :DELAYED_TRADE_CLOSURE) | ||
field(:reason, :string) | ||
field(:trade_ids, {:array, :string}) | ||
end | ||
|
||
def changeset(struct, data) do | ||
struct | ||
|> cast(data, [ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:request_id, | ||
:type, | ||
:reason, | ||
:trade_ids | ||
]) | ||
|> validate_required([ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:type | ||
]) | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
lib/models/definitions/transaction/dividend_adjustment_transaction.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
defmodule Oanda.Transaction.DividendAdjustmentTransaction do | ||
@moduledoc """ | ||
A DividendAdjustmentTransaction represents a dividend adjustment made to an Account. | ||
""" | ||
|
||
use TypedEctoSchema | ||
import Ecto.Changeset | ||
alias ExOanda.Type.Atom | ||
|
||
@primary_key false | ||
|
||
embedded_schema do | ||
field(:id, :string) | ||
field(:time, :utc_datetime_usec) | ||
field(:user_id, :integer) | ||
field(:account_id, :string) | ||
field(:batch_id, :string) | ||
field(:request_id, :string) | ||
field(:type, Atom, default: :DIVIDEND_ADJUSTMENT) | ||
field(:instrument, Atom) | ||
field(:dividend_rate, :float) | ||
field(:quote_units, :float) | ||
field(:home_conversion_factors, :map) | ||
field(:account_balance, :float) | ||
end | ||
|
||
def changeset(struct, data) do | ||
struct | ||
|> cast(data, [ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:request_id, | ||
:type, | ||
:instrument, | ||
:dividend_rate, | ||
:quote_units, | ||
:home_conversion_factors, | ||
:account_balance | ||
]) | ||
|> validate_required([ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:type, | ||
:instrument | ||
]) | ||
end | ||
end |
57 changes: 57 additions & 0 deletions
57
lib/models/definitions/transaction/fixed_price_order_transaction.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
defmodule Oanda.Transaction.FixedPriceOrderTransaction do | ||
@moduledoc """ | ||
A FixedPriceOrderTransaction represents the creation of a Fixed Price Order in the user's Account. | ||
""" | ||
|
||
use TypedEctoSchema | ||
import Ecto.Changeset | ||
alias ExOanda.Type.Atom | ||
|
||
@primary_key false | ||
|
||
embedded_schema do | ||
field(:id, :string) | ||
field(:time, :utc_datetime_usec) | ||
field(:user_id, :integer) | ||
field(:account_id, :string) | ||
field(:batch_id, :string) | ||
field(:request_id, :string) | ||
field(:type, Atom, default: :FIXED_PRICE_ORDER) | ||
field(:instrument, Atom) | ||
field(:units, :float) | ||
field(:price, :float) | ||
field(:position_fill, :string) | ||
field(:trade_state, :string) | ||
field(:reason, :string) | ||
end | ||
|
||
def changeset(struct, data) do | ||
struct | ||
|> cast(data, [ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:request_id, | ||
:type, | ||
:instrument, | ||
:units, | ||
:price, | ||
:position_fill, | ||
:trade_state, | ||
:reason | ||
]) | ||
|> validate_required([ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:type, | ||
:instrument, | ||
:units, | ||
:price | ||
]) | ||
end | ||
end |
80 changes: 80 additions & 0 deletions
80
lib/models/definitions/transaction/limit_order_reject_transaction.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
defmodule Oanda.Transaction.LimitOrderRejectTransaction do | ||
@moduledoc """ | ||
A LimitOrderRejectTransaction represents the rejection of the creation of a Limit Order. | ||
""" | ||
|
||
use TypedEctoSchema | ||
import Ecto.Changeset | ||
alias ExOanda.Type.Atom | ||
|
||
alias Oanda.Transaction.{ | ||
ClientExtensions, | ||
TakeProfitDetails, | ||
StopLossDetails, | ||
TrailingStopLossDetails, | ||
GuaranteedStopLossDetails | ||
} | ||
|
||
@primary_key false | ||
|
||
embedded_schema do | ||
field(:id, :string) | ||
field(:time, :utc_datetime_usec) | ||
field(:user_id, :integer) | ||
field(:account_id, :string) | ||
field(:batch_id, :string) | ||
field(:request_id, :string) | ||
field(:type, Atom, default: :LIMIT_ORDER_REJECT) | ||
field(:instrument, Atom) | ||
field(:units, :float) | ||
field(:price, :float) | ||
field(:time_in_force, Ecto.Enum, values: ~w(GTC GTD GFD FOK IOC)a) | ||
field(:gtd_time, :utc_datetime_usec) | ||
field(:position_fill, :string, default: "DEFAULT") | ||
field(:trigger_condition, Ecto.Enum, values: ~w(DEFAULT INVERSE BID ASK MID)a) | ||
field(:reason, :string) | ||
field(:reject_reason, :string) | ||
|
||
embeds_one :client_extensions, ClientExtensions | ||
embeds_one :take_profit_on_fill, TakeProfitDetails | ||
embeds_one :stop_loss_on_fill, StopLossDetails | ||
embeds_one :trailing_stop_loss_on_fill, TrailingStopLossDetails | ||
embeds_one :guaranteed_stop_loss_on_fill, GuaranteedStopLossDetails | ||
end | ||
|
||
def changeset(struct, data) do | ||
struct | ||
|> cast(data, [ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:request_id, | ||
:type, | ||
:instrument, | ||
:units, | ||
:price, | ||
:time_in_force, | ||
:gtd_time, | ||
:position_fill, | ||
:trigger_condition, | ||
:reason, | ||
:reject_reason | ||
]) | ||
|> cast_embed(:client_extensions) | ||
|> cast_embed(:take_profit_on_fill) | ||
|> cast_embed(:stop_loss_on_fill) | ||
|> cast_embed(:trailing_stop_loss_on_fill) | ||
|> cast_embed(:guaranteed_stop_loss_on_fill) | ||
|> validate_required([ | ||
:id, | ||
:time, | ||
:user_id, | ||
:account_id, | ||
:batch_id, | ||
:type, | ||
:reject_reason | ||
]) | ||
end | ||
end |
Oops, something went wrong.