Packages

Elixir client library for cryptocurrency exchanges — generated from CCXT specs via compile-time macros.

Current section

Files

Jump to
ccxt_client priv specs extracted alpaca.exs
Raw

priv/specs/extracted/alpaca.exs

# Alpaca Exchange Specification
#
# Auto-generated by: mix ccxt.extract alpaca
# CCXT version: 4.5.42
# Spec format version: 2
#
# Review before use:
# - signing: Detected from sign() method, verify with testnet
# - endpoints: Raw paths extracted, map to unified API as needed
# - exceptions: Extracted (exact, broad, HTTP status codes)
# - features/options: Extracted from describe()
# - classification: Set to :supported initially, promote after validation
#
%{
api_param_requirements: nil,
certified: false,
classification: :pro,
comment: nil,
countries: [
"US"
],
currencies: %{},
currency_aliases: %{
"BCHSV" => "BSV",
"XBT" => "BTC"
},
dex: false,
enable_rate_limit: true,
endpoint_extraction_stats: %{
"capturedMethods" => 29,
"coveragePercent" => 100,
"enabledMethods" => 30,
"excluded" => [],
"excludedMethods" => 0,
"extractableMethods" => 30,
"failures" => [
%{
"error" => "alpaca fetchL1OrderBook() is not implemented (has.fetchL1OrderBook: true but method is undefined)",
"method" => "fetchL1OrderBook"
}
]
},
endpoints: [
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :list,
market_type: :spot,
method: :delete,
name: :cancel_all_orders,
param_mappings: %{},
params: [
:symbol
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :delete,
name: :cancel_order,
param_mappings: %{
"id" => "order_id"
},
params: [
:id,
:symbol
],
path: "/v2/orders/{order_id}",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_a95f7c7fa0074fc3bfc0a11b0828f7d2",
"time_in_force" => "gtc",
"type" => "limit"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_limit_order,
param_mappings: %{
"amount" => "qty",
"price" => "limit_price"
},
params: [
:symbol,
:side,
:amount,
:price
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_1f155b1edb9c4a70a2e025bede41499b",
"side" => "buy",
"time_in_force" => "gtc",
"type" => "market"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_market_buy_order,
param_mappings: %{
"amount" => "qty"
},
params: [
:symbol,
:amount
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_ebaf230e552747cbb736b350ac2f5302",
"side" => "buy",
"time_in_force" => "gtc",
"type" => "market"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_market_buy_order_with_cost,
param_mappings: %{
"cost" => "notional"
},
params: [
:symbol,
:cost
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_f2ee27a0a41742ff8f228c204accf199",
"time_in_force" => "gtc",
"type" => "market"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_market_order,
param_mappings: %{
"amount" => "qty"
},
params: [
:symbol,
:side,
:amount,
:price
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_a5e0827e60764209be9d38b07d0d149a",
"time_in_force" => "gtc",
"type" => "market"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_market_order_with_cost,
param_mappings: %{
"cost" => "notional"
},
params: [
:symbol,
:side,
:cost
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_88adfecfff794be48fa3c94070f4c512",
"time_in_force" => "gtc"
},
expects: :single,
market_type: :spot,
method: :post,
name: :create_order,
param_mappings: %{
"amount" => "qty",
"price" => "limit_price"
},
params: [
:symbol,
:type,
:side,
:amount,
:price
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_70af7da2243a4e208720a7d399403d9f",
"time_in_force" => "gtc",
"triggerDirection" => "below"
},
expects: :single,
market_type: :swap,
method: :post,
name: :create_stop_order,
param_mappings: %{
"amount" => "qty",
"price" => "limit_price",
"triggerPrice" => "stopPrice"
},
params: [
:symbol,
:type,
:side,
:amount,
:price,
:triggerPrice
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_cbe41307368242cca083da949664db1d",
"time_in_force" => "gtc",
"triggerDirection" => "below",
"type" => "stop_limit"
},
expects: :single,
market_type: :swap,
method: :post,
name: :create_trigger_order,
param_mappings: %{
"amount" => "qty",
"price" => "limit_price",
"triggerPrice" => "stop_price"
},
params: [
:symbol,
:type,
:side,
:amount,
:price,
:triggerPrice
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"client_order_id" => "ccxt_6f7ffb55debd445c841bd5e0219e9cc9",
"time_in_force" => "gtc"
},
expects: :single,
market_type: :spot,
method: :patch,
name: :edit_order,
param_mappings: %{
"amount" => "qty",
"id" => "order_id",
"price" => "limit_price"
},
params: [
:id,
:symbol,
:type,
:side,
:amount,
:price
],
path: "/v2/orders/{order_id}",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_balance,
param_mappings: %{},
params: [],
path: "/v2/account",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"status" => "closed"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_closed_orders,
param_mappings: %{
"symbol" => "symbols"
},
params: [
:symbol,
:since,
:limit
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_deposit_address,
param_mappings: %{
"code" => "asset"
},
params: [
:code
],
path: "/v2/wallets",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_deposits,
param_mappings: %{},
params: [
:code,
:since,
:limit
],
path: "/v2/wallets/transfers",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_deposits_withdrawals,
param_mappings: %{},
params: [
:code,
:since,
:limit
],
path: "/v2/wallets/transfers",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"asset_class" => "crypto",
"status" => "active"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_markets,
param_mappings: %{},
params: [],
path: "/v2/assets",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"activity_type" => "FILL"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_my_trades,
param_mappings: %{},
params: [
:symbol,
:since,
:limit
],
path: "/v2/account/activities/{activity_type}",
source: :intercepted
},
%{
api_section: "market/public",
auth: false,
cost: 1,
default_params: %{
"loc" => "us",
"start" => "2024-01-01"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_ohlcv,
param_mappings: %{
"since" => "start",
"symbol" => "symbols"
},
params: [
:symbol,
:timeframe,
:since,
:limit
],
path: "/v1beta3/crypto/{loc}/bars",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"status" => "open"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_open_orders,
param_mappings: %{
"symbol" => "symbols"
},
params: [
:symbol,
:since,
:limit
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_order,
param_mappings: %{
"id" => "order_id"
},
params: [
:id,
:symbol
],
path: "/v2/orders/{order_id}",
source: :intercepted
},
%{
api_section: "market/public",
auth: false,
cost: 1,
default_params: %{
"loc" => "us"
},
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_order_book,
param_mappings: %{
"symbol" => "symbols"
},
params: [
:symbol,
:limit
],
path: "/v1beta3/crypto/{loc}/latest/orderbooks",
response_transformer: {:extract_path_unwrap, ["orderbooks"]},
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
default_params: %{
"status" => "all"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_orders,
param_mappings: %{
"symbol" => "symbols"
},
params: [
:symbol,
:since,
:limit
],
path: "/v2/orders",
source: :intercepted
},
%{
api_section: "market/public",
auth: false,
cost: 1,
default_params: %{
"loc" => "us"
},
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_ticker,
param_mappings: %{
"symbol" => "symbols"
},
params: [
:symbol
],
path: "/v1beta3/crypto/{loc}/snapshots",
response_transformer: {:extract_path_unwrap, ["snapshots"]},
source: :intercepted
},
%{
api_section: "market/public",
auth: false,
cost: 1,
default_params: %{
"loc" => "us",
"symbols" => "BTCUSDT"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_tickers,
param_mappings: %{},
params: [
:symbols
],
path: "/v1beta3/crypto/{loc}/snapshots",
response_transformer: {:extract_path, ["snapshots"]},
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :get,
name: :fetch_time,
param_mappings: %{},
params: [],
path: "/v2/clock",
source: :intercepted
},
%{
api_section: "market/public",
auth: false,
cost: 1,
default_params: %{
"loc" => "us",
"start" => "2024-01-01T00:00:00.000Z"
},
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_trades,
param_mappings: %{
"since" => "start",
"symbol" => "symbols"
},
params: [
:symbol,
:since,
:limit
],
path: "/v1beta3/crypto/{loc}/trades",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :list,
market_type: :spot,
method: :get,
name: :fetch_withdrawals,
param_mappings: %{},
params: [
:code,
:since,
:limit
],
path: "/v2/wallets/transfers",
source: :intercepted
},
%{
api_section: "trader/private",
auth: true,
cost: 1,
expects: :single,
market_type: :spot,
method: :post,
name: :withdraw,
param_mappings: %{
"code" => "asset"
},
params: [
:code,
:amount,
:address,
:tag
],
path: "/v2/wallets/transfers",
source: :intercepted
}
],
error_code_details: %{
40010001 => %{
description: "invalid order type for crypto order",
type: :invalid_parameters
},
40110000 => %{
description: "request is not authorized",
type: :access_restricted
},
40310000 => %{
description: "insufficient balance for USDT (requested: 221.63, available: 0)",
type: :insufficient_balance
},
40410000 => %{
description: "order is not found.",
type: :invalid_order
},
42910000 => %{
description: "rate limit exceeded",
type: :rate_limited
},
"Invalid format for parameter" => %{
description: "Invalid format for parameter start: error parsing '0' as RFC3339 or 2006-01-02 time: parsing time \"0\" as \"2006-01-02\": cannot parse \"0\" as \"2006\"",
type: :invalid_parameters
},
"Invalid symbol" => %{
description: "Invalid symbol(s): BTC/USDdsda does not match ^[A-Z]+/[A-Z]+$",
type: :invalid_order
},
"forbidden." => %{
description: "forbidden.",
type: :access_restricted
}
},
error_codes: %{
40010001 => :invalid_parameters,
40110000 => :access_restricted,
40310000 => :insufficient_balance,
40410000 => :invalid_order,
42910000 => :rate_limited,
"Invalid format for parameter" => :invalid_parameters,
"Invalid symbol" => :invalid_order,
"forbidden." => :access_restricted
},
exceptions: %{
broad: %{
"Invalid format for parameter" => :bad_request,
"Invalid symbol" => :bad_symbol
},
exact: %{
"40010001" => :bad_request,
"40110000" => :permission_denied,
"40310000" => :insufficient_funds,
"40410000" => :invalid_order,
"42910000" => :rate_limit_exceeded,
"forbidden." => :permission_denied
}
},
exchange_options: %{
"clientOrderId" => "ccxt_{id}",
"defaultExchange" => "CBSE",
"defaultNetworkCodeReplacements" => %{
"BRC20" => %{
"BRC20" => "BTC"
},
"CRO" => %{
"CRC20" => "CRONOS"
},
"ETH" => %{
"ERC20" => "ETH"
},
"TRX" => %{
"TRC20" => "TRX"
}
},
"defaultTimeInForce" => "gtc",
"exchanges" => [
"CBSE",
"FTX",
"GNSS",
"ERSX"
],
"networksById" => %{}
},
extended_metadata: %{
fees_url: "https://docs.alpaca.markets/docs/crypto-fees",
limits: %{
"amount" => %{},
"cost" => %{},
"leverage" => %{},
"price" => %{}
},
logo_url: "https://github.com/user-attachments/assets/e9476df8-a450-4c3e-ab9a-1a7794219e1b"
},
extracted_metadata: %{
ccxt_version: "4.5.42"
},
features: %{
future: %{},
spot: %{
create_order: %{
attached_stop_loss_take_profit: %{
price: true,
trigger_price_type: %{
index: true,
last: true,
mark: true
}
},
hedged: false,
iceberg: false,
leverage: false,
margin_mode: false,
market_buy_by_cost: false,
market_buy_requires_price: false,
self_trade_prevention: false,
stop_loss_price: false,
take_profit_price: false,
time_in_force: %{
fok: true,
gtd: false,
ioc: true,
po: true
},
trailing: true,
trigger_direction: false,
trigger_price: true
},
fetch_closed_orders: %{
days_back: 100000,
limit: 500,
margin_mode: false,
symbol_required: false,
trailing: false,
trigger: false,
until_days: 100000
},
fetch_my_trades: %{
days_back: 100000,
limit: 100,
margin_mode: false,
symbol_required: false,
until_days: 100000
},
fetch_ohlcv: %{
limit: 1000
},
fetch_open_orders: %{
limit: 500,
margin_mode: false,
symbol_required: false,
trailing: false,
trigger: false
},
fetch_order: %{
margin_mode: false,
symbol_required: false,
trailing: false,
trigger: false
},
fetch_orders: %{
days_back: 100000,
limit: 500,
margin_mode: false,
symbol_required: false,
trailing: false,
trigger: false,
until_days: 100000
},
sandbox: true
},
swap: %{}
},
fees: %{
trading: %{
maker: 0.0015,
percentage: true,
taker: 0.0025,
tier_based: true,
tiers: %{
maker: [
%{
fee: 0.0015,
volume: 0
},
%{
fee: 0.0012,
volume: 100000
},
%{
fee: 0.001,
volume: 500000
},
%{
fee: 0.0008,
volume: 1000000
},
%{
fee: 0.0005,
volume: 10000000
},
%{
fee: 0.0002,
volume: 25000000
},
%{
fee: 0.0002,
volume: 50000000
},
%{
fee: 0,
volume: 100000000
}
],
taker: [
%{
fee: 0.0025,
volume: 0
},
%{
fee: 0.0022,
volume: 100000
},
%{
fee: 0.002,
volume: 500000
},
%{
fee: 0.0018,
volume: 1000000
},
%{
fee: 0.0015,
volume: 10000000
},
%{
fee: 0.0013,
volume: 25000000
},
%{
fee: 0.0012,
volume: 50000000
},
%{
fee: 0.001,
volume: 100000000
}
]
}
}
},
forward_aliases: nil,
handle_content_type_application_zip: nil,
handle_errors_source: "handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {\n if (response === undefined) {\n return undefined; // default error handler\n }\n // {\n // \"code\": 40110000,\n // \"message\": \"request is not authorized\"\n // }\n const feedback = this.id + ' ' + body;\n const errorCode = this.safeString(response, 'code');\n if (code !== undefined) {\n this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);\n }\n const message = this.safeValue(response, 'message', undefined);\n if (message !== undefined) {\n this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);\n this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);\n throw new errors.ExchangeError(feedback);\n }\n return undefined;\n }",
has: %{
add_margin: false,
borrow_cross_margin: false,
borrow_isolated_margin: false,
borrow_margin: false,
c_o_r_s: false,
cancel_all_orders: true,
cancel_all_orders_ws: false,
cancel_order: true,
cancel_order_with_client_order_id: false,
cancel_order_ws: false,
cancel_orders: false,
cancel_orders_with_client_order_id: false,
cancel_orders_ws: false,
close_all_positions: false,
close_position: false,
create_deposit_address: false,
create_limit_buy_order: false,
create_limit_buy_order_ws: false,
create_limit_order: true,
create_limit_order_ws: false,
create_limit_sell_order: false,
create_limit_sell_order_ws: false,
create_market_buy_order: true,
create_market_buy_order_with_cost: true,
create_market_buy_order_with_cost_ws: false,
create_market_buy_order_ws: false,
create_market_order: true,
create_market_order_with_cost: true,
create_market_order_with_cost_ws: false,
create_market_order_ws: true,
create_market_sell_order: false,
create_market_sell_order_with_cost: false,
create_market_sell_order_with_cost_ws: false,
create_market_sell_order_ws: false,
create_order: true,
create_order_with_take_profit_and_stop_loss: false,
create_order_with_take_profit_and_stop_loss_ws: false,
create_order_ws: false,
create_orders: false,
create_post_only_order: false,
create_post_only_order_ws: false,
create_reduce_only_order: false,
create_reduce_only_order_ws: false,
create_stop_limit_order: false,
create_stop_limit_order_ws: false,
create_stop_loss_order: false,
create_stop_loss_order_ws: false,
create_stop_market_order: false,
create_stop_market_order_ws: false,
create_stop_order: true,
create_stop_order_ws: false,
create_take_profit_order: false,
create_take_profit_order_ws: false,
create_trailing_amount_order: false,
create_trailing_amount_order_ws: false,
create_trailing_percent_order: false,
create_trailing_percent_order_ws: false,
create_trigger_order: true,
create_trigger_order_ws: false,
deposit: false,
edit_order: true,
edit_order_with_client_order_id: false,
edit_order_ws: false,
edit_orders: false,
fetch_a_d_l_rank: false,
fetch_accounts: false,
fetch_balance: true,
fetch_balance_ws: false,
fetch_bids_asks: false,
fetch_borrow_interest: false,
fetch_borrow_rate: false,
fetch_borrow_rate_histories: false,
fetch_borrow_rate_history: false,
fetch_borrow_rates: false,
fetch_borrow_rates_per_symbol: false,
fetch_canceled_and_closed_orders: false,
fetch_canceled_orders: false,
fetch_closed_order: false,
fetch_closed_orders: true,
fetch_closed_orders_ws: false,
fetch_convert_currencies: false,
fetch_convert_quote: false,
fetch_convert_trade: false,
fetch_convert_trade_history: false,
fetch_cross_borrow_rate: false,
fetch_cross_borrow_rates: false,
fetch_currencies: false,
fetch_currencies_ws: true,
fetch_deposit: false,
fetch_deposit_address: true,
fetch_deposit_addresses: false,
fetch_deposit_addresses_by_network: false,
fetch_deposit_withdraw_fee: false,
fetch_deposit_withdraw_fees: false,
fetch_deposits: true,
fetch_deposits_withdrawals: true,
fetch_deposits_ws: false,
fetch_funding_history: false,
fetch_funding_interval: false,
fetch_funding_intervals: false,
fetch_funding_rate: false,
fetch_funding_rate_history: false,
fetch_funding_rates: false,
fetch_greeks: false,
fetch_index_ohlcv: false,
fetch_isolated_borrow_rate: false,
fetch_isolated_borrow_rates: false,
fetch_isolated_positions: false,
fetch_l1_order_book: true,
fetch_l2_order_book: false,
fetch_l3_order_book: false,
fetch_last_prices: false,
fetch_ledger: false,
fetch_ledger_entry: false,
fetch_leverage: false,
fetch_leverage_tiers: false,
fetch_leverages: false,
fetch_liquidations: false,
fetch_long_short_ratio: false,
fetch_long_short_ratio_history: false,
fetch_margin_adjustment_history: false,
fetch_margin_mode: false,
fetch_margin_modes: false,
fetch_mark_ohlcv: false,
fetch_mark_prices: false,
fetch_market_leverage_tiers: false,
fetch_markets: true,
fetch_markets_ws: false,
fetch_my_liquidations: false,
fetch_my_settlement_history: false,
fetch_my_trades: true,
fetch_my_trades_ws: false,
fetch_ohlcv: true,
fetch_ohlcv_ws: false,
fetch_open_interest: false,
fetch_open_interest_history: false,
fetch_open_interests: false,
fetch_open_order: false,
fetch_open_orders: true,
fetch_open_orders_ws: false,
fetch_option: false,
fetch_option_chain: false,
fetch_order: true,
fetch_order_book: true,
fetch_order_book_ws: false,
fetch_order_books: false,
fetch_order_trades: false,
fetch_order_with_client_order_id: false,
fetch_order_ws: false,
fetch_orders: true,
fetch_orders_by_status: false,
fetch_orders_ws: false,
fetch_position: false,
fetch_position_a_d_l_rank: false,
fetch_position_history: false,
fetch_position_mode: false,
fetch_position_ws: false,
fetch_positions: false,
fetch_positions_a_d_l_rank: false,
fetch_positions_for_symbol: false,
fetch_positions_for_symbol_ws: false,
fetch_positions_history: false,
fetch_positions_risk: false,
fetch_positions_ws: false,
fetch_premium_index_ohlcv: false,
fetch_settlement_history: false,
fetch_status: false,
fetch_ticker: true,
fetch_ticker_ws: false,
fetch_tickers: true,
fetch_tickers_ws: false,
fetch_time: true,
fetch_trades: true,
fetch_trades_ws: false,
fetch_trading_fee: false,
fetch_trading_fees: false,
fetch_trading_fees_ws: false,
fetch_trading_limits: false,
fetch_transaction_fee: false,
fetch_transaction_fees: false,
fetch_transactions: false,
fetch_transfer: false,
fetch_transfers: false,
fetch_underlying_assets: false,
fetch_volatility_history: false,
fetch_withdraw_addresses: false,
fetch_withdrawal: false,
fetch_withdrawal_whitelist: false,
fetch_withdrawals: true,
fetch_withdrawals_ws: false,
future: false,
margin: false,
option: false,
private_api: true,
public_api: true,
reduce_margin: false,
repay_cross_margin: false,
repay_isolated_margin: false,
sandbox: true,
set_leverage: false,
set_margin: false,
set_margin_mode: false,
set_position_mode: false,
sign_in: false,
spot: true,
swap: false,
transfer: false,
un_watch_my_trades: false,
un_watch_ohlcv: false,
un_watch_ohlcv_for_symbols: false,
un_watch_order_book: false,
un_watch_order_book_for_symbols: false,
un_watch_orders: false,
un_watch_positions: false,
un_watch_ticker: false,
un_watch_tickers: false,
un_watch_trades: false,
un_watch_trades_for_symbols: false,
watch_balance: false,
watch_bids_asks: false,
watch_liquidations: false,
watch_liquidations_for_symbols: false,
watch_mark_price: false,
watch_mark_prices: false,
watch_my_liquidations: false,
watch_my_liquidations_for_symbols: false,
watch_my_trades: true,
watch_ohlcv: true,
watch_ohlcv_for_symbols: false,
watch_order_book: true,
watch_order_book_for_symbols: false,
watch_orders: true,
watch_orders_for_symbols: false,
watch_position: false,
watch_positions: false,
watch_status: false,
watch_ticker: true,
watch_tickers: false,
watch_trades: true,
watch_trades_for_symbols: false,
withdraw: true,
ws: false
},
http_config: %{
headers: %{
"APCA-PARTNER-ID" => "ccxt"
}
},
id: "alpaca",
markets: nil,
name: "Alpaca",
ohlcv_timestamp_resolution: :unknown,
options: %{
"client_order_id" => "ccxt_{id}",
"default_exchange" => "CBSE",
:default_time_in_force => "gtc",
"exchanges" => [
"CBSE",
"FTX",
"GNSS",
"ERSX"
]
},
order_mappings: %{
side_format: :lowercase,
side_key: "side",
type_format: :lowercase,
type_key: "type"
},
param_mappings: %{
"amount" => "qty",
"code" => "asset",
"cost" => "notional",
"id" => "order_id",
"price" => "limit_price",
"since" => "start",
"symbol" => "symbols",
"triggerPrice" => "stop_price"
},
parse_methods: [
%{
"comment" => nil,
"examples" => [],
"line_end" => 1891,
"line_start" => 1882,
"mappings" => [],
"name" => "parseBalance",
"signature" => "parseBalance (response): Balances",
"source" => "parseBalance (response): Balances {\n const result: Dict = { 'info': response };\n const account = this.account ();\n const currencyId = this.safeString (response, 'currency');\n const code = this.safeCurrencyCode (currencyId);\n account['free'] = this.safeString (response, 'cash');\n account['total'] = this.safeString (response, 'equity');\n result[code] = account;\n return this.safeBalance (result);\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"asset_id\": \"4fa30c85-77b7-4cbc-92dd-7b7513640aad\",\n \"address\": \"bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r\",\n \"created_at\": \"2024-11-03T07:30:05.609976344Z\"\n }"
],
"line_end" => 1621,
"line_start" => 1602,
"mappings" => [
%{
"comment" => nil,
"key" => "info",
"value" => "depositAddress"
},
%{
"comment" => nil,
"key" => "currency",
"value" => "parsedCurrency"
},
%{
"comment" => nil,
"key" => "network",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "address",
"value" => "this.safeString (depositAddress, 'address')"
},
%{
"comment" => nil,
"key" => "tag",
"value" => "undefined"
}
],
"name" => "parseDepositAddress",
"signature" => "parseDepositAddress (depositAddress, currency: Currency = undefined): DepositAddress",
"source" => "parseDepositAddress (depositAddress, currency: Currency = undefined): DepositAddress {\n //\n // {\n // \"asset_id\": \"4fa30c85-77b7-4cbc-92dd-7b7513640aad\",\n // \"address\": \"bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r\",\n // \"created_at\": \"2024-11-03T07:30:05.609976344Z\"\n // }\n //\n let parsedCurrency = undefined;\n if (currency !== undefined) {\n parsedCurrency = currency['id'];\n }\n return {\n 'info': depositAddress,\n 'currency': parsedCurrency,\n 'network': undefined,\n 'address': this.safeString (depositAddress, 'address'),\n 'tag': undefined,\n } as DepositAddress;\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"id\": \"c150e086-1e75-44e6-9c2c-093bb1e93139\",\n \"class\": \"crypto\",\n \"exchange\": \"CRYPTO\",\n \"symbol\": \"BTC/USDT\",\n \"name\": \"Bitcoin / USD Tether\",\n \"status\": \"active\",\n \"tradable\": true,\n \"marginable\": false,\n \"maintenance_margin_requirement\": 101,\n \"shortable\": false,\n \"easy_to_borrow\": false,\n \"fractionable\": true,\n \"attributes\": [],\n \"min_order_size\": \"0.000026873\",\n \"min_trade_increment\": \"0.000000001\",\n \"price_increment\": \"1\"\n }"
],
"line_end" => 574,
"line_start" => 486,
"mappings" => [
%{
"comment" => nil,
"key" => "id",
"value" => "marketId"
},
%{
"comment" => nil,
"key" => "symbol",
"value" => "symbol"
},
%{
"comment" => nil,
"key" => "base",
"value" => "base"
},
%{
"comment" => nil,
"key" => "quote",
"value" => "quote"
},
%{
"comment" => nil,
"key" => "settle",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "baseId",
"value" => "baseId"
},
%{
"comment" => nil,
"key" => "quoteId",
"value" => "quoteId"
},
%{
"comment" => nil,
"key" => "settleId",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "type",
"value" => "'spot'"
},
%{
"comment" => nil,
"key" => "spot",
"value" => "true"
},
%{
"comment" => nil,
"key" => "margin",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "swap",
"value" => "false"
},
%{
"comment" => nil,
"key" => "future",
"value" => "false"
},
%{
"comment" => nil,
"key" => "option",
"value" => "false"
},
%{
"comment" => nil,
"key" => "active",
"value" => "active"
},
%{
"comment" => nil,
"key" => "contract",
"value" => "false"
},
%{
"comment" => nil,
"key" => "linear",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "inverse",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "contractSize",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "expiry",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "expiryDatetime",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "strike",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "optionType",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "precision",
"value" => "{\n 'amount': amount,\n 'price': price,\n }"
},
%{
"comment" => nil,
"key" => "limits",
"value" => "{\n 'leverage': {\n 'min': undefined,\n 'max': undefined,\n },\n 'amount': {\n 'min': minAmount,\n 'max': undefined,\n },\n 'price': {\n 'min': undefined,\n 'max': undefined,\n },\n 'cost': {\n 'min': undefined,\n 'max': undefined,\n },\n }"
},
%{
"comment" => nil,
"key" => "created",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "info",
"value" => "asset"
}
],
"name" => "parseMarket",
"signature" => "parseMarket (asset): Market",
"source" => "parseMarket (asset): Market {\n //\n // {\n // \"id\": \"c150e086-1e75-44e6-9c2c-093bb1e93139\",\n // \"class\": \"crypto\",\n // \"exchange\": \"CRYPTO\",\n // \"symbol\": \"BTC/USDT\",\n // \"name\": \"Bitcoin / USD Tether\",\n // \"status\": \"active\",\n // \"tradable\": true,\n // \"marginable\": false,\n // \"maintenance_margin_requirement\": 101,\n // \"shortable\": false,\n // \"easy_to_borrow\": false,\n // \"fractionable\": true,\n // \"attributes\": [],\n // \"min_order_size\": \"0.000026873\",\n // \"min_trade_increment\": \"0.000000001\",\n // \"price_increment\": \"1\"\n // }\n //\n const marketId = this.safeString (asset, 'symbol');\n const parts = marketId.split ('/');\n const assetClass = this.safeString (asset, 'class');\n const baseId = this.safeString (parts, 0);\n const quoteId = this.safeString (parts, 1);\n const base = this.safeCurrencyCode (baseId);\n let quote = this.safeCurrencyCode (quoteId);\n // Us equity markets do not include quote in symbol.\n // We can safely coerce us_equity quote to USD\n if (quote === undefined && assetClass === 'us_equity') {\n quote = 'USD';\n }\n const symbol = base + '/' + quote;\n const status = this.safeString (asset, 'status');\n const active = (status === 'active');\n const minAmount = this.safeNumber (asset, 'min_order_size');\n const amount = this.safeNumber (asset, 'min_trade_increment');\n const price = this.safeNumber (asset, 'price_increment');\n return {\n 'id': marketId,\n 'symbol': symbol,\n 'base': base,\n 'quote': quote,\n 'settle': undefined,\n 'baseId': baseId,\n 'quoteId': quoteId,\n 'settleId': undefined,\n 'type': 'spot',\n 'spot': true,\n 'margin': undefined,\n 'swap': false,\n 'future': false,\n 'option': false,\n 'active': active,\n 'contract': false,\n 'linear': undefined,\n 'inverse': undefined,\n 'contractSize': undefined,\n 'expiry': undefined,\n 'expiryDatetime': undefined,\n 'strike': undefined,\n 'optionType': undefined,\n 'precision': {\n 'amount': amount,\n 'price': price,\n },\n 'limits': {\n 'leverage': {\n 'min': undefined,\n 'max': undefined,\n },\n 'amount': {\n 'min': minAmount,\n 'max': undefined,\n },\n 'price': {\n 'min': undefined,\n 'max': undefined,\n },\n 'cost': {\n 'min': undefined,\n 'max': undefined,\n },\n },\n 'created': undefined,\n 'info': asset,\n };\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"c\":22895,\n \"h\":22895,\n \"l\":22884,\n \"n\":6,\n \"o\":22884,\n \"t\":\"2022-07-21T05:01:00Z\",\n \"v\":0.001,\n \"vw\":22889.5\n }"
],
"line_end" => 833,
"line_start" => 810,
"mappings" => [],
"name" => "parseOHLCV",
"signature" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV",
"source" => "parseOHLCV (ohlcv, market: Market = undefined): OHLCV {\n //\n // {\n // \"c\":22895,\n // \"h\":22895,\n // \"l\":22884,\n // \"n\":6,\n // \"o\":22884,\n // \"t\":\"2022-07-21T05:01:00Z\",\n // \"v\":0.001,\n // \"vw\":22889.5\n // }\n //\n const datetime = this.safeString (ohlcv, 't');\n const timestamp = this.parse8601 (datetime);\n return [\n timestamp, // timestamp\n this.safeNumber (ohlcv, 'o'), // open\n this.safeNumber (ohlcv, 'h'), // high\n this.safeNumber (ohlcv, 'l'), // low\n this.safeNumber (ohlcv, 'c'), // close\n this.safeNumber (ohlcv, 'v'), // volume\n ];\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"id\":\"6ecfcc34-4bed-4b53-83ba-c564aa832a81\",\n \"client_order_id\":\"ccxt_1c6ceab0b5e84727b2f1c0394ba17560\",\n \"created_at\":\"2022-06-14T13:59:30.224037068Z\",\n \"updated_at\":\"2022-06-14T13:59:30.224037068Z\",\n \"submitted_at\":\"2022-06-14T13:59:30.221856828Z\",\n \"filled_at\":null,\n \"expired_at\":null,\n \"canceled_at\":null,\n \"failed_at\":null,\n \"replaced_at\":null,\n \"replaced_by\":null,\n \"replaces\":null,\n \"asset_id\":\"64bbff51-59d6-4b3c-9351-13ad85e3c752\",\n \"symbol\":\"BTCUSD\",\n \"asset_class\":\"crypto\",\n \"notional\":null,\n \"qty\":\"0.01\",\n \"filled_qty\":\"0\",\n \"filled_avg_price\":null,\n \"order_class\":\"\",\n \"order_type\":\"limit\",\n \"type\":\"limit\",\n \"side\":\"buy\",\n \"time_in_force\":\"day\",\n \"limit_price\":\"14000\",\n \"stop_price\":null,\n \"status\":\"accepted\",\n \"extended_hours\":false,\n \"legs\":null,\n \"trail_percent\":null,\n \"trail_price\":null,\n \"hwm\":null,\n \"commission\":\"0.42\",\n \"source\":null\n }"
],
"line_end" => 1437,
"line_start" => 1353,
"mappings" => [
%{
"comment" => nil,
"key" => "id",
"value" => "this.safeString (order, 'id')"
},
%{
"comment" => nil,
"key" => "clientOrderId",
"value" => "this.safeString (order, 'client_order_id')"
},
%{
"comment" => nil,
"key" => "timestamp",
"value" => "timestamp"
},
%{
"comment" => nil,
"key" => "datetime",
"value" => "datetime"
},
%{
"comment" => nil,
"key" => "lastTradeTimeStamp",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "status",
"value" => "status"
},
%{
"comment" => nil,
"key" => "symbol",
"value" => "symbol"
},
%{
"comment" => nil,
"key" => "type",
"value" => "orderType"
},
%{
"comment" => nil,
"key" => "timeInForce",
"value" => "this.parseTimeInForce (this.safeString (order, 'time_in_force'))"
},
%{
"comment" => nil,
"key" => "postOnly",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "side",
"value" => "this.safeString (order, 'side')"
},
%{
"comment" => nil,
"key" => "price",
"value" => "this.safeNumber (order, 'limit_price')"
},
%{
"comment" => nil,
"key" => "triggerPrice",
"value" => "this.safeNumber (order, 'stop_price')"
},
%{
"comment" => nil,
"key" => "cost",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "average",
"value" => "this.safeNumber (order, 'filled_avg_price')"
},
%{
"comment" => nil,
"key" => "amount",
"value" => "this.safeNumber (order, 'qty')"
},
%{
"comment" => nil,
"key" => "filled",
"value" => "this.safeNumber (order, 'filled_qty')"
},
%{
"comment" => nil,
"key" => "remaining",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "trades",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "fee",
"value" => "fee"
},
%{
"comment" => nil,
"key" => "info",
"value" => "order"
}
],
"name" => "parseOrder",
"signature" => "parseOrder (order: Dict, market: Market = undefined): Order",
"source" => "parseOrder (order: Dict, market: Market = undefined): Order {\n //\n // {\n // \"id\":\"6ecfcc34-4bed-4b53-83ba-c564aa832a81\",\n // \"client_order_id\":\"ccxt_1c6ceab0b5e84727b2f1c0394ba17560\",\n // \"created_at\":\"2022-06-14T13:59:30.224037068Z\",\n // \"updated_at\":\"2022-06-14T13:59:30.224037068Z\",\n // \"submitted_at\":\"2022-06-14T13:59:30.221856828Z\",\n // \"filled_at\":null,\n // \"expired_at\":null,\n // \"canceled_at\":null,\n // \"failed_at\":null,\n // \"replaced_at\":null,\n // \"replaced_by\":null,\n // \"replaces\":null,\n // \"asset_id\":\"64bbff51-59d6-4b3c-9351-13ad85e3c752\",\n // \"symbol\":\"BTCUSD\",\n // \"asset_class\":\"crypto\",\n // \"notional\":null,\n // \"qty\":\"0.01\",\n // \"filled_qty\":\"0\",\n // \"filled_avg_price\":null,\n // \"order_class\":\"\",\n // \"order_type\":\"limit\",\n // \"type\":\"limit\",\n // \"side\":\"buy\",\n // \"time_in_force\":\"day\",\n // \"limit_price\":\"14000\",\n // \"stop_price\":null,\n // \"status\":\"accepted\",\n // \"extended_hours\":false,\n // \"legs\":null,\n // \"trail_percent\":null,\n // \"trail_price\":null,\n // \"hwm\":null,\n // \"commission\":\"0.42\",\n // \"source\":null\n // }\n //\n const marketId = this.safeString (order, 'symbol');\n market = this.safeMarket (marketId, market);\n const symbol = market['symbol'];\n const alpacaStatus = this.safeString (order, 'status');\n const status = this.parseOrderStatus (alpacaStatus);\n const feeValue = this.safeString (order, 'commission');\n let fee = undefined;\n if (feeValue !== undefined) {\n fee = {\n 'cost': feeValue,\n 'currency': 'USD',\n };\n }\n let orderType = this.safeString (order, 'order_type');\n if (orderType !== undefined) {\n if (orderType.indexOf ('limit') >= 0) {\n // might be limit or stop-limit\n orderType = 'limit';\n }\n }\n const datetime = this.safeString (order, 'submitted_at');\n const timestamp = this.parse8601 (datetime);\n return this.safeOrder ({\n 'id': this.safeString (order, 'id'),\n 'clientOrderId': this.safeString (order, 'client_order_id'),\n 'timestamp': timestamp,\n 'datetime': datetime,\n 'lastTradeTimeStamp': undefined,\n 'status': status,\n 'symbol': symbol,\n 'type': orderType,\n 'timeInForce': this.parseTimeInForce (this.safeString (order, 'time_in_force')),\n 'postOnly': undefined,\n 'side': this.safeString (order, 'side'),\n 'price': this.safeNumber (order, 'limit_price'),\n 'triggerPrice': this.safeNumber (order, 'stop_price'),\n 'cost': undefined,\n 'average': this.safeNumber (order, 'filled_avg_price'),\n 'amount': this.safeNumber (order, 'qty'),\n 'filled': this.safeNumber (order, 'filled_qty'),\n 'remaining': undefined,\n 'trades': undefined,\n 'fee': fee,\n 'info': order,\n }, market);\n }"
},
%{
"comment" => nil,
"examples" => [],
"line_end" => 1449,
"line_start" => 1439,
"mappings" => [],
"name" => "parseOrderStatus",
"signature" => "parseOrderStatus (status: Str)",
"source" => "parseOrderStatus (status: Str) {\n const statuses: Dict = {\n 'pending_new': 'open',\n 'accepted': 'open',\n 'new': 'open',\n 'partially_filled': 'open',\n 'activated': 'open',\n 'filled': 'closed',\n };\n return this.safeString (statuses, status, status);\n }"
},
%{
"comment" => nil,
"examples" => [],
"line_end" => 1456,
"line_start" => 1451,
"mappings" => [],
"name" => "parseTimeInForce",
"signature" => "parseTimeInForce (timeInForce: Str)",
"source" => "parseTimeInForce (timeInForce: Str) {\n const timeInForces: Dict = {\n 'day': 'Day',\n };\n return this.safeString (timeInForces, timeInForce, timeInForce);\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"t\":\"2022-06-14T05:00:00.027869Z\",\n \"x\":\"CBSE\",\n \"p\":\"21942.15\",\n \"s\":\"0.0001\",\n \"tks\":\"S\",\n \"i\":\"355681339\"\n }",
"{\n \"id\": \"20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8\",\n \"activity_type\": \"FILL\",\n \"transaction_time\": \"2022-12-28T12:19:29.579352Z\",\n \"type\": \"fill\",\n \"price\": \"67.31\",\n \"qty\": \"0.07\",\n \"side\": \"sell\",\n \"symbol\": \"LTC/USD\",\n \"leaves_qty\": \"0\",\n \"order_id\": \"82eebcf7-6e66-4b7e-93f8-be0df0e4f12e\",\n \"cum_qty\": \"0.07\",\n \"order_status\": \"filled\",\n \"swap_rate\": \"1\"\n },"
],
"line_end" => 1574,
"line_start" => 1515,
"mappings" => [
%{
"comment" => nil,
"key" => "info",
"value" => "trade"
},
%{
"comment" => nil,
"key" => "id",
"value" => "this.safeString2 (trade, 'i', 'id')"
},
%{
"comment" => nil,
"key" => "timestamp",
"value" => "timestamp"
},
%{
"comment" => nil,
"key" => "datetime",
"value" => "this.iso8601 (timestamp)"
},
%{
"comment" => nil,
"key" => "symbol",
"value" => "symbol"
},
%{
"comment" => nil,
"key" => "order",
"value" => "this.safeString (trade, 'order_id')"
},
%{
"comment" => nil,
"key" => "type",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "side",
"value" => "side"
},
%{
"comment" => nil,
"key" => "takerOrMaker",
"value" => "'taker'"
},
%{
"comment" => nil,
"key" => "price",
"value" => "priceString"
},
%{
"comment" => nil,
"key" => "amount",
"value" => "amountString"
},
%{
"comment" => nil,
"key" => "cost",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "fee",
"value" => "undefined"
}
],
"name" => "parseTrade",
"signature" => "parseTrade (trade: Dict, market: Market = undefined): Trade",
"source" => "parseTrade (trade: Dict, market: Market = undefined): Trade {\n //\n // fetchTrades\n //\n // {\n // \"t\":\"2022-06-14T05:00:00.027869Z\",\n // \"x\":\"CBSE\",\n // \"p\":\"21942.15\",\n // \"s\":\"0.0001\",\n // \"tks\":\"S\",\n // \"i\":\"355681339\"\n // }\n //\n // fetchMyTrades\n //\n // {\n // \"id\": \"20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8\",\n // \"activity_type\": \"FILL\",\n // \"transaction_time\": \"2022-12-28T12:19:29.579352Z\",\n // \"type\": \"fill\",\n // \"price\": \"67.31\",\n // \"qty\": \"0.07\",\n // \"side\": \"sell\",\n // \"symbol\": \"LTC/USD\",\n // \"leaves_qty\": \"0\",\n // \"order_id\": \"82eebcf7-6e66-4b7e-93f8-be0df0e4f12e\",\n // \"cum_qty\": \"0.07\",\n // \"order_status\": \"filled\",\n // \"swap_rate\": \"1\"\n // },\n //\n const marketId = this.safeString2 (trade, 'S', 'symbol');\n const symbol = this.safeSymbol (marketId, market);\n const datetime = this.safeString2 (trade, 't', 'transaction_time');\n const timestamp = this.parse8601 (datetime);\n const alpacaSide = this.safeString (trade, 'tks');\n let side = this.safeString (trade, 'side');\n if (alpacaSide === 'B') {\n side = 'buy';\n } else if (alpacaSide === 'S') {\n side = 'sell';\n }\n const priceString = this.safeString2 (trade, 'p', 'price');\n const amountString = this.safeString2 (trade, 's', 'qty');\n return this.safeTrade ({\n 'info': trade,\n 'id': this.safeString2 (trade, 'i', 'id'),\n 'timestamp': timestamp,\n 'datetime': this.iso8601 (timestamp),\n 'symbol': symbol,\n 'order': this.safeString (trade, 'order_id'),\n 'type': undefined,\n 'side': side,\n 'takerOrMaker': 'taker',\n 'price': priceString,\n 'amount': amountString,\n 'cost': undefined,\n 'fee': undefined,\n }, market);\n }"
},
%{
"comment" => nil,
"examples" => [
"{\n \"id\": \"e27b70a6-5610-40d7-8468-a516a284b776\",\n \"tx_hash\": null,\n \"direction\": \"OUTGOING\",\n \"amount\": \"20\",\n \"usd_value\": \"19.99856\",\n \"chain\": \"ETH\",\n \"asset\": \"USDT\",\n \"from_address\": \"0x123930E4dCA196E070d39B60c644C8Aae02f23\",\n \"to_address\": \"0x1232c0925196e4dcf05945f67f690153190fbaab\",\n \"status\": \"PROCESSING\",\n \"created_at\": \"2024-11-07T02:39:01.775495Z\",\n \"network_fee\": \"4\",\n \"fees\": \"0.1\"\n }"
],
"line_end" => 1801,
"line_start" => 1751,
"mappings" => [
%{
"comment" => nil,
"key" => "info",
"value" => "transaction"
},
%{
"comment" => nil,
"key" => "id",
"value" => "this.safeString (transaction, 'id')"
},
%{
"comment" => nil,
"key" => "txid",
"value" => "this.safeString (transaction, 'tx_hash')"
},
%{
"comment" => nil,
"key" => "timestamp",
"value" => "this.parse8601 (datetime)"
},
%{
"comment" => nil,
"key" => "datetime",
"value" => "datetime"
},
%{
"comment" => nil,
"key" => "network",
"value" => "this.safeString (transaction, 'chain')"
},
%{
"comment" => nil,
"key" => "address",
"value" => "this.safeString (transaction, 'to_address')"
},
%{
"comment" => nil,
"key" => "addressTo",
"value" => "this.safeString (transaction, 'to_address')"
},
%{
"comment" => nil,
"key" => "addressFrom",
"value" => "this.safeString (transaction, 'from_address')"
},
%{
"comment" => nil,
"key" => "tag",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "tagTo",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "tagFrom",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "type",
"value" => "this.parseTransactionType (this.safeString (transaction, 'direction'))"
},
%{
"comment" => nil,
"key" => "amount",
"value" => "this.safeNumber (transaction, 'amount')"
},
%{
"comment" => nil,
"key" => "currency",
"value" => "code"
},
%{
"comment" => nil,
"key" => "status",
"value" => "this.parseTransactionStatus (this.safeString (transaction, 'status'))"
},
%{
"comment" => nil,
"key" => "updated",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "fee",
"value" => "fee"
},
%{
"comment" => nil,
"key" => "comment",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "internal",
"value" => "undefined"
},
%{
"comment" => nil,
"key" => "cost",
"value" => "this.parseNumber (totalFee)"
}
],
"name" => "parseTransaction",
"signature" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction",
"source" => "parseTransaction (transaction: Dict, currency: Currency = undefined): Transaction {\n //\n // {\n // \"id\": \"e27b70a6-5610-40d7-8468-a516a284b776\",\n // \"tx_hash\": null,\n // \"direction\": \"OUTGOING\",\n // \"amount\": \"20\",\n // \"usd_value\": \"19.99856\",\n // \"chain\": \"ETH\",\n // \"asset\": \"USDT\",\n // \"from_address\": \"0x123930E4dCA196E070d39B60c644C8Aae02f23\",\n // \"to_address\": \"0x1232c0925196e4dcf05945f67f690153190fbaab\",\n // \"status\": \"PROCESSING\",\n // \"created_at\": \"2024-11-07T02:39:01.775495Z\",\n // \"network_fee\": \"4\",\n // \"fees\": \"0.1\"\n // }\n //\n const datetime = this.safeString (transaction, 'created_at');\n const currencyId = this.safeString (transaction, 'asset');\n const code = this.safeCurrencyCode (currencyId, currency);\n const fees = this.safeString (transaction, 'fees');\n const networkFee = this.safeString (transaction, 'network_fee');\n const totalFee = Precise.stringAdd (fees, networkFee);\n const fee = {\n 'cost': this.parseNumber (totalFee),\n 'currency': code,\n };\n return {\n 'info': transaction,\n 'id': this.safeString (transaction, 'id'),\n 'txid': this.safeString (transaction, 'tx_hash'),\n 'timestamp': this.parse8601 (datetime),\n 'datetime': datetime,\n 'network': this.safeString (transaction, 'chain'),\n 'address': this.safeString (transaction, 'to_address'),\n 'addressTo': this.safeString (transaction, 'to_address'),\n 'addressFrom': this.safeString (transaction, 'from_address'),\n 'tag': undefined,\n 'tagTo': undefined,\n 'tagFrom': undefined,\n 'type': this.parseTransactionType (this.safeString (transaction, 'direction')),\n 'amount': this.safeNumber (transaction, 'amount'),\n 'currency': code,\n 'status': this.parseTransactionStatus (this.safeString (transaction, 'status')),\n 'updated': undefined,\n 'fee': fee,\n 'comment': undefined,\n 'internal': undefined,\n } as Transaction;\n }"
},
%{
"comment" => nil,
"examples" => [],
"line_end" => 1810,
"line_start" => 1803,
"mappings" => [],
"name" => "parseTransactionStatus",
"signature" => "parseTransactionStatus (status: Str)",
"source" => "parseTransactionStatus (status: Str) {\n const statuses: Dict = {\n 'PROCESSING': 'pending',\n 'FAILED': 'failed',\n 'COMPLETE': 'ok',\n };\n return this.safeString (statuses, status, status);\n }"
},
%{
"comment" => nil,
"examples" => [],
"line_end" => 1818,
"line_start" => 1812,
"mappings" => [],
"name" => "parseTransactionType",
"signature" => "parseTransactionType (type)",
"source" => "parseTransactionType (type) {\n const types: Dict = {\n 'INCOMING': 'deposit',\n 'OUTGOING': 'withdrawal',\n };\n return this.safeString (types, type, type);\n }"
}
],
path_prefix: "",
pro: true,
quote_json_numbers: nil,
rate_limits: %{
interval_ms: 333,
period: 1000,
requests: 3,
rolling_window_size: 60000
},
raw_endpoints: %{
private: [],
public: []
},
required_credentials: %{
api_key: true,
password: false,
secret: true,
uid: false
},
requires_eddsa: false,
response_error: nil,
signing: %{
api_key_header: "APCA-API-SECRET-KEY",
confidence: :medium,
pattern: :hmac_sha256_headers
},
spec_format_version: 2,
status: %{
"eta" => nil,
"status" => "ok",
"updated" => nil,
"url" => nil
},
symbol_format: nil,
symbol_formats: nil,
symbol_patterns: %{},
timeframes: %{
"12h" => "12H",
"15m" => "15min",
"1M" => "1M",
"1d" => "1D",
"1h" => "1H",
"1m" => "1min",
"1w" => "1W",
"2h" => "2H",
"30m" => "30min",
"3d" => "3D",
"3m" => "3min",
"4h" => "4H",
"5m" => "5min",
"6h" => "6H",
"8h" => "8H"
},
url_strategy: %{
detected_from: "fallback",
pattern: :no_prefix,
prefix: nil
},
urls: %{
api: "https://broker-api.alpaca.markets",
api_sections: %{
"broker" => "https://broker-api.alpaca.markets",
"market" => "https://data.alpaca.markets",
"trader" => "https://api.alpaca.markets"
},
doc: "https://alpaca.markets/docs/",
other: nil,
sandbox: %{
"broker" => "https://broker-api.sandbox.alpaca.markets",
"market" => "https://data.alpaca.markets",
"trader" => "https://paper-api.alpaca.markets"
},
www: "https://alpaca.markets"
},
version: nil,
ws: %{
channel_templates: %{
watch_my_trades: %{
auth_required: true,
market_id_format: :native,
params: [
%{
"default" => nil,
"name" => "limit"
}
],
pattern: :action_subscribe
},
watch_ohlcv: %{
auth_required: true,
market_id_format: :native,
params: [
%{
"default" => nil,
"name" => "limit"
}
],
pattern: :action_subscribe
},
watch_order_book: %{
auth_required: true,
market_id_format: :native,
params: [
%{
"default" => nil,
"name" => "limit"
}
],
pattern: :action_subscribe
},
watch_orders: %{
auth_required: true,
market_id_format: :native,
params: [
%{
"default" => nil,
"name" => "limit"
}
],
pattern: :action_subscribe
},
watch_ticker: %{
auth_required: true,
market_id_format: :native,
params: [],
pattern: :action_subscribe
},
watch_trades: %{
auth_required: true,
market_id_format: :native,
params: [
%{
"default" => nil,
"name" => "limit"
}
],
pattern: :action_subscribe
}
},
has: %{
watch_balance: false,
watch_bids_asks: nil,
watch_liquidations: false,
watch_liquidations_for_symbols: false,
watch_mark_price: false,
watch_mark_prices: false,
watch_my_liquidations: false,
watch_my_liquidations_for_symbols: false,
watch_my_trades: true,
watch_ohlcv: true,
watch_ohlcv_for_symbols: nil,
watch_order_book: true,
watch_order_book_for_symbols: nil,
watch_orders: true,
watch_orders_for_symbols: nil,
watch_position: false,
watch_positions: false,
watch_status: nil,
watch_ticker: true,
watch_tickers: false,
watch_trades: true,
watch_trades_for_symbols: nil
},
hostname: "alpaca.markets",
message_patterns: [
%{
format: :action,
keys: [
"action",
"key",
"secret"
],
kind_field: "action",
kind_value: "auth",
sources: [
:send,
:watch
]
},
%{
args_field: "data",
format: :action,
keys: [
"action",
"data"
],
kind_field: "action",
kind_value: "authenticate",
sources: [
:send,
:watch
]
},
%{
args_field: "data",
format: :action,
keys: [
"action",
"data"
],
kind_field: "action",
kind_value: "listen",
sources: [
:send,
:watch
]
},
%{
format: :action,
keys: [
"action",
"bars"
],
kind_field: "action",
kind_value: "subscribe",
sources: [
:send,
:watch
]
},
%{
format: :action,
keys: [
"action",
"orderbooks"
],
kind_field: "action",
kind_value: "subscribe",
sources: [
:send,
:watch
]
},
%{
format: :action,
keys: [
"action",
"quotes"
],
kind_field: "action",
kind_value: "subscribe",
sources: [
:send,
:watch
]
},
%{
format: :action,
keys: [
"action",
"trades"
],
kind_field: "action",
kind_value: "subscribe",
sources: [
:send,
:watch
]
}
],
subscription_config: %{
args_field: "params",
args_format: :params_object,
market_id_format: :native,
op_field: "action"
},
subscription_pattern: :action_subscribe,
test_urls: %{
"crypto" => "wss://stream.data.alpaca.markets/v1beta2/crypto",
"trading" => "wss://paper-api.alpaca.markets/stream"
},
urls: %{
"crypto" => "wss://stream.data.alpaca.markets/v1beta2/crypto",
"trading" => "wss://api.alpaca.markets/stream"
},
watch_methods: [
"watchMyTrades",
"watchOHLCV",
"watchOrderBook",
"watchOrders",
"watchTicker",
"watchTrades"
]
}
}