在比特股的区块链浏览器上,我们可以查询bitCN这项资产的相关信息。
https://www.cryptofresh.com/a/CNY
喂价信息 / Feeds
区块链浏览器可以查询喂价信息
其中有一点对我而言很不方便,就是喂价是以CNY=>BTS的方式表示的,我的大脑没法处理这种价格。
尽管在区块链浏览器中可以点击来对调资产对,但是对调以后喂价信息没有啦。于是我就想能否用python-bitshares实现个显示喂价的功能。
Python 代码
经过一番了解,发现python-bitshares中的Asset类可以实现这个功能。
比如说使用Asset类的feeds属性
获取喂价列表:
简单的示例代码如下:
from bitshares.asset import Asset
from prettytable import PrettyTable
from pprint import pprint
import operator
from bitshares import BitShares
bitshares = BitShares(node="wss://bitshares-api.wancloud.io/ws")
asset=Asset(asset="CNY", bitshares_instance=bitshares)
t = PrettyTable(["Producer", "Settlement Price", "CER", "MCR", "MSSR", "Time"])
feeds = list(asset.feeds)
feeds_sorted = sorted(feeds, key=operator.itemgetter('date'), reverse=True)
t.padding_width = 1
#t.align["Collateral"] = "r"
#t.align["Debt"] = "r"
for item in feeds_sorted:
t.add_row([str(item['producer']['name']),
str(item['settlement_price']),
str(item['core_exchange_rate']),
str(item['maintenance_collateral_ratio']),
str(item['maximum_short_squeeze_ratio']),
str(item['date'])])
print(t)
执行效果
运行效果如下:
其它
我们还可以通过Asset类的feed属性
来获取当前喂价信息
突然间发现自己就是个文盲,这些参数干啥的,两眼一抹黑。
如果简单的想获取喂价信息,还是使用公众号查询方便:
😭哭,我明明记得我写文之前,价格4.5多呢。
封面图源:https://pixabay.com
Nice post
upvoted followed
good post you fren
dane wonderfully
@oflyhigh your posts are amezing like your ranking. Thanks for sharing. Please follow me @dreamlandsteem.
beautiful post keep going
this coding is like a amazing wise ur ranking... plz follow and comment me also @rajat1802
good informations friend
New Year will enter tonight with midnight
We hope that it will be better than 2017 and that there will be more progress and prosperity
Happy year to all and we wish all the struggle and diligence in this year to realize your dreams
Let us make this year a beautiful and happy year for all
wooow, i like it, haha
Thanks for share ...
Hello there :)
Always great to discover new articles and I really like yours!
You can follow me if you like photography and if you are interested in seeing beautiful places, portraits and landscapes: as a passionate photographer I try to build my place here by sharing my work. I hope you'll like it :)
Here is an example of my work :
and you can see my personal presentation here
Have a great day!!