futu-elixir
Futu API in Elixir
Document
Official documentation: Futu API 文檔 v5.6
Before anything
Make sure you have FutuOpenD executable downloaded on your machine. Checkout the official document if you have no idea about this thing.
If you want to use it in docker container or deployment on cloud instances, futu-opend-docker.
Installation
def deps do
[
{:futu, "~> 2.0.0"}
]
end
Usage
Start GenServer
{:ok, _pid} = Futu.start(%{host: "localhost", port: 11_111, name: :futu_client})
Retrieve historical stocks data
opts = [
market: Futu.Quote.Historical.market(:hk_security),
code: 1,
period: Futu.Quote.Historical.period(:daily),
from: ~N[2021-08-08 00:00:00],
max_rows: 5
]
{:ok, stocks} = Futu.historical(:futu_client, opts) # Protocol ID 3103
About InitConnect and KeepAlive
Both are automatically intiated and supervised in GenServers when the application start, no extra care required for this part.