alpa v0.1.6 Alpa View Source
api wrapper for alpaca.markets
calls return:
{:ok, result} on success
{:error, reason} on failure
Link to this section Summary
Functions
gets account info
get account config
get asset by id or symbol
list assets
list bars
buy day market order wrapper
get the calendar
get the market clock
close a position by symbol
close all positions
create a watchlist
delete all orders
delete an order
delete a watchlist by id
auth headers for api
get portfolio history
get market open status
get an order
get an order by client order id
list all orders
places an order
get asset by id or symbol
list open positions
sell day market order wrapper
update account config
updates an order
get watchlists by id
add an asset to a watchlist
gets id of watchlist by name
list watchlists
Link to this section Functions
gets account info
get account config
get asset by id or symbol
list assets
list bars
paper money account, IEX data only
(uses 'v1')
https://docs.alpaca.markets/api-documentation/api-v2/market-data/bars/
Retrieves a list of bars for each requested symbol. It is guaranteed all bars are in ascending order by time.
for alpaca api, timestamps are ISO 8601 ('2019-04-15T09:30:00-04:00')
for Alpa, timestamps are Elixir DateTimes
params: alpaca api type/Elixir type
- timeframe: string, default = "1Min" ["minute", "1Min", "5Min", "15Min", "day" or "1D"]
- symbols: string, (comma separated list)
- limit : int, default = 100 (1000 max)
- start_time : timestamp, (cannot be used with :after)
- end_time : timestamp, (cannot be used with :until)
- after : timestamp, (cannot be used with :start)
- until : timestamp, (cannot be used with :until)
note: :end, :after, :until -> :*_time due to Elixir keyword conflict
returns Bars response (list of symbols with lists of bar objects)
%{:ok,
[
%{symbol: "AAPL",
[
%{t: 1544129220,
o: 172.26,
h: 172.3,
l: 172.16,
c: 172.18,
v: 3892,
}
]
}
]
}
- t : the beginning time of this bar as a Unix epoch in seconds, int
- o : open price, float
- h : high price, float
- l : low price, float
- c : close price, float
- v : volume, int
buy day market order wrapper
calendar(start_time \\ Date.utc_today, end_time \\ Date.utc_today)
View Sourceget the calendar
1970 - 2029
get the market clock
close a position by symbol
close all positions
create a watchlist
delete all orders
delete an order
delete a watchlist by id
auth headers for api
history(period \\ "1M", timeframe \\ "1D", date_end \\ Date.utc_today, extended_hours \\ false)
View Sourceget portfolio history
get market open status
get an order
get an order by client order id
list all orders
place_order(symbol, qty, side, type, time_in_force \\ "day", limit_price \\ nil, stop_price \\ nil)
View Sourceplaces an order
get asset by id or symbol
list open positions
sell day market order wrapper
update_account_config(dtbp_check \\ "entry", trade_confirm_email \\ "all", suspend_trade \\ false, no_shorting \\ false)
View Sourceupdate account config
- dtbp_check : string, [both, entry, or exit] Controls Day Trading Margin Call (DTMC) checks.
- trade_confirm_email : string [all or none]
- suspend_trade : bool
- no_shorting : bool
update_order(order_id, qty, time_in_force \\ "day", limit_price \\ nil, stop_price \\ nil)
View Sourceupdates an order
get watchlists by id
add an asset to a watchlist
gets id of watchlist by name
returns:
{:ok, id} on success
{:error, reason} on failure
list watchlists