Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit b8b96a0

Browse files
Merge pull request #52 from verata-veritatis/asset_module_dev
Asset module dev
2 parents ef8a6da + 15d8f01 commit b8b96a0

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

pybit/__init__.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,88 @@ def close_position(self, symbol):
13821382

13831383
# Submit a market order against each open position for the same qty.
13841384
return self.place_active_order_bulk(orders)
1385+
'''
1386+
Below are methods under https://bybit-exchange.github.io/docs/account_asset
1387+
'''
1388+
def create_internal_transfer(self, **kwargs):
1389+
"""
1390+
Create internal transfer. For more information, see
1391+
https://bybit-exchange.github.io/docs/account_asset/#t-transfer
1392+
"""
1393+
1394+
suffix="/asset/v1/private/transfer"
1395+
if self._verify_string(kwargs,'amount'):
1396+
return self._submit_request(
1397+
method='POST',
1398+
path=self.endpoint + suffix,
1399+
query=kwargs,
1400+
auth=True
1401+
)
1402+
else:
1403+
self.logger.error('amount must be in string format')
1404+
1405+
def create_subaccount_transfer(self, **kwargs):
1406+
"""
1407+
Create internal transfer. For more information, see
1408+
https://bybit-exchange.github.io/docs/account_asset/#t-transfer
1409+
"""
1410+
1411+
suffix="/asset/v1/private/sub-member/transfer"
1412+
1413+
if self._verify_string(kwargs, 'amount'):
1414+
return self._submit_request(
1415+
method='POST',
1416+
path=self.endpoint + suffix,
1417+
query=kwargs,
1418+
auth=True
1419+
)
1420+
else:
1421+
self.logger.error('amount must be in string format')
1422+
1423+
def query_transfer_list(self, **kwargs):
1424+
"""
1425+
Create internal transfer. For more information, see
1426+
https://bybit-exchange.github.io/docs/account_asset/#t-transfer
1427+
"""
1428+
1429+
suffix="/asset/v1/private/transfer/list"
1430+
1431+
return self._submit_request(
1432+
method='GET',
1433+
path=self.endpoint + suffix,
1434+
query=kwargs,
1435+
auth=True
1436+
)
13851437

1438+
def query_subaccount_list(self):
1439+
"""
1440+
Create internal transfer. For more information, see
1441+
https://bybit-exchange.github.io/docs/account_asset/#t-transfer
1442+
"""
1443+
1444+
suffix="/asset/v1/private/sub-member/member-ids"
1445+
1446+
return self._submit_request(
1447+
method='GET',
1448+
path=self.endpoint + suffix,
1449+
query={},
1450+
auth=True
1451+
)
1452+
1453+
def query_subaccount_transfer_list(self,**kwargs):
1454+
"""
1455+
Create internal transfer. For more information, see
1456+
https://bybit-exchange.github.io/docs/account_asset/#t-transfer
1457+
"""
1458+
1459+
suffix="/asset/v1/private/sub-member/transfer/list"
1460+
1461+
return self._submit_request(
1462+
method='GET',
1463+
path=self.endpoint + suffix,
1464+
query=kwargs,
1465+
auth=True
1466+
)
13861467
'''
13871468
Internal methods; signature and request submission.
13881469
For more information about the request signature, see
@@ -1428,6 +1509,14 @@ def _auth(self, method, params, recv_window):
14281509
bytes(_val, 'utf-8'), digestmod='sha256'
14291510
).hexdigest())
14301511

1512+
def _verify_string(self,params,key):
1513+
if key in params:
1514+
if not isinstance(params[key], str):
1515+
return False
1516+
else:
1517+
return True
1518+
return True
1519+
14311520
def _submit_request(self, method=None, path=None, query=None, auth=False):
14321521
"""
14331522
Submits the request to the API.

0 commit comments

Comments
 (0)