@verb #1409:"portfolio" any any any rxdo #7407 @program #1409:"portfolio" any any any caller_perms() == player || caller == this || raise(E_PERM) if (argstr) if ($command_utils:player_match_failed(who = $string_utils:match_player(argstr), argstr)) return endif else who = player endif info = this.user_info[i = who in this.user_objs] {cash, stocks} = info telldata = del = {} totinvest = totworth = 0.0 j = 1 while (j <= length(stocks)) fl = 0 if (j == length(stocks)) {ticker, ?owned = 0, ?invested = 0.0} = stocks[j] if (owned <= 0) stocks = listdelete(stocks, j) continue endif try price = listassoc(ticker, this.quotes)[2] except (E_RANGE) player:tell("Stock ticker \"", ticker, "\" no longer listed on the exchange. Removing it from your portfolio.") stocks = listdelete(stocks, j) continue endtry if (price == -1) price = this:_get_index() endif worth = tofloat(owned) * price totworth = totworth + worth totinvest = totinvest + invested telldata = {@telldata, {ticker, owned, $su:currency(price), $su:currency(invested), $su:currency(worth), "-", "", "", "", "", ""}} elseif (j % 2) {s1, s2} = stocks[j..j + 1] {ticker1, ?owned1 = 0, ?invested1 = 0.0} = s1 {ticker2, ?owned2 = 0, ?invested2 = 0.0} = s2 owned2 <= 0 && (stocks = listdelete(stocks, j + 1)) owned1 <= 0 && (stocks = listdelete(stocks, j)) if (owned2 <= 0 || owned1 <= 0) continue endif try price2 = listassoc(ticker2, this.quotes)[2] except (E_RANGE) player:tell("Stock ticker \"", ticker2, "\" no longer listed on the exchange. Removing it from your portfolio.") stocks = listdelete(stocks, j + 1) fl = 1 endtry if (price2 == -1) price2 = this:_get_index() endif try price1 = listassoc(ticker1, this.quotes)[2] except (E_RANGE) player:tell("Stock ticker \"", ticker1, "\" no longer listed on the exchange. Removing it from your portfolio.") stocks = listdelete(stocks, j) fl = 1 endtry if (price1 == -1) price1 = this:_get_index() endif if (fl) continue endif worth1 = tofloat(owned1) * price1 worth2 = tofloat(owned2) * price2 totworth = totworth + worth1 + worth2 totinvest = totinvest + invested1 + invested2 telldata = {@telldata, {ticker1, owned1, $su:currency(price1), $su:currency(invested1), $su:currency(worth1), "-", ticker2, owned2, $su:currency(price2), $su:currency(invested2), $su:currency(worth2)}} endif j = j + 2 endwhile this.user_info[i][2] = stocks player:tellcolumns("lrrrrllrrrr", {5.0, 5.0, 5.0, 5.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0}, {"Tick", "Shares", "Price", "Invested", "Worth", "-", "Tick", "Shares", "Price", "Invested", "Worth"}, @telldata) if (caller != this) player:tell("") player:tell("You have ", $su:currency(cash), " cash in your account.") player:tell("You have ", $su:currency(totinvest), " that has been invested into stocks.") player:tell("Your portfolio is worth ", $su:currency(totworth), " right now.") player:tell("Your personal net worth is currently ", $su:currency(totworth + cash), ".") endif "Last modified by Cecil (#7407) on Fri Apr 19 11:09:00 2002 MDT." .