Packages
tai
0.0.70
0.0.75
0.0.74
0.0.73
0.0.72
0.0.71
0.0.70
0.0.69
0.0.68
0.0.67
0.0.66
0.0.65
0.0.64
0.0.63
0.0.62
0.0.61
0.0.60
0.0.59
0.0.58
0.0.57
0.0.56
0.0.55
0.0.54
0.0.53
0.0.52
0.0.51
0.0.50
0.0.49
0.0.48
0.0.47
0.0.46
0.0.45
0.0.44
0.0.43
0.0.42
0.0.41
0.0.40
0.0.39
0.0.38
0.0.37
0.0.36
0.0.35
0.0.34
0.0.33
0.0.32
0.0.31
0.0.30
0.0.29
0.0.28
0.0.27
0.0.26
0.0.25
0.0.24
0.0.23
0.0.22
0.0.21
0.0.20
0.0.19
0.0.18
0.0.17
0.0.16
0.0.15
0.0.14
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
A composable, real time, market data and trade execution toolkit
Current section
Files
Jump to
Current section
Files
lib/tai/commander.ex
defmodule Tai.Commander do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
def accounts(options \\ []) do
options |> to_dest() |> GenServer.call(:accounts)
end
def products(options \\ []) do
options |> to_dest() |> GenServer.call(:products)
end
def fees(options \\ []) do
options |> to_dest() |> GenServer.call(:fees)
end
def markets(options \\ []) do
options |> to_dest() |> GenServer.call(:markets)
end
def orders(query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:orders, query, options})
end
def orders_count(query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:orders_count, query})
end
def get_order_by_client_id(client_id, options \\ []) do
options |> to_dest() |> GenServer.call({:get_order_by_client_id, client_id})
end
def get_orders_by_client_ids(client_ids, options \\ []) do
options |> to_dest() |> GenServer.call({:get_orders_by_client_ids, client_ids})
end
def order_transitions(client_id, query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:order_transitions, client_id, query, options})
end
def order_transitions_count(client_id, query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:order_transitions_count, client_id, query})
end
def failed_order_transitions(client_id, query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:failed_order_transitions, client_id, query, options})
end
def failed_order_transitions_count(client_id, query \\ nil, options \\ []) do
options |> to_dest() |> GenServer.call({:failed_order_transitions_count, client_id, query})
end
def delete_all_orders(options \\ []) do
options |> to_dest() |> GenServer.call(:delete_all_orders, 60_000)
end
def positions(options \\ []) do
options |> to_dest() |> GenServer.call(:positions)
end
def venues(options \\ []) do
options |> to_dest() |> GenServer.call({:venues, options})
end
def start_venue(venue_id, options \\ []) do
options |> to_dest |> GenServer.call({:start_venue, venue_id, options})
end
def stop_venue(venue_id, options \\ []) do
options |> to_dest |> GenServer.call({:stop_venue, venue_id, options})
end
def fleets(options \\ []) do
options |> to_dest |> GenServer.call({:fleets, options})
end
def advisors(options \\ []) do
options |> to_dest |> GenServer.call({:advisors, options})
end
def start_advisors(options \\ []) do
options |> to_dest |> GenServer.call({:start_advisors, options})
end
def stop_advisors(options \\ []) do
options |> to_dest |> GenServer.call({:stop_advisors, options})
end
def settings(options \\ []) do
options |> to_dest |> GenServer.call(:settings)
end
def enable_send_orders(options \\ []) do
options |> to_dest |> GenServer.call(:enable_send_orders)
end
def disable_send_orders(options \\ []) do
options |> to_dest |> GenServer.call(:disable_send_orders)
end
def init(state) do
{:ok, state}
end
def handle_call(:accounts, _from, state) do
{:reply, Tai.Commander.Accounts.get(), state}
end
def handle_call(:products, _from, state) do
{:reply, Tai.Commander.Products.get(), state}
end
def handle_call(:fees, _from, state) do
{:reply, Tai.Commander.Fees.get(), state}
end
def handle_call(:markets, _from, state) do
{:reply, Tai.Commander.Markets.get(), state}
end
def handle_call({:orders, query, options}, _from, state) do
{:reply, Tai.Commander.Orders.get(query, options), state}
end
def handle_call({:orders_count, query}, _from, state) do
{:reply, Tai.Commander.OrdersCount.get(query), state}
end
def handle_call({:get_order_by_client_id, client_id}, _from, state) do
{:reply, Tai.Commander.GetOrderByClientId.get(client_id), state}
end
def handle_call({:get_orders_by_client_ids, client_ids}, _from, state) do
{:reply, Tai.Commander.GetOrdersByClientIds.get(client_ids), state}
end
def handle_call({:order_transitions, client_id, query, options}, _from, state) do
{:reply, Tai.Commander.OrderTransitions.get(client_id, query, options), state}
end
def handle_call({:order_transitions_count, client_id, query}, _from, state) do
{:reply, Tai.Commander.OrderTransitionsCount.get(client_id, query), state}
end
def handle_call({:failed_order_transitions, client_id, query, options}, _from, state) do
{:reply, Tai.Commander.FailedOrderTransitions.get(client_id, query, options), state}
end
def handle_call({:failed_order_transitions_count, client_id, query}, _from, state) do
{:reply, Tai.Commander.FailedOrderTransitionsCount.get(client_id, query), state}
end
def handle_call(:delete_all_orders, _from, state) do
{:reply, Tai.Commander.DeleteAllOrders.execute(), state}
end
def handle_call(:positions, _from, state) do
{:reply, Tai.Commander.Positions.get(), state}
end
def handle_call({:venues, options}, _from, state) do
{:reply, Tai.Commander.Venues.get(options), state}
end
def handle_call({:start_venue, venue_id, options}, _from, state) do
{:reply, Tai.Commander.StartVenue.execute(venue_id, options), state}
end
def handle_call({:stop_venue, venue_id, store_id}, _from, state) do
{:reply, Tai.Commander.StopVenue.execute(venue_id, store_id), state}
end
def handle_call({:fleets, options}, _from, state) do
{:reply, Tai.Commander.Fleets.get(options), state}
end
def handle_call({:advisors, options}, _from, state) do
{:reply, Tai.Commander.Advisors.get(options), state}
end
def handle_call({:start_advisors, options}, _from, state) do
{:reply, Tai.Commander.StartAdvisors.execute(options), state}
end
def handle_call({:stop_advisors, options}, _from, state) do
{:reply, Tai.Commander.StopAdvisors.execute(options), state}
end
def handle_call(:settings, _from, state) do
{:reply, Tai.Commander.Settings.get(), state}
end
def handle_call(:enable_send_orders, _from, state) do
{:reply, Tai.Commander.EnableSendOrders.execute(), state}
end
def handle_call(:disable_send_orders, _from, state) do
{:reply, Tai.Commander.DisableSendOrders.execute(), state}
end
defp to_dest(options) do
options
|> Keyword.get(:node)
|> case do
nil -> __MODULE__
node -> {__MODULE__, node}
end
end
end