Disclaimer: This is only an example! The currencies shown below were purchased to create this document.
If you're anything like me, you open and toggle between 5 to 10 (or more) apps per day just for status checks. My most engaged app throughout the day is Slack, so why not consolidate some of the status check's into one centralized notification channel? I recently forgot my Coinbase password but had previously stored the API keys. With this is I figured, F the password – I'll just send this information to Slack to completely ignore the Coinbase UI (no disrespect, just didn't want to wait n-days for an account reset).
Requirements:
schedule==0.6.0
coinbase==2.1.0
slackclient==1.3.2
Scope
- Wallet Summary
- includes total Coinbase wallet balance, amount invested, total (current) profit, and percentage amount changed
- Wallet Details
- includes number of units and balance of each account in my Coinbase wallet
WalletService()
crypto_wallet.py
comes with a service
variable that instantiates WalletService
class for quick use. Let's take a look at a few of its useful methods:
get_summary(notify=Bool)
- returns a dictionary of wallet information. The summary can (and will) be modified as my account becomes more diverse. Note: when notify=True, a Slack message is sent to CHANNEL variable.
In [1]: from crypto_wallet import *
In [2]: service.get_summary()
2019-07-17 11:35:52,757 | INFO | get_summary |Collecting Summary data
2019-07-17 11:35:54,309 | INFO | get_summary |Wallet Balance Changed
Current <-51.76>
Previous <0>
2019-07-17 11:35:54,309 | INFO | get_summary |Summary Result:
{'Diff': Decimal('-51.76'), 'Balance': Decimal('114.66'), 'Invested': Decimal('166.42'), 'byPercent': -31.102031005888715}
Out[2]:
{'Balance': Decimal('114.66'),
'Diff': Decimal('-51.76'),
'Invested': Decimal('166.42'),
'byPercent': -31.102031005888715}
-
my_account_data()
- returns a list of accounts where each account is a dictionary object
In [3]: service.my_account_data()
Out[3]:
[<Account @ 0x1073cd618> {
"allow_deposits": true,
"allow_withdrawals": true,
"balance": {
"amount": "500.0000000",
"currency": "XLM"
},
"created_at": "2019-07-03T20:35:10Z",
"currency": "XLM",
"id": "2d470ff6-8355-59b5-8089-c168f215cd63",
"name": "XLM Wallet",
"native_balance": {
"amount": "41.71",
"currency": "USD"
},
"primary": false,
"resource": "account",
"resource_path": "/v2/accounts/2d470ff6-8355-59b5-8089-c168f215cd63",
"type": "wallet",
"updated_at": "2019-07-03T20:45:19Z"
},
send_details(notify=Bool)
- send and/or return details for each account with abalance != $0
. Note: should return the same asmy_account_data
; it's main use is to format Slack messages
In [4]: service.send_details(notify=False)
Out[4]:
[<Account @ 0x1073be990> {
"allow_deposits": true,
"allow_withdrawals": true,
"balance": {
"amount": "500.0000000",
"currency": "XLM"
},
"created_at": "2019-07-03T20:35:10Z",
"currency": "XLM",
"id": "2d470ff6-8355-59b5-8089-c168f215cd63",
"name": "XLM Wallet",
"native_balance": {
"amount": "41.48",
"currency": "USD"
},
"primary": false,
"resource": "account",
"resource_path": "/v2/accounts/2d470ff6-8355-59b5-8089-c168f215cd63",
"type": "wallet",
"updated_at": "2019-07-03T20:45:19Z"
},
run()
- starts theschedule
process along with Slack'srtm_read
so that myWallet Summary
gets sent to Slack every n-secs|mins|hours while I'm able to requestWallet Details
via a custom command to the Bot.
Wallet Summary

Wallet Details

cryptobot get details
command sends Wallet Details
as a messageFuture updates to this bot will include:
- automatically buy/sell based on predefined triggers
- notify Slack when certain (haven't thought of them yet) conditions are met
- perform actions to account via Slack (custom commands)