Skip to content

Commit

Permalink
add example of how to retrieve usd wallet balance
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLep committed Apr 22, 2022
1 parent 12100eb commit 1d77308
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ ftx_rest_api: FtxRestApi = FtxRestApi()
Then you can use the FtxRestApi instance to retrieve information from FTX Api. See some examples:

```python
from tools.utils import format_wallet_raw_data

# Get last market data
response = ftx_rest_api.get(f"markets/BTC-PERP")
logging.info(f"FTX API response: {str(response)}")
Expand All @@ -297,6 +299,10 @@ logging.info(f"FTX API response: {str(response)}")
response = ftx_rest_api.get("wallet/balances")
logging.info(f"FTX API response: {str(response)}")

# Display USD wallet info
wallets = [format_wallet_raw_data(wallet) for wallet in response if
wallet["coin"] == 'USD']
logging.info(f"FTX USD Wallet: {str(wallets)}")
# ...
```

Expand Down
7 changes: 7 additions & 0 deletions strategies/demo_strategy/demo_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from core.stock.crypto_pair_manager import CryptoPairManager
from core.stock.stock_data_manager import StockDataManager
from core.strategy.strategy import Strategy
from tools.utils import format_wallet_raw_data


class DemoStrategy(Strategy):
Expand Down Expand Up @@ -71,6 +72,12 @@ def loop(self) -> None:
response = self.ftx_rest_api.get("wallet/balances")
logging.info(f"FTX API response: {str(response)}")

# Display USD wallet info
wallets = [format_wallet_raw_data(wallet) for wallet in response if
wallet["coin"] == 'USD']
logging.info(f"FTX USD Wallet: {str(wallets)}")


def after_loop(self) -> None:
"""Called after each loop"""
logging.info("DemoStrategy after_loop")
Expand Down

0 comments on commit 1d77308

Please sign in to comment.