Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
WISEPLAT
GitHub Repository: WISEPLAT/python-code
Path: blob/master/ invest-robot-contest_tinkoff_invest_robot-main/src/algotrading/get_shares.py
12267 views
1
from loguru import logger
2
from tinkoff.invest import InstrumentStatus
3
4
from . import glossary, utils
5
6
7
def get_shares(client):
8
shares_info = {}
9
shares = client.instruments.shares(instrument_status=InstrumentStatus.INSTRUMENT_STATUS_BASE)
10
for share in shares.instruments:
11
shares_info[share.figi] = {}
12
for key in glossary.thead.keys():
13
if key == "min_price_increment":
14
shares_info[share.figi][key] = utils.to_float(share.__getattribute__(key))
15
elif key == "trading_status":
16
shares_info[share.figi][key] = glossary.trading_status.get(share.__getattribute__(key)._name_)
17
else:
18
shares_info[share.figi][key] = share.__getattribute__(key)
19
20
return shares_info
21
22
23
def main():
24
api_client = utils.api_client_configure()
25
with api_client as client:
26
shares = get_shares(client)
27
28
return shares
29
30
31
if __name__ == "__main__":
32
main()
33
34