# Integration of AWS Deep Graph insights for bond trading forecasts

AWS has developed the Deep Graph Knowledge Embedding Library (DGL-KE), a knowledge graph integration library based on the Deep Graph Library (DGL). DGL is a scalable, high-performance Python library for deep learning in graphs. This library is used by advanced machine learning systems developed with Trumid to build a credit trading platform.

Trumid has developed an electronic trading platform where traders can buy and sell bonds and interact with the community. With the expansion of the user network, Trumid needs an ML system to provide a personalized trading experience by modeling the preferences and interests of its platform users. In this way, the most relevant information and information is presented to each user to enable a faster and more organized trading experience.

AWS Machine Learning Solutions Lab is engaged to help Trumid’s AI and Data Strategy team jointly develop an end-to-end pipeline consisting of data preparation, model training, and network model-based inference processes deep neural built using Deep Graph Library for Knowledge Integration (DGL-KE).

Bond trading can be thought of as a web of interaction between buyers and sellers involving different types of bonds, so a chart provides a natural way to model this real-world complexity with the information embedded in the relationship between entities.

In this case, graph ML algorithms scale better than traditional ML algorithms due to the nature of the dataset. A traditional ML algorithm works with data structured in the form of tables, a graphical ML algorithm learns from a graphical dataset which includes information about constituent nodes, edges, and other features.

The data set used by Trumid and AWS is characterized by dimensions such as transaction size, duration, issuer, rate, coupon values, bid/ask bid, protocol type of trading and indications of interest (IOI). This data is used to construct graphs of interactions between traders, bonds and issuer and a graphical ML model is developed to predict future interactions.

The first step in the recommendation pipeline is data preparation: trading data is represented as a graph with only nodes and edges typed where nodes are traders or bonds and edges are relationships and this set of data is saved in TSV format.

*Chart or relationships between traders, bonds and bond issuers*

DGL-KE is well suited for knowledge graphs, that is, graphs composed only of nodes and relations. The knowledge graph is a structured mix of entities, relationships and semantic description. The information stored in the knowledge graph is often specified in triplets: head, relation and tail ([h,r,t]) where heads and tails are the entities and the union is also known as the declarations.

Knowledge graph embeds are a low-dimensional representation of the entities and relationships in a knowledge graph. Popular KGE models are: TransE, TransR, RESCAL, DistMult, ComplEx and RotatE. The difference between these models is the score function. This function measures the distance between related entities by their relationship. In other words: features linked by a relationship are close to each other, while other unrelated features are far apart in vector space.

For this particular application, the TransE integration model is used for the learning phase and to predict new trades, equality:

*Source node integration + relationship integration = target node integration *

Where the source node integration is the merchant integration, the relationship integration is the recent transaction integration, and the target node are the closest links of the resulting integration.

This approach is tested to calculate the scores of all possible recent trade relationships and calculate the 100 highest scores for each trader.

The solution is released to production as a single script in the SageMaker job. This is possible because there is no need to separate data preparation, model training, and prediction.

With this implementation, the average recall, i.e. the percentage of actual transactions predicted by the recommender, averaged over all merchants, is improved by 80% compared to other methods for all types of transactions.