Skip to content

Commit 559dee4

Browse files
freenancialMichael Cardillo
authored andcommitted
Add stablecoin conversion
1 parent 8186cf2 commit 559dee4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cbpro/authenticated_client.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,33 @@ def get_account_holds(self, account_id, **kwargs):
173173
endpoint = '/accounts/{}/holds'.format(account_id)
174174
return self._send_paginated_message(endpoint, params=kwargs)
175175

176+
177+
def convert_stablecoin(self, amount, from_currency, to_currency):
178+
""" Convert stablecoin.
179+
180+
Args:
181+
amount (Decimal): The amount to convert.
182+
from_currency (str): Currency type (eg. 'USDC')
183+
to_currency (str): Currency type (eg. 'USD').
184+
185+
Returns:
186+
dict: Conversion details. Example::
187+
{
188+
"id": "8942caee-f9d5-4600-a894-4811268545db",
189+
"amount": "10000.00",
190+
"from_account_id": "7849cc79-8b01-4793-9345-bc6b5f08acce",
191+
"to_account_id": "105c3e58-0898-4106-8283-dc5781cda07b",
192+
"from": "USD",
193+
"to": "USDC"
194+
}
195+
196+
"""
197+
params = {'from': from_currency,
198+
'to': to_currency,
199+
'amount': amount}
200+
return self._send_message('post', '/conversions', data=json.dumps(params))
201+
202+
176203
def place_order(self, product_id, side, order_type=None, **kwargs):
177204
""" Place an order.
178205

0 commit comments

Comments
 (0)