Update for steemengine - token class and command line tool added

in #utopian-io7 years ago (edited)

image.png

Repository

https://github.com/holgern/steemengine

steemengine

steemengine is a python library for working with steem-engine.com tokens.

I released version 0.3.0 which can be installed by

pip install steemengine

New features

New Token class

I added a token class, that can be used to receive information about a token.

from steemengine.tokenobject import Token
eng = Token("ENG")
print(eng)
print(eng.get_holder())
print(eng.get_market_info())
print(eng.get_buy_book())
print(eng.get_sell_book())

get_holder

All accounts that currently are holding a token can be received by the get_holder() function
It uses the find function from the api:

holder = self.api.find("tokens", "balances", query={"symbol": self.symbol})

It returns a list of dict-objects. Each dict object is of the following structure:

{'$loki': 2,
 'account': 'steemsc',
 'balance': '1973148.55400000',
 'symbol': 'ENG'}

get_market_info()

This function uses:

metrics = self.api.find_one("market", "metrics", query={"symbol": self.symbol})

and returns the following structure:

{'$loki': 1,
 'highestBid': '0.81000',
 'lastDayPrice': '0.949',
 'lastDayPriceExpiration': 1552346331,
 'lastPrice': '0.949',
 'lowestAsk': '0.949',
 'priceChangePercent': '0.00%',
 'priceChangeSteem': '0.000',
 'symbol': 'ENG',
 'volume': 223.535,
 'volumeExpiration': 1552346331}

get_buy_book() and get_sell_book()

These functions return the sell/buy book of all currently not fullfilled order at the market.

Command line tool

I added a command line tool to the python package. It has currently two commands.
After installing the steemengine library, a steemengine command should be available in the terminal.

steemengine --version

and

steemengine --help

should be working.

steemengine richlist

This command returns the top n token holder.
For example the top 10 ENG token holder can be shown be the following command:

 steemengine richlist -t 10 ENG

image.png

The STEEM value of the token balance is obtained by multiplying the balance by the lastPrice field from get_market_info().

steemengine info

This command can be used to receive information about

latest block

steemengine info

image.png

a sidechain block

steemengine info 16695

image.png

a token

steemengine info ENG

image.png

an account

steemengine info holger80

image.png

a transaction id

steemengine info 12ed6e59179a8b5441809d60dc3025143f17ff9f

image.png

PyInstaller

I created two pyinstaller specs, which will create a one file standalone executable and a one-directory standalone excecutable. I setup appveyoer, in order to build a packed version for windows:
https://ci.appveyor.com/project/holger80/steemengine
I will put the newest Windows-Versions to the release page: https://github.com/holgern/steemengine/releases

Commits

Changelog and pyinstaller build instruction added

Add command line tool for showing block, token and account info

  • commit e8362861
  • Add CLI for showing information about blocks, transaction ids, token and accounts
  • Unit tests for tokenobject and tokens added
  • get_buy_book and get_sell_book for Wallet added

Add Token class, remove unused imports and fix some variable names

  • commit d34d5ee
  • The new Token class returns, token holder, market information and token information
  • some camelcase variable names fixed
  • unused imports removed
  • version increased to 0.3.0

GitHub Account

https://github.com/holgern

Sort:  
  • Good post with images and code samples.
  • Good commits messages and comments in the code.
  • Great advancement to bring smart contract and tokens to the Steem blockchain.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thank you for your review, @helo! Keep up the good work!

hey, thanks again. I am counting on you to make some easy full set delegation tool for steemmonsters..

Posted using Partiko Android

I will work on a command line tool :)

Posted using Partiko Android

You're on fire :D

Hi @holger80!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

This post is supported by $5.02 @tipU upvote funded by @cardboard :)
@tipU voting service always profitable, instant upvotes | For investors.

Thank you so much for participating in the Partiko Delegation Plan Round 1! We really appreciate your support! As part of the delegation benefits, we just gave you a 3.00% upvote! Together, let’s change the world!

Hey, @holger80!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

This post has been included in the latest edition of SoS Daily News - a digest of all the latest news on the Steem blockchain.