Ejemplo n.º 1
0
# SETUP TRADING API
trading_api = TradingAPI(credentials=credentials)

# ESTABLISH CONNECTION
trading_api.connect()

# SETUP REQUEST
request_stock = ProductSearch.RequestStocks(
    indexId=5,
    isInUSGreenList=False,
    stockCountryId=886,
    offset=0,
    limit=100,
    requireTotal=True,
    sortColumns='name',
    sortTypes='asc',
)

# FETCH DATA
stock_list = trading_api.product_search(request=request_stock, raw=False)

# LOOP OVER PRODUCTS
for product in stock_list.products:
    print(dict(product))

# LOOP OVER COLUMNS
product = stock_list.products[0]
for column in product:
    print(column, product[column])
Ejemplo n.º 2
0
# SETUP CREDENTIALS
int_account = config_dict['int_account']
username = config_dict['username']
password = config_dict['password']
credentials = Credentials(
    int_account=int_account,
    username=username,
    password=password,
)

# SETUP TRADING API
trading_api = TradingAPI(credentials=credentials)

# ESTABLISH CONNECTION
trading_api.connect()

# SETUP REQUEST
request_lookup = ProductSearch.RequestLookup(
    search_text='APPLE',
    limit=2,
    offset=0,
)

# FETCH DATA
products_lookup = trading_api.product_search(request=request_lookup, raw=False)
products_lookup_dict = payload_handler.message_to_dict(message=products_lookup)
pretty_json = json.dumps(products_lookup_dict, sort_keys=True, indent=4)

print(pretty_json)