所以我正在使用 robin-stocks api,我试图从提供的函数中提取特定数据。
我打印时的输出:
positions = r.crypto.get_crypto_positions()
是:
[{'account_id': 'removed', 'cost_bases': [{'currency_id': 'removed', 'direct_cost_basis': '0.110000000000000000', 'direct_quantity': '0.000011050000000000', 'id': 'removed', 'intraday_quantity': '0.000000000000000000', 'intraday_cost_basis': '0.000000000000000000', 'marked_cost_basis': '0.000000000000000000', 'marked_quantity': '0.000000000000000000'}], 'created_at': '2020-05-07T20:44:23.510080-04:00', 'currency': {'brand_color': 'EA963D', 'code': 'BTC', 'id': 'removed', 'increment': '0.000000010000000000', 'name': 'Bitcoin', 'type': 'cryptocurrency'}, 'id': 'removed', 'quantity': '0.000011050000000000', 'quantity_available': '0.000011050000000000', 'quantity_held_for_buy': '0.000000000000000000', 'quantity_held_for_sell': '0.000000000000000000', 'updated_at': '2020-05-07T23:40:34.381524-04:00'}]
这是他们网站上关于此的文档:
robin_stocks.crypto.get_crypto_positions(info=None)[source]
返回账户的加密头寸。
参数: info (Optional[str]) - 将过滤结果以获取特定值。返回:返回每个选项的键/值对字典列表。如果提供了 info 参数,则返回字符串列表,其中字符串是与 info 匹配的键的值。
我在这里的目标是获得'direct_cost_basis'. 我怎样才能做到这一点?我在 python 方面相当不错,但这只是我的头脑。