Skip to content

Application to value a portfolio of multiple asset classes (Supports SG / US / HK markets)

License

Notifications You must be signed in to change notification settings

rodionlim/portfolio-manager-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portfolio Valuation Tool

An application to value equities, fx, commodities, cash, bonds (corps / gov), and cryptocurrencies in your personal portfolio.

Features

  • Value assets based on current market prices
  • Fetch market data based on free data sources (Yahoo finance, Google finance, dividends.sg, ilovessb.com) with local cache
  • Output portfolio blotter data in a CSV file for easy access and manipulation
  • Import / Export portfolio blotter data from CSV file for easy migration to other portfolio systems
  • Store portfolio, reference, dividends and coupon data in leveldb for persistence
  • Display detailed information for individual and aggregated assets
  • OpenAPI compliant for easy integration with other systems

Installation

  1. Install Go version 1.23.4 or higher.
  2. Clone the repository to your local machine.
  3. Run make to build and install the application
  4. Run the portfolio-manager binary to start the application. Pass in config flag -config custom-config.yaml

Quickstart

Start the application

make run

Build the application

make

Wipe the entire database

make clean-db

Tests

make test # unit tests
make test-integration # integration tests

Project Structure

portfolio-manager/
├── cmd/
│   └── portfolio/
│       └── main.go
├── docs/
│   └── swagger.json
├── internal/
│   ├── blotter/
│   ├── config/
│   ├── dal/
│   ├── dividends/
│   ├── mocks/
│   ├── portfolio/
│   └── server/
├── pkg/
│   ├── common/
│   ├── event/
│   ├── logging/
│   ├── mdata/
│   │   └── sources/
│   ├── rdata/
│   └── types/
├── web/
├── .gitignore
├── go.mod
└── README.md

Sample Curl Commands

All API calls are documented (OAS) under http://localhost:8080/swagger/index.html

Add Asset

curl -X POST http://localhost:8080/api/v1/blotter/trade \
    -H "Content-Type: application/json" \
    -d '{
        "ticker": "AAPL",
        "side": "buy",
        "broker": "dbs",
        "trader": "traderA",
        "quantity": 10,
        "price": 150.00,
        "type": "buy",
        "tradeDate": "2024-12-09T00:00:00Z"
    }'

Import Trades from CSV (for migrating into portfolio-manager)

curl -X POST http://localhost:8080/api/v1/blotter/import \
  -F "file=@templates/blotter_import.csv"

Export Trades to a CSV (for migrating out of portfolio-manager)

curl -X GET http://localhost:8080/api/v1/blotter/export

View Positions

curl -X GET http://localhost:8080/api/v1/portfolio/positions

Fetch Asset Prices

curl -X GET http://localhost:8080/api/v1/mdata/price/es3.si
curl -X GET http://localhost:8080/api/v1/mdata/price/eth-usd
curl -X GET http://localhost:8080/api/v1/mdata/price/usd-sgd

Fetch Dividends

# equity - refer to ticker reference for identifier
curl -X GET http://localhost:8080/api/v1/mdata/dividend/es3.si
curl -X GET http://localhost:8080/api/v1/mdata/dividend/aapl

# ssb - format SBMMMYY
curl -X GET http://localhost:8080/api/v1/mdata/dividend/sbjul24

# mas bill
curl -X GET http://localhost:8080/api/v1/mdata/dividend/bs24124z

Fetch Reference Data

curl -X GET http://localhost:8080/api/v1/refdata

Force a compute of dividends for a ticker across the entire blotter

curl -X POST http://localhost:8080/api/v1/dividends -H "Content-Type: application/json" -d '{"ticker": "ES3.SI"}'

Configurations

Sample configurations

verboseLogging: true
logFilePath: ./portfolio-manager.log
host: localhost
port: 8080
db: leveldb
dbPath: ./portfolio-manager.db
refDataSeedPath: "./seed/refdata.yaml"
divWitholdingTaxSG: 0
divWitholdingTaxUS: 0.3
divWitholdingTaxHK: 0
divWitholdingTaxIE: 0.15

Roadmap

  1. Support non SGD dividends (Implemented)
  2. Support MAS TBills (Implemented)
  3. Support Crypto market data (Implemented)
  4. Support FX market data (Implemented)
  5. Support exporting/importing of leveldb for backup
  6. Add UI and convert to a monorepo
  7. Refactor configuration to have sections

Contributing

Contributions are always welcome! If you have any suggestions or find a bug, please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the license file for details.

About

Application to value a portfolio of multiple asset classes (Supports SG / US / HK markets)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published