Alpa (AlpaEx v1.0.3)
View SourceElixir client library for the Alpaca Trading API.
Quick Start
Set your API credentials as environment variables:
export APCA_API_KEY_ID="your-key"
export APCA_API_SECRET_KEY="your-secret"
export APCA_USE_PAPER="true" # optional, defaults to trueThen use the API:
# Get account info
{:ok, account} = Alpa.account()
# Place a market order
{:ok, order} = Alpa.buy("AAPL", 10)
# Get positions
{:ok, positions} = Alpa.positions()
# Get market data
{:ok, bars} = Alpa.bars("AAPL", timeframe: "1Day")
# Get a market snapshot
{:ok, snapshot} = Alpa.snapshot("AAPL")Modules
For more advanced usage, use the specific modules:
Alpa.Trading.Account- Account info, config, activities, portfolio historyAlpa.Trading.Orders- Order placement and managementAlpa.Trading.Positions- Position managementAlpa.Trading.Assets- Asset informationAlpa.Trading.Watchlists- Watchlist CRUDAlpa.Trading.Market- Market clock and calendarAlpa.Trading.CorporateActions- Corporate action announcementsAlpa.MarketData.Bars- Historical bar dataAlpa.MarketData.Quotes- Historical quote dataAlpa.MarketData.Trades- Historical trade dataAlpa.MarketData.Snapshots- Market snapshotsAlpa.Stream.TradeUpdates- Real-time trade updatesAlpa.Stream.MarketData- Real-time market dataAlpa.Options.Contracts- Options contract searchAlpa.Crypto.Trading- Crypto trading operationsAlpa.Crypto.MarketData- Crypto bars, quotes, trades, snapshots, order booksAlpa.Crypto.Funding- Crypto transfers and wallets
Configuration
Configuration can be set via:
- Environment variables (recommended for credentials)
- Application config
- Options passed directly to functions
See Alpa.Config for details.
Summary
Functions
Get account information.
Get account configurations.
Get a specific asset.
Get all assets.
Get historical bars for a symbol.
Get historical bars for multiple symbols.
Place a market buy order.
Get the market calendar.
Cancel all orders.
Cancel an order.
Get the market clock.
Close all positions.
Close a position.
Get a specific corporate action announcement.
Get corporate action announcements.
Create a watchlist.
Get all available crypto assets.
Get historical crypto bars for a symbol.
Buy crypto with a market order.
Get latest crypto bars for a symbol.
Get latest crypto quotes for a symbol.
Get latest crypto trades for a symbol.
Place a crypto order.
Get all crypto positions.
Get historical crypto quotes for a symbol.
Sell crypto with a market order.
Get crypto snapshots for one or more symbols.
Get historical crypto trades for a symbol.
Get a specific crypto transfer.
List crypto funding transfers.
List crypto wallets.
Request a crypto withdrawal.
Delete a watchlist.
Get account activities.
Get account activities for a specific activity type.
Get an order by client order ID.
Get portfolio history.
Get the latest bar for a symbol.
Get latest bars for multiple symbols.
Get the latest quote for a symbol.
Get latest quotes for multiple symbols.
Get the latest trade for a symbol.
Get latest trades for multiple symbols.
Check if the market is open.
Get a specific option contract by symbol or ID.
Get option contracts with filtering.
Search for option contracts by underlying symbol.
Get a specific order.
Get all orders.
Place a new order.
Get a specific position.
Get all positions.
Get historical quotes for a symbol.
Get historical quotes for multiple symbols.
Replace (modify) an existing order.
Place a market sell order.
Get a market snapshot for a symbol.
Get market snapshots for multiple symbols.
Get historical trades for a symbol.
Get historical trades for multiple symbols.
Update account configurations.
Get a specific watchlist.
Get all watchlists.
Functions
Get account information.
See Alpa.Trading.Account.get/1 for details.
Get account configurations.
See Alpa.Trading.Account.get_configurations/1 for details.
Get a specific asset.
See Alpa.Trading.Assets.get/2 for details.
Get all assets.
See Alpa.Trading.Assets.list/1 for details.
Get historical bars for a symbol.
See Alpa.MarketData.Bars.get/2 for details.
Get historical bars for multiple symbols.
See Alpa.MarketData.Bars.get_multi/2 for details.
Place a market buy order.
See Alpa.Trading.Orders.buy/3 for details.
Get the market calendar.
See Alpa.Trading.Market.get_calendar/1 for details.
Cancel all orders.
See Alpa.Trading.Orders.cancel_all/1 for details.
Cancel an order.
See Alpa.Trading.Orders.cancel/2 for details.
Get the market clock.
See Alpa.Trading.Market.get_clock/1 for details.
Close all positions.
See Alpa.Trading.Positions.close_all/1 for details.
Close a position.
See Alpa.Trading.Positions.close/2 for details.
Get a specific corporate action announcement.
See Alpa.Trading.CorporateActions.get/2 for details.
Get corporate action announcements.
See Alpa.Trading.CorporateActions.list/1 for details.
Create a watchlist.
See Alpa.Trading.Watchlists.create/1 for details.
Get all available crypto assets.
See Alpa.Crypto.Trading.assets/1 for details.
Get historical crypto bars for a symbol.
See Alpa.Crypto.MarketData.bars/2 for details.
Buy crypto with a market order.
See Alpa.Crypto.Trading.buy/3 for details.
Get latest crypto bars for a symbol.
See Alpa.Crypto.MarketData.latest_bars/2 for details.
Get latest crypto quotes for a symbol.
See Alpa.Crypto.MarketData.latest_quotes/2 for details.
Get latest crypto trades for a symbol.
See Alpa.Crypto.MarketData.latest_trades/2 for details.
Place a crypto order.
See Alpa.Crypto.Trading.place_order/1 for details.
Get all crypto positions.
See Alpa.Crypto.Trading.positions/1 for details.
Get historical crypto quotes for a symbol.
See Alpa.Crypto.MarketData.quotes/2 for details.
Sell crypto with a market order.
See Alpa.Crypto.Trading.sell/3 for details.
Get crypto snapshots for one or more symbols.
See Alpa.Crypto.MarketData.snapshots/2 for details.
Get historical crypto trades for a symbol.
See Alpa.Crypto.MarketData.trades/2 for details.
Get a specific crypto transfer.
See Alpa.Crypto.Funding.get_transfer/2 for details.
List crypto funding transfers.
See Alpa.Crypto.Funding.list_transfers/1 for details.
List crypto wallets.
See Alpa.Crypto.Funding.list_wallets/1 for details.
Request a crypto withdrawal.
See Alpa.Crypto.Funding.create_transfer/1 for details.
Delete a watchlist.
See Alpa.Trading.Watchlists.delete/2 for details.
Get account activities.
See Alpa.Trading.Account.get_activities/1 for details.
Get account activities for a specific activity type.
See Alpa.Trading.Account.get_activities_by_type/2 for details.
Get an order by client order ID.
See Alpa.Trading.Orders.get_by_client_id/2 for details.
Get portfolio history.
See Alpa.Trading.Account.get_portfolio_history/1 for details.
Get the latest bar for a symbol.
See Alpa.MarketData.Bars.latest/2 for details.
Get latest bars for multiple symbols.
See Alpa.MarketData.Bars.latest_multi/2 for details.
Get the latest quote for a symbol.
See Alpa.MarketData.Quotes.latest/2 for details.
Get latest quotes for multiple symbols.
See Alpa.MarketData.Quotes.latest_multi/2 for details.
Get the latest trade for a symbol.
See Alpa.MarketData.Trades.latest/2 for details.
Get latest trades for multiple symbols.
See Alpa.MarketData.Trades.latest_multi/2 for details.
Check if the market is open.
See Alpa.Trading.Market.open?/1 for details.
Get a specific option contract by symbol or ID.
See Alpa.Options.Contracts.get/2 for details.
Get option contracts with filtering.
See Alpa.Options.Contracts.list/1 for details.
Search for option contracts by underlying symbol.
See Alpa.Options.Contracts.search/2 for details.
Get a specific order.
See Alpa.Trading.Orders.get/2 for details.
Get all orders.
See Alpa.Trading.Orders.list/1 for details.
Place a new order.
See Alpa.Trading.Orders.place/1 for details.
Get a specific position.
See Alpa.Trading.Positions.get/2 for details.
Get all positions.
See Alpa.Trading.Positions.list/1 for details.
Get historical quotes for a symbol.
See Alpa.MarketData.Quotes.get/2 for details.
Get historical quotes for multiple symbols.
See Alpa.MarketData.Quotes.get_multi/2 for details.
Replace (modify) an existing order.
See Alpa.Trading.Orders.replace/2 for details.
Place a market sell order.
See Alpa.Trading.Orders.sell/3 for details.
Get a market snapshot for a symbol.
See Alpa.MarketData.Snapshots.get/2 for details.
Get market snapshots for multiple symbols.
See Alpa.MarketData.Snapshots.get_multi/2 for details.
Get historical trades for a symbol.
See Alpa.MarketData.Trades.get/2 for details.
Get historical trades for multiple symbols.
See Alpa.MarketData.Trades.get_multi/2 for details.
Update account configurations.
See Alpa.Trading.Account.update_configurations/1 for details.
Get a specific watchlist.
See Alpa.Trading.Watchlists.get/2 for details.
Get all watchlists.
See Alpa.Trading.Watchlists.list/1 for details.