nectar.vote module

class nectar.vote.AccountVotes(account, start: datetime | str | None = None, stop: datetime | str | None = None, raw_data=False, lazy=False, full=False, blockchain_instance=None, **kwargs)

Bases: VotesObject

Obtain a list of votes for an account Lists the last 100+ votes on the given account.

Parameters:
  • account (str) – Account name

  • blockchain_instance (Blockchain) – Blockchain instance to use when accessing RPC

class nectar.vote.ActiveVotes(authorperm, lazy=False, full=False, blockchain_instance=None, **kwargs)

Bases: VotesObject

Obtain a list of votes for a post

Parameters:
  • authorperm (str) – authorperm link

  • blockchain_instance (Blockchain) – Blockchain instance to use when accessing RPC

get_downvote_pct_to_zero(account)

Calculate the vote percent (internal units; -10000 = -100%) required for the given account to downvote this post’s pending payout to zero USING THE PAYOUT FORMULA shared as reference (reward fund + median price + effective vesting shares), adjusted by the account’s current downvoting power.

If the account’s full 100% downvote (at current downvoting power) is insufficient, returns -10000.

class nectar.vote.Vote(voter, authorperm=None, lazy=False, full=False, blockchain_instance=None, **kwargs)

Bases: BlockchainObject

Read data about a Vote in the chain

Parameters:
  • authorperm (str) – perm link to post/comment

  • blockchain_instance (nectar.nectar.nectar) – nectar instance to use when accessing an RPC

property authorperm
property hbd

Return the HBD value equivalent of this vote’s rshares.

Uses the bound blockchain instance’s rshares_to_hbd to convert the vote’s integer rshares (defaults to 0).

Returns:

float: HBD amount corresponding to the vote’s rshares.

json()
property percent
refresh()

Refresh the Vote object from the blockchain RPC, replacing its internal data with the latest on-chain vote.

If the object has no identifier or the blockchain is not connected, this method returns immediately. It resolves author, permlink, and voter from the stored identifier and queries the node for active votes. If the matching vote is found, the object is reinitialized with the normalized vote data; otherwise VoteDoesNotExistsException is raised.

Raises:

VoteDoesNotExistsException: if the vote cannot be found or the RPC indicates the vote does not exist.

property rep
property reputation
property rshares

Return the vote’s raw rshares as an integer.

Converts the stored rshares value (which may be a string or number) to an int and returns it. If rshares is missing, returns 0.

property time
property token_backed_dollar

Convert this vote’s rshares to HBD (Hive-backed dollar).

Uses the associated blockchain instance’s rshares_to_hbd conversion on the vote’s “rshares” field (defaults to 0 if missing). This is Hive-specific and always returns HBD-equivalent value for the vote.

property votee
property voter
property weight

Return the raw vote weight stored for this vote.

The value is read directly from the underlying vote data (self[“weight”]) and represents the weight field provided by the blockchain (type may be int).

class nectar.vote.VotesObject(iterable=(), /)

Bases: list

get_list(var='voter', voter=None, votee=None, start=None, stop=None, start_percent=None, stop_percent=None, sort_key='time', reverse=True)
get_sorted_list(sort_key='time', reverse=True)
printAsTable(voter=None, votee=None, start=None, stop=None, start_percent=None, stop_percent=None, sort_key='time', reverse=True, allow_refresh=True, return_str=False, **kwargs)

Render the votes collection as a formatted table, with optional filtering and sorting.

Detailed behavior: - Filters votes by voter name, votee (author), time window (start/stop), and percent range (start_percent/stop_percent). - Sorts votes using sort_key (default “time”) and reverse order flag. - Formats columns: Voter, Votee, HBD (token equivalent), Time (human-readable delta), Rshares, Percent, Weight. - If return_str is True, returns the table string; otherwise prints it to stdout.

Parameters:

voter (str, optional): Only include votes by this voter name. votee (str, optional): Only include votes targeting this votee (author). start (datetime or str, optional): Inclusive lower bound for vote time; timezone info is added if missing. stop (datetime or str, optional): Inclusive upper bound for vote time; timezone info is added if missing. start_percent (int, optional): Inclusive lower bound for vote percent. stop_percent (int, optional): Inclusive upper bound for vote percent. sort_key (str, optional): Attribute name used to sort votes (default “time”). reverse (bool, optional): If True, sort in descending order (default True). allow_refresh (bool, optional): If False, prevents refreshing votes during iteration by marking them as cached. return_str (bool, optional): If True, return the rendered table as a string; otherwise print it. **kwargs: Passed through to PrettyTable.get_string when rendering the table.

Returns:

str or None: The table string when return_str is True; otherwise None (table is printed).

print_stats(return_str=False, **kwargs)

Print or return a summary table of vote statistics for this collection.

If return_str is True, the formatted table is returned as a string; otherwise it is printed. Accepts the same filtering and formatting keyword arguments used by printAsTable (e.g., voter, votee, start, stop, start_percent, stop_percent, sort_key, reverse).