Bugs Fixed, Features Added


SUBMITTED BY: PimpTheRomeo

DATE: Jan. 20, 2018, 5:04 p.m.

FORMAT: Text only

SIZE: 5.8 kB

HITS: 513

  1. Bug Fixes
  2. fixed #1 - added null argument to get_current_median_history_price call
  3. fixed #2 - unhide cursor on ticker exit
  4. fixed duplicate method entry
  5. Discovered these issues while running the scripts and playing with the functions in functions.sh.
  6. New Features
  7. Moved ticker style functionality to its own function and put it into functions.sh ee3dfc15a3ffc8ff0e0f337c84ae787fdf4ecde2.
  8. Created balances.sh f12da076103377308e38b953983f55443ccb3d30 to replace all of the ticker scripts and provide new functionality:
  9. added argument parsing for tenable output
  10. User can choose
  11. display full account value
  12. display balances (sbd, steem, savings) [default]
  13. display SP
  14. display pending payouts [new] added here and then here
  15. made ticker format optional (can do one-shot and exit)
  16. added ability to display other output currencies (try LTC, for example) [new]
  17. This is used for:
  18. full account value option
  19. pending payout option
  20. added ability to specify the service endpoint (future proofing) [new]
  21. minimized external service calls (speedup)
  22. How did you implement it/them?
  23. The pending payout calculation is the full pending payout, before subtracting any curation. Little more to do here, but good start. It was implemented using the rpc_get_discussions_by_author_before_date, giving it the provided author and today's date as a starting point and going back to the last N posts (10 originally, updated to be configurable).
  24. This is how the get_payout function was implemented:
  25. ##
  26. # get_payout <AUTHOR> <LIMIT> [ENDPOINT]
  27. # Gets the specified author's pending payouts as a sum of SBD.
  28. get_payout(){
  29. local AUTHOR=${1}
  30. local WHEN=$(date -Iseconds)
  31. local LIMIT=${2:-}
  32. local PAYOUTS=$(rpc_get_discussions_by_author_before_date "${AUTHOR}" '' "${WHEN}" "${LIMIT}" "${ENDPOINT}" | grep -Po '"pending_payout_value":.*?[^\\]",' | cut -f2 -d: | cut -f2 -d'"' | cut -f1 -d' ' | xargs)
  33. VALUE=$(math "$(sed 's/ /+/g' <<< "${PAYOUTS}")" 2)
  34. echo "${VALUE}"
  35. }
  36. The get_discussions_by_author_before_date rpc call is used because it looked like the only one that clearly filtered based on author. The tag field is simply left empty to get all posts before the current moment.
  37. The original project author mentioned possibly moving away from jq, so I used grep as an example of how to extract json values. The actual pending payout values are of the form "000.000 SBD" so the value needed to be cut on the space to discard the SBD but otherwise extracting the value is pretty clear. Then The list of payout values it added together using the original author's math function. The values are built up with a sed expression. Finally, the value is returned in SBD.
  38. Back in the balances.sh script, the value is also displayed in whatever currency the user passes in. This is accomplished by propagating the CURRENCY value through the CURRENCY global to the get_prices function so that the SBD value can just be multiplied by that result.
  39. Added some functions to fetch just SP, STEEM, and SBD f381a3df70661a2c6d6ca8424718d644fae1c689. Originally these were in a new example script, but I made this script obsolete when I moved balances_ticker.sh to just balances.sh and added all of the new options f12da076103377308e38b953983f55443ccb3d30. It was too slow to fetch the various fields one at a time, so the method fetches the account information and then calculates the rest. At the same time, I added a CURRENCY option to balances.sh so that it could be used in calculating other dollar values of account assets.
  40. The ability to choose which elements are displayed is new. Calculating pending payouts is new. Displaying in other currencies was supported by aspects of the architecture, but it wasn't being passed through nor being used in calculating values, so while the functions for fetching currency values already existed, making use of them and doing the extra calculations is new.
  41. The output of the new balances.sh is much clearer than the previous ticker.
  42. ticker screenshot
  43. I don't know how to make animated gifs, but I updated the README to include text examples of the new output and features.
  44. Updated content for the readme:
  45. There are some example scripts, they all take a minimum, one or more account names.
  46. worth.sh - original one-shot example for fetching account value
  47. balances.sh - an uber example ticker or one-shot script
  48. The worth.sh script is a very basic example that only supports a user name.
  49. Example:
  50. $ worth.sh not-a-bird
  51. 1577.120
  52. The balances.sh supports more options and multiple user names.
  53. Usage:
  54. balances.sh [-b] [-c CURRENCY] [-e RPC_ENDPOINT] [-s] [-t] [-w] [-p] [-h] <USER> [USER ...]"
  55. Get and display balance information about the specified user.
  56. - b show balances (sbd, steem, savings) [default when no options specified]
  57. - c CURRENCY (default is USD)
  58. - e specify service node endpoint
  59. - h show help
  60. - p include pending payouts in output
  61. - s include SP in output
  62. - t enable stock ticker output
  63. - w include total account worth in output
  64. Examples:
  65. $ balances.sh -b not-a-bird
  66. not-a-bird 1.899 STEEM 2.027 SBD 1.000 Savings
  67. $ balances.sh -w not-a-bird
  68. not-a-bird worth: 1,157.77 USD
  69. $ balances.sh -c LTC -w not-a-bird
  70. not-a-bird worth: 6.00 LTC
  71. $ balances.sh -p not-a-bird
  72. not-a-bird pending payout: 248.86 SBD (USD: 1072.587)
  73. $ balances.sh -p -c BTC not-a-bird ned
  74. not-a-bird pending payout: 248.87 SBD (BTC: 0.095)
  75. ned pending payout: 0.00 SBD (BTC: 0.000)
  76. $ balances.sh -bpw -c BTC not-a-bird ned
  77. not-a-bird worth: 0.10 BTC 1.899 STEEM 2.027 SBD 1.000 Savings pending payout: 248.88 SBD (BTC: 0.094)
  78. ned worth: 1,452.40 BTC 141871.305 STEEM 5743.288 SBD 0.000 Savings pending payout: 0.00 SBD (BTC: 0.000)
  79. My Fork here and original project here.

comments powered by Disqus