Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.
/ xpbonds Public archive

Detect the best bonds from XP Investments' reports

License

Notifications You must be signed in to change notification settings

rafaeljusto/xpbonds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XP Bonds

GoDoc license

Serverless solution to parse and analyze bond reports from XP Investments. It was built to run in AWS Lambda service. There's also a common HTTP server solution that can be used in other environments.

How does it works?

The service receives the Focused Lists report from XP Investments, in Excel format (xlsx), like the bellow.

XP Investments Report Example

The Excel report will be analyzed filtering undesired bonds with the following rules:

  • Minimum coupon rate
  • Maturity
  • Price

The resulted bonds will be sorted by coupon. Current market price will also be retrieved to compare with the report (when available).

Serveless Setup

% go get -u github.com/rafaeljusto/xpbonds/...
% cd $GOPATH/github.com/rafaeljusto/xpbonds/cmd/xpbonds-serveless
% GOOS=linux go build -o xpbonds *.go && zip xpbonds.zip ./xpbonds
% aws lambda create-function \
  --region <region> \
  --function-name xpbonds \
  --memory 512 \
  --role <arn:aws:iam::account-id:role/execution_role> \
  --runtime go1.x \
  --zip-file fileb://$GOPATH/github.com/rafaeljusto/xpbonds/xpbonds.zip \
  --handler xpbonds

Serveless Protocol

The JSON that the service is expecting a events.APIGatewayProxyRequest, where the method should be POST and the body should be:

{
  "xlsxReport": "EsDBBQABgAIAAAAIQBG8ICPdQEAAD...BQYAAAAADwAPAN4DAABChAEAAAA=",
  "dateFormat": "MM/DD/YYYY",
  "minCoupon": 5,
  "maxMaturity": 6,
  "minPrice": 95,
  "maxPrice": 101,
  "minPiece": 0,
  "maxPiece": 400000
}

Where:

  • xlsxReport is the XLSX report encoded in base64;
  • dateFormat defines the date format used in the report, possible values are MM/DD/YYYY or DD/MM/YYYY;
  • minCoupon will filter bonds that have a coupon rate (%) less than the provided;
  • maxMaturity defined in years also will filter bonds with an expiration date too far away;
  • minPrice and maxPrice defines a range of acceptable market prices for the bonds;
  • minPiece and maxPiece defines a range of acceptable minimum piece of a bond;
  • focusedOnly flag to determinate if only XP suggested bonds should be analyzed.

CORS is enable to make it easy for cross-domain requests. The response will be a events.APIGatewayProxyResponse, where the body will contain a list of bonds in the following format:

[
  {
    "name": "Gol Linhas Aereas Inteligentes",
    "security": "GOLLBZ 8 7/8 01/24/22",
    "coupon": 8.875,
    "yield": 8.6,
    "maturity": "2022-01-24T00:00:00Z",
    "lastPrice": 100.4,
    "duration": 1.8,
    "yearsToMaturity": 3.1,
    "minimumPiece": 200000,
    "country": "BR",
    "risk": {
      "standardPoor": "B-",
      "moody": "n.a.",
      "fitch": "B"
    },
    "code": "USL4441PAA86"
  }
]

PS: maturity could be null when the bond has no end date.

User Interface

There's a simple user web interface to easy retrieve the best bonds. If you decide using it, please remember to replace an internal URL for your production server.

User Interface

About

Detect the best bonds from XP Investments' reports

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published