import tinkoff_grpc
import market_trade.constants

if __name__ == '__main__':
    api_address = market_trade.constants.TINKOFF_API_ADDRESS
    token = market_trade.constants.TINKOFF_BEARER_TOKEN
    authorization_field = market_trade.constants.TINKOFF_AUTHORIZATION_HEADER
    with tinkoff_grpc.Channel(api_address=api_address,
                              token=token,
                              authorization_field=authorization_field) as tinkoff_channel:
        instrument_service = tinkoff_grpc.InstrumentsService(tinkoff_channel)
        shares = instrument_service.get_shares(market_trade.constants.DEFAULT_INSTRUMENT_STATUS)
        print(len(shares))
        for share in shares:
            print(share.is_api_tradeable)
