ccxt 4.4.25__py2.py3-none-any.whl → 4.4.26__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +1 -1
- ccxt/abstract/alpaca.py +1 -0
- ccxt/abstract/bingx.py +1 -0
- ccxt/abstract/okx.py +1 -0
- ccxt/abstract/phemex.py +1 -0
- ccxt/alpaca.py +245 -12
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/alpaca.py +245 -12
- ccxt/async_support/base/exchange.py +6 -6
- ccxt/async_support/binance.py +5 -6
- ccxt/async_support/bingx.py +6 -1
- ccxt/async_support/bitget.py +5 -5
- ccxt/async_support/bitmart.py +6 -6
- ccxt/async_support/bybit.py +6 -15
- ccxt/async_support/cex.py +36 -0
- ccxt/async_support/coinex.py +5 -7
- ccxt/async_support/digifinex.py +5 -5
- ccxt/async_support/exmo.py +1 -0
- ccxt/async_support/gate.py +6 -6
- ccxt/async_support/htx.py +5 -6
- ccxt/async_support/hyperliquid.py +12 -4
- ccxt/async_support/kucoin.py +5 -5
- ccxt/async_support/okx.py +6 -5
- ccxt/async_support/phemex.py +4 -2
- ccxt/async_support/whitebit.py +5 -5
- ccxt/async_support/woo.py +1 -1
- ccxt/async_support/xt.py +32 -24
- ccxt/base/exchange.py +11 -6
- ccxt/base/types.py +12 -0
- ccxt/binance.py +5 -6
- ccxt/bingx.py +6 -1
- ccxt/bitget.py +5 -5
- ccxt/bitmart.py +6 -6
- ccxt/bybit.py +6 -15
- ccxt/cex.py +36 -0
- ccxt/coinex.py +5 -7
- ccxt/digifinex.py +5 -5
- ccxt/exmo.py +1 -0
- ccxt/gate.py +6 -6
- ccxt/htx.py +5 -6
- ccxt/hyperliquid.py +12 -4
- ccxt/kucoin.py +5 -5
- ccxt/okx.py +6 -5
- ccxt/phemex.py +4 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/exmo.py +204 -4
- ccxt/test/tests_helpers.py +3 -1
- ccxt/whitebit.py +5 -5
- ccxt/woo.py +1 -1
- ccxt/xt.py +32 -24
- {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/METADATA +5 -5
- {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/RECORD +55 -55
- {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/WHEEL +0 -0
- {ccxt-4.4.25.dist-info → ccxt-4.4.26.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/alpaca.py
CHANGED
@@ -20,6 +20,7 @@ class ImplicitAPI:
|
|
20
20
|
trader_private_get_v2_assets_symbol_or_asset_id = traderPrivateGetV2AssetsSymbolOrAssetId = Entry('v2/assets/{symbol_or_asset_id}', ['trader', 'private'], 'GET', {})
|
21
21
|
trader_private_get_v2_corporate_actions_announcements_id = traderPrivateGetV2CorporateActionsAnnouncementsId = Entry('v2/corporate_actions/announcements/{id}', ['trader', 'private'], 'GET', {})
|
22
22
|
trader_private_get_v2_corporate_actions_announcements = traderPrivateGetV2CorporateActionsAnnouncements = Entry('v2/corporate_actions/announcements', ['trader', 'private'], 'GET', {})
|
23
|
+
trader_private_get_v2_wallets = traderPrivateGetV2Wallets = Entry('v2/wallets', ['trader', 'private'], 'GET', {})
|
23
24
|
trader_private_post_v2_orders = traderPrivatePostV2Orders = Entry('v2/orders', ['trader', 'private'], 'POST', {})
|
24
25
|
trader_private_post_v2_watchlists = traderPrivatePostV2Watchlists = Entry('v2/watchlists', ['trader', 'private'], 'POST', {})
|
25
26
|
trader_private_post_v2_watchlists_watchlist_id = traderPrivatePostV2WatchlistsWatchlistId = Entry('v2/watchlists/{watchlist_id}', ['trader', 'private'], 'POST', {})
|
ccxt/abstract/bingx.py
CHANGED
@@ -36,6 +36,7 @@ class ImplicitAPI:
|
|
36
36
|
swap_v1_private_get_market_markpriceklines = swapV1PrivateGetMarketMarkPriceKlines = Entry('market/markPriceKlines', ['swap', 'v1', 'private'], 'GET', {'cost': 1})
|
37
37
|
swap_v1_private_get_trade_batchcancelreplace = swapV1PrivateGetTradeBatchCancelReplace = Entry('trade/batchCancelReplace', ['swap', 'v1', 'private'], 'GET', {'cost': 5})
|
38
38
|
swap_v1_private_get_trade_fullorder = swapV1PrivateGetTradeFullOrder = Entry('trade/fullOrder', ['swap', 'v1', 'private'], 'GET', {'cost': 2})
|
39
|
+
swap_v1_private_get_positionmargin_history = swapV1PrivateGetPositionMarginHistory = Entry('positionMargin/history', ['swap', 'v1', 'private'], 'GET', {'cost': 2})
|
39
40
|
swap_v1_private_post_trade_cancelreplace = swapV1PrivatePostTradeCancelReplace = Entry('trade/cancelReplace', ['swap', 'v1', 'private'], 'POST', {'cost': 2})
|
40
41
|
swap_v1_private_post_positionside_dual = swapV1PrivatePostPositionSideDual = Entry('positionSide/dual', ['swap', 'v1', 'private'], 'POST', {'cost': 5})
|
41
42
|
swap_v1_private_post_trade_closeposition = swapV1PrivatePostTradeClosePosition = Entry('trade/closePosition', ['swap', 'v1', 'private'], 'POST', {'cost': 2})
|
ccxt/abstract/okx.py
CHANGED
@@ -189,6 +189,7 @@ class ImplicitAPI:
|
|
189
189
|
private_get_finance_staking_defi_orders_history = privateGetFinanceStakingDefiOrdersHistory = Entry('finance/staking-defi/orders-history', 'private', 'GET', {'cost': 3.3333333333333335})
|
190
190
|
private_get_finance_staking_defi_eth_balance = privateGetFinanceStakingDefiEthBalance = Entry('finance/staking-defi/eth/balance', 'private', 'GET', {'cost': 1.6666666666666667})
|
191
191
|
private_get_finance_staking_defi_eth_purchase_redeem_history = privateGetFinanceStakingDefiEthPurchaseRedeemHistory = Entry('finance/staking-defi/eth/purchase-redeem-history', 'private', 'GET', {'cost': 1.6666666666666667})
|
192
|
+
private_get_finance_staking_defi_eth_product_info = privateGetFinanceStakingDefiEthProductInfo = Entry('finance/staking-defi/eth/product-info', 'private', 'GET', {'cost': 3})
|
192
193
|
private_get_copytrading_current_subpositions = privateGetCopytradingCurrentSubpositions = Entry('copytrading/current-subpositions', 'private', 'GET', {'cost': 1})
|
193
194
|
private_get_copytrading_subpositions_history = privateGetCopytradingSubpositionsHistory = Entry('copytrading/subpositions-history', 'private', 'GET', {'cost': 1})
|
194
195
|
private_get_copytrading_instruments = privateGetCopytradingInstruments = Entry('copytrading/instruments', 'private', 'GET', {'cost': 4})
|
ccxt/abstract/phemex.py
CHANGED
@@ -24,6 +24,7 @@ class ImplicitAPI:
|
|
24
24
|
v1_get_exchange_public_products = v1GetExchangePublicProducts = Entry('exchange/public/products', 'v1', 'GET', {'cost': 5})
|
25
25
|
v1_get_api_data_public_data_funding_rate_history = v1GetApiDataPublicDataFundingRateHistory = Entry('api-data/public/data/funding-rate-history', 'v1', 'GET', {'cost': 5})
|
26
26
|
v2_get_public_products = v2GetPublicProducts = Entry('public/products', 'v2', 'GET', {'cost': 5})
|
27
|
+
v2_get_public_products_plus = v2GetPublicProductsPlus = Entry('public/products-plus', 'v2', 'GET', {'cost': 5})
|
27
28
|
v2_get_md_v2_orderbook = v2GetMdV2Orderbook = Entry('md/v2/orderbook', 'v2', 'GET', {'cost': 5})
|
28
29
|
v2_get_md_v2_trade = v2GetMdV2Trade = Entry('md/v2/trade', 'v2', 'GET', {'cost': 5})
|
29
30
|
v2_get_md_v2_ticker_24hr = v2GetMdV2Ticker24hr = Entry('md/v2/ticker/24hr', 'v2', 'GET', {'cost': 5})
|
ccxt/alpaca.py
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.alpaca import ImplicitAPI
|
8
|
-
from ccxt.base.types import Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Trade
|
8
|
+
from ccxt.base.types import Currency, DepositAddress, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import ExchangeError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
12
|
+
from ccxt.base.errors import ArgumentsRequired
|
12
13
|
from ccxt.base.errors import BadRequest
|
13
14
|
from ccxt.base.errors import BadSymbol
|
14
15
|
from ccxt.base.errors import InsufficientFunds
|
@@ -63,7 +64,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
63
64
|
'fetchBidsAsks': False,
|
64
65
|
'fetchClosedOrders': True,
|
65
66
|
'fetchCurrencies': False,
|
66
|
-
'fetchDepositAddress':
|
67
|
+
'fetchDepositAddress': True,
|
67
68
|
'fetchDepositAddressesByNetwork': False,
|
68
69
|
'fetchDeposits': False,
|
69
70
|
'fetchDepositsWithdrawals': False,
|
@@ -74,7 +75,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
74
75
|
'fetchL1OrderBook': True,
|
75
76
|
'fetchL2OrderBook': False,
|
76
77
|
'fetchMarkets': True,
|
77
|
-
'fetchMyTrades':
|
78
|
+
'fetchMyTrades': True,
|
78
79
|
'fetchOHLCV': True,
|
79
80
|
'fetchOpenOrder': False,
|
80
81
|
'fetchOpenOrders': True,
|
@@ -89,8 +90,8 @@ class alpaca(Exchange, ImplicitAPI):
|
|
89
90
|
'fetchPositionsHistory': False,
|
90
91
|
'fetchPositionsRisk': False,
|
91
92
|
'fetchStatus': False,
|
92
|
-
'fetchTicker':
|
93
|
-
'fetchTickers':
|
93
|
+
'fetchTicker': True,
|
94
|
+
'fetchTickers': True,
|
94
95
|
'fetchTime': True,
|
95
96
|
'fetchTrades': True,
|
96
97
|
'fetchTradingFee': False,
|
@@ -129,6 +130,7 @@ class alpaca(Exchange, ImplicitAPI):
|
|
129
130
|
'v2/assets/{symbol_or_asset_id}',
|
130
131
|
'v2/corporate_actions/announcements/{id}',
|
131
132
|
'v2/corporate_actions/announcements',
|
133
|
+
'v2/wallets',
|
132
134
|
],
|
133
135
|
'post': [
|
134
136
|
'v2/orders',
|
@@ -671,6 +673,130 @@ class alpaca(Exchange, ImplicitAPI):
|
|
671
673
|
self.safe_number(ohlcv, 'v'), # volume
|
672
674
|
]
|
673
675
|
|
676
|
+
def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
677
|
+
"""
|
678
|
+
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
679
|
+
:see: https://docs.alpaca.markets/reference/cryptosnapshots-1
|
680
|
+
:param str symbol: unified symbol of the market to fetch the ticker for
|
681
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
682
|
+
:param str [params.loc]: crypto location, default: us
|
683
|
+
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
684
|
+
"""
|
685
|
+
self.load_markets()
|
686
|
+
symbol = self.symbol(symbol)
|
687
|
+
tickers = self.fetch_tickers([symbol], params)
|
688
|
+
return self.safe_dict(tickers, symbol)
|
689
|
+
|
690
|
+
def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
691
|
+
"""
|
692
|
+
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
693
|
+
:see: https://docs.alpaca.markets/reference/cryptosnapshots-1
|
694
|
+
:param str[] symbols: unified symbols of the markets to fetch tickers for
|
695
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
696
|
+
:param str [params.loc]: crypto location, default: us
|
697
|
+
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
698
|
+
"""
|
699
|
+
if symbols is None:
|
700
|
+
raise ArgumentsRequired(self.id + ' fetchTickers() requires a symbols argument')
|
701
|
+
self.load_markets()
|
702
|
+
symbols = self.market_symbols(symbols)
|
703
|
+
loc = self.safe_string(params, 'loc', 'us')
|
704
|
+
ids = self.market_ids(symbols)
|
705
|
+
request = {
|
706
|
+
'symbols': ','.join(ids),
|
707
|
+
'loc': loc,
|
708
|
+
}
|
709
|
+
params = self.omit(params, 'loc')
|
710
|
+
response = self.marketPublicGetV1beta3CryptoLocSnapshots(self.extend(request, params))
|
711
|
+
#
|
712
|
+
# {
|
713
|
+
# "snapshots": {
|
714
|
+
# "BTC/USD": {
|
715
|
+
# "dailyBar": {
|
716
|
+
# "c": 69403.554,
|
717
|
+
# "h": 69609.6515,
|
718
|
+
# "l": 69013.26,
|
719
|
+
# "n": 9,
|
720
|
+
# "o": 69536.7,
|
721
|
+
# "t": "2024-11-01T05:00:00Z",
|
722
|
+
# "v": 0.210809181,
|
723
|
+
# "vw": 69327.655393908
|
724
|
+
# },
|
725
|
+
# "latestQuote": {
|
726
|
+
# "ap": 69424.19,
|
727
|
+
# "as": 0.68149,
|
728
|
+
# "bp": 69366.086,
|
729
|
+
# "bs": 0.68312,
|
730
|
+
# "t": "2024-11-01T08:31:41.880246926Z"
|
731
|
+
# },
|
732
|
+
# "latestTrade": {
|
733
|
+
# "i": 5272941104897543146,
|
734
|
+
# "p": 69416.9,
|
735
|
+
# "s": 0.014017324,
|
736
|
+
# "t": "2024-11-01T08:14:28.245088803Z",
|
737
|
+
# "tks": "B"
|
738
|
+
# },
|
739
|
+
# "minuteBar": {
|
740
|
+
# "c": 69403.554,
|
741
|
+
# "h": 69403.554,
|
742
|
+
# "l": 69399.125,
|
743
|
+
# "n": 0,
|
744
|
+
# "o": 69399.125,
|
745
|
+
# "t": "2024-11-01T08:30:00Z",
|
746
|
+
# "v": 0,
|
747
|
+
# "vw": 0
|
748
|
+
# },
|
749
|
+
# "prevDailyBar": {
|
750
|
+
# "c": 69515.1415,
|
751
|
+
# "h": 72668.837,
|
752
|
+
# "l": 68796.85,
|
753
|
+
# "n": 129,
|
754
|
+
# "o": 72258.9,
|
755
|
+
# "t": "2024-10-31T05:00:00Z",
|
756
|
+
# "v": 2.217683307,
|
757
|
+
# "vw": 70782.6811608144
|
758
|
+
# }
|
759
|
+
# },
|
760
|
+
# }
|
761
|
+
# }
|
762
|
+
#
|
763
|
+
results = []
|
764
|
+
snapshots = self.safe_dict(response, 'snapshots', {})
|
765
|
+
marketIds = list(snapshots.keys())
|
766
|
+
for i in range(0, len(marketIds)):
|
767
|
+
marketId = marketIds[i]
|
768
|
+
market = self.safe_market(marketId)
|
769
|
+
entry = self.safe_dict(snapshots, marketId)
|
770
|
+
dailyBar = self.safe_dict(entry, 'dailyBar', {})
|
771
|
+
prevDailyBar = self.safe_dict(entry, 'prevDailyBar', {})
|
772
|
+
latestQuote = self.safe_dict(entry, 'latestQuote', {})
|
773
|
+
latestTrade = self.safe_dict(entry, 'latestTrade', {})
|
774
|
+
datetime = self.safe_string(latestQuote, 't')
|
775
|
+
ticker = self.safe_ticker({
|
776
|
+
'info': entry,
|
777
|
+
'symbol': market['symbol'],
|
778
|
+
'timestamp': self.parse8601(datetime),
|
779
|
+
'datetime': datetime,
|
780
|
+
'high': self.safe_string(dailyBar, 'h'),
|
781
|
+
'low': self.safe_string(dailyBar, 'l'),
|
782
|
+
'bid': self.safe_string(latestQuote, 'bp'),
|
783
|
+
'bidVolume': self.safe_string(latestQuote, 'bs'),
|
784
|
+
'ask': self.safe_string(latestQuote, 'ap'),
|
785
|
+
'askVolume': self.safe_string(latestQuote, 'as'),
|
786
|
+
'vwap': self.safe_string(dailyBar, 'vw'),
|
787
|
+
'open': self.safe_string(dailyBar, 'o'),
|
788
|
+
'close': self.safe_string(dailyBar, 'c'),
|
789
|
+
'last': self.safe_string(latestTrade, 'p'),
|
790
|
+
'previousClose': self.safe_string(prevDailyBar, 'c'),
|
791
|
+
'change': None,
|
792
|
+
'percentage': None,
|
793
|
+
'average': None,
|
794
|
+
'baseVolume': self.safe_string(dailyBar, 'v'),
|
795
|
+
'quoteVolume': self.safe_string(dailyBar, 'n'),
|
796
|
+
}, market)
|
797
|
+
results.append(ticker)
|
798
|
+
return self.filter_by_array(results, 'symbol', symbols)
|
799
|
+
|
674
800
|
def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
675
801
|
"""
|
676
802
|
create a trade order
|
@@ -1014,7 +1140,54 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1014
1140
|
}
|
1015
1141
|
return self.safe_string(timeInForces, timeInForce, timeInForce)
|
1016
1142
|
|
1143
|
+
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1144
|
+
"""
|
1145
|
+
fetch all trades made by the user
|
1146
|
+
:see: https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1
|
1147
|
+
:param str [symbol]: unified market symbol
|
1148
|
+
:param int [since]: the earliest time in ms to fetch trades for
|
1149
|
+
:param int [limit]: the maximum number of trade structures to retrieve
|
1150
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1151
|
+
:param int [params.until]: the latest time in ms to fetch trades for
|
1152
|
+
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1153
|
+
"""
|
1154
|
+
self.load_markets()
|
1155
|
+
market = None
|
1156
|
+
request: dict = {
|
1157
|
+
'activity_type': 'FILL',
|
1158
|
+
}
|
1159
|
+
if symbol is not None:
|
1160
|
+
market = self.market(symbol)
|
1161
|
+
if since is not None:
|
1162
|
+
request['after'] = since
|
1163
|
+
if limit is not None:
|
1164
|
+
request['page_size'] = limit
|
1165
|
+
request, params = self.handle_until_option('until', request, params)
|
1166
|
+
response = self.traderPrivateGetV2AccountActivitiesActivityType(self.extend(request, params))
|
1167
|
+
#
|
1168
|
+
# [
|
1169
|
+
# {
|
1170
|
+
# "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
1171
|
+
# "activity_type": "FILL",
|
1172
|
+
# "transaction_time": "2022-12-28T12:19:29.579352Z",
|
1173
|
+
# "type": "fill",
|
1174
|
+
# "price": "67.31",
|
1175
|
+
# "qty": "0.07",
|
1176
|
+
# "side": "sell",
|
1177
|
+
# "symbol": "LTC/USD",
|
1178
|
+
# "leaves_qty": "0",
|
1179
|
+
# "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
1180
|
+
# "cum_qty": "0.07",
|
1181
|
+
# "order_status": "filled",
|
1182
|
+
# "swap_rate": "1"
|
1183
|
+
# },
|
1184
|
+
# ]
|
1185
|
+
#
|
1186
|
+
return self.parse_trades(response, market, since, limit)
|
1187
|
+
|
1017
1188
|
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1189
|
+
#
|
1190
|
+
# fetchTrades
|
1018
1191
|
#
|
1019
1192
|
# {
|
1020
1193
|
# "t":"2022-06-14T05:00:00.027869Z",
|
@@ -1025,25 +1198,43 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1025
1198
|
# "i":"355681339"
|
1026
1199
|
# }
|
1027
1200
|
#
|
1028
|
-
|
1201
|
+
# fetchMyTrades
|
1202
|
+
#
|
1203
|
+
# {
|
1204
|
+
# "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
1205
|
+
# "activity_type": "FILL",
|
1206
|
+
# "transaction_time": "2022-12-28T12:19:29.579352Z",
|
1207
|
+
# "type": "fill",
|
1208
|
+
# "price": "67.31",
|
1209
|
+
# "qty": "0.07",
|
1210
|
+
# "side": "sell",
|
1211
|
+
# "symbol": "LTC/USD",
|
1212
|
+
# "leaves_qty": "0",
|
1213
|
+
# "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
1214
|
+
# "cum_qty": "0.07",
|
1215
|
+
# "order_status": "filled",
|
1216
|
+
# "swap_rate": "1"
|
1217
|
+
# },
|
1218
|
+
#
|
1219
|
+
marketId = self.safe_string_2(trade, 'S', 'symbol')
|
1029
1220
|
symbol = self.safe_symbol(marketId, market)
|
1030
|
-
datetime = self.
|
1221
|
+
datetime = self.safe_string_2(trade, 't', 'transaction_time')
|
1031
1222
|
timestamp = self.parse8601(datetime)
|
1032
1223
|
alpacaSide = self.safe_string(trade, 'tks')
|
1033
|
-
side
|
1224
|
+
side = self.safe_string(trade, 'side')
|
1034
1225
|
if alpacaSide == 'B':
|
1035
1226
|
side = 'buy'
|
1036
1227
|
elif alpacaSide == 'S':
|
1037
1228
|
side = 'sell'
|
1038
|
-
priceString = self.
|
1039
|
-
amountString = self.
|
1229
|
+
priceString = self.safe_string_2(trade, 'p', 'price')
|
1230
|
+
amountString = self.safe_string_2(trade, 's', 'qty')
|
1040
1231
|
return self.safe_trade({
|
1041
1232
|
'info': trade,
|
1042
|
-
'id': self.
|
1233
|
+
'id': self.safe_string_2(trade, 'i', 'id'),
|
1043
1234
|
'timestamp': timestamp,
|
1044
1235
|
'datetime': self.iso8601(timestamp),
|
1045
1236
|
'symbol': symbol,
|
1046
|
-
'order':
|
1237
|
+
'order': self.safe_string(trade, 'order_id'),
|
1047
1238
|
'type': None,
|
1048
1239
|
'side': side,
|
1049
1240
|
'takerOrMaker': 'taker',
|
@@ -1053,6 +1244,48 @@ class alpaca(Exchange, ImplicitAPI):
|
|
1053
1244
|
'fee': None,
|
1054
1245
|
}, market)
|
1055
1246
|
|
1247
|
+
def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
|
1248
|
+
"""
|
1249
|
+
fetch the deposit address for a currency associated with self account
|
1250
|
+
:see: https://docs.alpaca.markets/reference/listcryptofundingwallets
|
1251
|
+
:param str code: unified currency code
|
1252
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1253
|
+
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
1254
|
+
"""
|
1255
|
+
self.load_markets()
|
1256
|
+
currency = self.currency(code)
|
1257
|
+
request: dict = {
|
1258
|
+
'asset': currency['id'],
|
1259
|
+
}
|
1260
|
+
response = self.traderPrivateGetV2Wallets(self.extend(request, params))
|
1261
|
+
#
|
1262
|
+
# {
|
1263
|
+
# "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
1264
|
+
# "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
1265
|
+
# "created_at": "2024-11-03T07:30:05.609976344Z"
|
1266
|
+
# }
|
1267
|
+
#
|
1268
|
+
return self.parse_deposit_address(response, currency)
|
1269
|
+
|
1270
|
+
def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
|
1271
|
+
#
|
1272
|
+
# {
|
1273
|
+
# "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
1274
|
+
# "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
1275
|
+
# "created_at": "2024-11-03T07:30:05.609976344Z"
|
1276
|
+
# }
|
1277
|
+
#
|
1278
|
+
parsedCurrency = None
|
1279
|
+
if currency is not None:
|
1280
|
+
parsedCurrency = currency['id']
|
1281
|
+
return {
|
1282
|
+
'info': depositAddress,
|
1283
|
+
'currency': parsedCurrency,
|
1284
|
+
'network': None,
|
1285
|
+
'address': self.safe_string(depositAddress, 'address'),
|
1286
|
+
'tag': None,
|
1287
|
+
}
|
1288
|
+
|
1056
1289
|
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
1057
1290
|
endpoint = '/' + self.implode_params(path, params)
|
1058
1291
|
url = self.implode_hostname(self.urls['api'][api[0]])
|