Futu (futu v2.8.0)

Futu Elixir API Client

Link to this section Summary

Functions

1004 KeepAlive Cast for the heartbeat, no reply This function will execute in Futu.GenServer automatically

1001 InitConnect This function will execute in Futu.GenServer automatically

3103 Qot_RequestHistoryKL

This is the main function of intereacting Futu TCP client. Three steps here

Refer to historical/1, I don't like the function name

Futu client gen server

Link to this section Types

Specs

server() :: GenServer.server()

Link to this section Functions

Specs

_heartbeat() :: binary()

1004 KeepAlive Cast for the heartbeat, no reply This function will execute in Futu.GenServer automatically

Link to this function

_init_connect(pid)

Specs

_init_connect(server()) :: {:ok, any()} | {:error, bitstring()}

1001 InitConnect This function will execute in Futu.GenServer automatically

Link to this function

account_funds(pid, opts)

Specs

account_funds(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

account_list(pid, opts)

Specs

account_list(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

get_conn_id(pid)

Specs

get_conn_id(server()) :: integer()
Link to this function

historical(pid, list)

Specs

historical(server(), list()) :: {:ok, any()} | {:error, bitstring()}

3103 Qot_RequestHistoryKL

Paramters

required:

  • period, checkout Futu.Quote.Historical.period/1
  • market, checkout Futu.Quote.Historical.market/1
  • code, e.g. 1

optional:

  • rehab, checkout Futu.Quote.Historical.rehab/1
  • from, default ~N[1999-01-01 00:00:00]
  • to, default now
  • max_rows, integer
  • next_page_key, if it's included from the last response
  • extended_time, boolean, to get the pre-market and after-hours data of US stocks, only supports timeframe of 1-minute
Link to this function

history_order_list(pid, opts)

Specs

history_order_list(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

max_trade_quantities(pid, opts)

Specs

max_trade_quantities(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

order_list(pid, opts)

Specs

order_list(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

place_order(pid, opts)

Specs

place_order(server(), list()) ::
  {:ok, Trd_PlaceOrder.S2C.t()} | {:error, bitstring()}
Link to this function

position_list(pid, opts)

Specs

position_list(server(), list()) ::
  {:ok, Trd_GetPositionList.S2C.t()} | {:error, bitstring()}
Link to this function

request(pid, module, opts)

Specs

request(server(), module(), list()) :: {:ok, any()} | {:error, bitstring()}

This is the main function of intereacting Futu TCP client. Three steps here:

  1. build request: opts -> module.encode/1 -> Request.build/3
  2. send tcp message by GenServer
  3. parse response: tcp_reply -> Response.parse/2 success -> module.decode/1
             success
             request failure
    header failure
Link to this function

request_history_kl(pid, list)

Specs

request_history_kl(server(), list()) :: {:ok, any()} | {:error, bitstring()}

Refer to historical/1, I don't like the function name

Link to this function

security_snapshot(pid, list)

Specs

security_snapshot(server(), list()) ::
  {:ok, Qot_GetSecuritySnapshot.S2C.t()} | {:error, bitstring()}
Link to this function

start(opts \\ %{})

Specs

start(%{host: bitstring(), port: integer(), name: server()} | map()) ::
  {:ok, pid()}

Futu client gen server

Link to this function

subscription(pid, opts)

Specs

subscription(server(), list()) :: {:ok, any()} | {:error, bitstring()}
Link to this function

unlock_trade(pid, opts)

Specs

unlock_trade(server(), list()) ::
  {:ok, Trd_UnlockTrade.S2C.t()} | {:error, bitstring()}