Author Topic: Bitshares Client Needs Account Value Feature  (Read 1858 times)

0 Members and 1 Guest are viewing this topic.

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053
Interesting thought to put up a bounty for that feature. It's not just to see the value of the BTS in my wallet relative to other currencies, but to see the full account value including current market prices for the other bitassets. It'd be nice to log in and see the bottom line full wallet value.

While not part of the client I have python functions that calculate this for one of my bot dashboards. Returns values in BTS. It ain't pretty but it gets the job done.

Code: [Select]
def get_open_order_balance(self, account, base, quote):
        quote_precision = float(self.get_precision(self.asset_id(quote)))
        base_precision = float(self.get_precision(self.asset_id(base)))
        median_quote = float(self.get_median(quote))
        #print "%s, %s" % (quote, base)
        response = self.request("wallet_market_order_list", [quote, base, -1, account])
        order_ids = []
        total_orders = 0.0
        bids = 0.0
        asks = 0.0
        shorts = 0.0
        if "result" in response.json():
           for item in response.json()["result"]:
              if item[1]["type"] == "bid_order":
                 total_orders += item[1]["state"]["balance"] / quote_precision
                 bids += item[1]["state"]["balance"] / quote_precision
              if item[1]["type"] == "ask_order":
                 total_orders += (item[1]["state"]["balance"] / base_precision) * median_quote
                 asks += (item[1]["state"]["balance"] / base_precision) * median_quote
              if item[1]["type"] == "cover_order":
                 total_orders += (item[1]["collateral"] / base_precision) * median_quote
                 shorts += (item[1]["collateral"] / base_precision) * median_quote
           return total_orders, bids, asks, shorts
        return

    def total_account_value(self, account):
        base = "BTS"
        markets = ["GOLD", "SILVER", "USD"]
        account_value = 0.0
        balance_bts = self.get_balance(account, base)
        for quote in markets:
           total_orders, bids, asks, shorts  = self.get_open_order_balance(account, base, quote)
           precision = float(self.get_precision(self.asset_id(quote)) )
           balance = float(self.get_balance(account, quote))
           median = float(self.get_median(quote))
           account_value = account_value + (total_orders / median) + (balance / median)

        account_value += balance_bts
        return account_value

Awesome, thx! i'm a little rusty with python these days. how do i run the function? i don't see where it interacts with the Bitshares API?

Offline Riverhead

Interesting thought to put up a bounty for that feature. It's not just to see the value of the BTS in my wallet relative to other currencies, but to see the full account value including current market prices for the other bitassets. It'd be nice to log in and see the bottom line full wallet value.

While not part of the client I have python functions that calculate this for one of my bot dashboards. Returns values in BTS. It ain't pretty but it gets the job done.

Code: [Select]
def get_open_order_balance(self, account, base, quote):
        quote_precision = float(self.get_precision(self.asset_id(quote)))
        base_precision = float(self.get_precision(self.asset_id(base)))
        median_quote = float(self.get_median(quote))
        #print "%s, %s" % (quote, base)
        response = self.request("wallet_market_order_list", [quote, base, -1, account])
        order_ids = []
        total_orders = 0.0
        bids = 0.0
        asks = 0.0
        shorts = 0.0
        if "result" in response.json():
           for item in response.json()["result"]:
              if item[1]["type"] == "bid_order":
                 total_orders += item[1]["state"]["balance"] / quote_precision
                 bids += item[1]["state"]["balance"] / quote_precision
              if item[1]["type"] == "ask_order":
                 total_orders += (item[1]["state"]["balance"] / base_precision) * median_quote
                 asks += (item[1]["state"]["balance"] / base_precision) * median_quote
              if item[1]["type"] == "cover_order":
                 total_orders += (item[1]["collateral"] / base_precision) * median_quote
                 shorts += (item[1]["collateral"] / base_precision) * median_quote
           return total_orders, bids, asks, shorts
        return

    def total_account_value(self, account):
        base = "BTS"
        markets = ["GOLD", "SILVER", "USD"]
        account_value = 0.0
        balance_bts = self.get_balance(account, base)
        for quote in markets:
           total_orders, bids, asks, shorts  = self.get_open_order_balance(account, base, quote)
           precision = float(self.get_precision(self.asset_id(quote)) )
           balance = float(self.get_balance(account, quote))
           median = float(self.get_median(quote))
           account_value = account_value + (total_orders / median) + (balance / median)

        account_value += balance_bts
        return account_value

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053
Interesting thought to put up a bounty for that feature. It's not just to see the value of the BTS in my wallet relative to other currencies, but to see the full account value including current market prices for the other bitassets. It'd be nice to log in and see the bottom line full wallet value. 

Tuck Fheman

  • Guest
Suggestion for future dev of the client:

It'd be great to have an account value feature on the Dashboard so you can see the total value of all your BTS and other assets. Ideally, we'd have the option that RippleTrade has of seeing total value in BTS, BTC, USD, or other useful currencies.

1 BitShares = 1 BitShares.

What you're asking for could probably be handled with a small bounty to code that in for you personally and compile the wallet (if necessary). I'm just guessing that would be possible, since it's a relatively easy task (I think).
« Last Edit: May 30, 2015, 04:36:43 am by Tuck Fheman »

Offline BunkerChainLabs-DataSecurityNode

I prefer to calculate total asset value in chocolate bars.

Even having one is still delicious. :)
+-+-+-+-+-+-+-+-+-+-+
www.Peerplays.com | Decentralized Gaming Built with Graphene - Now with BookiePro and Sweeps!
+-+-+-+-+-+-+-+-+-+-+

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053
true, even a total BTS or BTC value summary would be cool...

merockstar

  • Guest
it would be a nice feature, but I don't mind not having it.

I don't like to think of the value of my BTS in terms of USD. I do my best to just block it out and forget I own any.

Offline cylonmaker2053

  • Hero Member
  • *****
  • Posts: 1004
  • Saving the world one block at a time
    • View Profile
  • BitShares: cylonmaker2053
Suggestion for future dev of the client:

It'd be great to have an account value feature on the Dashboard so you can see the total value of all your BTS and other assets. Ideally, we'd have the option that RippleTrade has of seeing total value in BTS, BTC, USD, or other useful currencies.