Wallet Class

High-level wrapper over the account balances (Spot and cross Margin), with daily snapshots and performance helpers. Requires API credentials, which are managed by panzer (~/.panzer_creds); see Secrets Module. The underlying request functions are documented in Wallet API Functions.

class Wallet(time_zone='UTC', snapshot_days: int = 30)[source]

Bases: object

Wallet is a BinPan Class that can give information about balances, in Spot or Margin trading.

Also can show snapshots of the account status days ago, or using timestamps.

Credentials are managed by panzer’s CredentialManager (~/.panzer_creds). On first use, panzer will prompt for API key and secret if not already stored.

Methods:

update_spot([decimal_mode])

Updates balances in the class object.

update_spot_snapshot([startTime, endTime, ...])

Updates spot wallet snapshot and stores it in self.spot_snapshot.

update_margin([decimal_mode])

Updates balances in the wallet class object.

update_margin_snapshot([startTime, endTime, ...])

Updates margin wallet snapshot and stores it in self.margin_snapshot.

spot_wallet_performance(decimal_mode[, ...])

Calculate difference between current wallet not locked values and days before.

margin_wallet_performance(decimal_mode[, ...])

Calculate difference between current wallet not locked values and days before.

update_spot(decimal_mode=False)[source]

Updates balances in the class object. :param bool decimal_mode: Use of decimal objects instead of float. :return dict: Wallet dictionary

update_spot_snapshot(startTime: int | str = None, endTime: int | str = None, snapshot_days=30, time_zone=None)[source]

Updates spot wallet snapshot and stores it in self.spot_snapshot.

Parameters:
  • startTime (int or str) – Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42

  • endTime (int or str) – Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42

  • snapshot_days (int) – Days to look if not start time or endtime passed.

  • time_zone (str) – A time zone for time index conversion. Example: “Europe/Madrid”

Return pd.DataFrame:

Spot wallet snapshot for the time period requested.

update_margin(decimal_mode=False)[source]

Updates balances in the wallet class object.

Parameters:

decimal_mode (bool) – Use of decimal objects instead of float.

Return dict:

Wallet dictionary

update_margin_snapshot(startTime: int | str = None, endTime: int | str = None, snapshot_days=30, time_zone=None)[source]

Updates margin wallet snapshot and stores it in self.margin_snapshot.

Parameters:
  • startTime (int or str) – Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42

  • endTime (int or str) – Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42

  • snapshot_days (int) – Days to look if not start time or endtime passed.

  • time_zone (str) – A time zone for time index conversion. Example: “Europe/Madrid”

Return pd.DataFrame:

Margin wallet snapshot for the time period requested.

spot_wallet_performance(decimal_mode: bool, startTime=None, endTime=None, days: int = 30, convert_to: str = 'BUSD')[source]

Calculate difference between current wallet not locked values and days before. :param bool decimal_mode: Fixes Decimal return type and operative. :param int or str startTime: Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42 :param int or str endTime: Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42 :param int days: Days to compare balances. :param str convert_to: Converts balances to a coin. :return float: Value increase or decrease with current value of convert_to coin.

margin_wallet_performance(decimal_mode: bool, startTime=None, endTime=None, days: int = 30, convert_to: str = 'BUSD')[source]

Calculate difference between current wallet not locked values and days before. :param bool decimal_mode: Fixes Decimal return type and operative. :param int or str startTime: Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42 :param int or str endTime: Can be integer timestamp in milliseconds or formatted string: 2022-05-11 06:45:42 :param int days: Days to compare balances. :param str convert_to: Converts balances to a coin. :return float: Value increase or decrease with current value of convert_to coin.