MCPcopy Index your code
hub / github.com/dude333/rapina

github.com/dude333/rapina @v1.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.0 ↗ · + Follow
350 symbols 989 edges 60 files 182 documented · 52% updated 2y agov1.1.0 · 2022-10-04★ 2267 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

𝚛𝚊𝚙𝚒𝚗𝚊

Download and process Brazilian companies' financial data directly from CVM. [Em português]

GitHub release Travis License

1. Installation

No installation required, just download the latest released executable. Then open a terminal (CMD on Windows) and run the commands shown below.

2. Commands

For the first time, run the following command:

./rapina get

Then, to get a company report, together with a summary for the companies from the same sector:

./rapina report <company>

2.1. get| Download and store financial data into the local database

./rapina get [-s]

It downloads all files from CVM web server, parses their contents and stores on a sqlite database at .data/rapina.db.

This command must be run at least once before you run the other commands.

2.1.1 Option

  -s, --sectors   Download and sector classification for companies listed at B3

Used to get only a summary for the other companies from the same sector.

asciicast

2.2. list| List all companies

./rapina list

asciicast

2.3. report| Create a spreadsheet with a company financial data

./rapina report [flags] company_name

A spreadsheet with the financial data will be created and, on another sheet, the summary of all companies in the same sector.

The sector list is obtained from B3 and saved in the sector.yml file (via get -s command). If you want to change the sector grouping, just edit this file.

2.3.1. Options

  -d, --outputDir string   Output directory [default: ./reports]
  -s, --scriptMode         Does not show companies list; uses the most similar
                           company name

On Linux or macOS, use the arrow keys to navigate through the companies list. On Windows, use j and k.

asciicast

2.3.2. Examples

./rapina report WEG

The spreadsheet will be saved at ./reports

./rapina report "TEC TOY" -s -d /tmp/output

The spreadsheet will be saved at /tmp/output

3. Troubleshooting

Some Linux distributions (e.g. Fedora 34) might face some issues regarding the signer authority (Global Sign) that B3 is using on its SSL certificates. In case of x509: certificate signed by unknown authority error, one should manually import the Root CA certificate into the O.S. trusted database:

Fedora 34 / CentOS

  1. Download the Issuer Root Cert

    curl http://secure.globalsign.com/cacert/gsrsaovsslca2018.crt > /tmp/global-signer.der

  2. Convert from .der to .pem

    openssl x509 -inform der -in /tmp/global-signer.der -out /tmp/globalsignroot.pem

  3. Move the .pem file to the anchors folder

    sudo cp /tmp/globalsignroot.pem /usr/share/pki/ca-trust-source/anchors/

  4. Update the trusted certificates database

    sudo update-ca-trust

Ubuntu

  1. Download the Issuer Root Cert

    curl https://secure.globalsign.net/cacert/Root-R1.crt > /tmp/GlobalSign_Root_CA.crt curl https://secure.globalsign.net/cacert/Root-R2.crt > /tmp/GlobalSign_Root_CA_R2.crt

  2. Move the .crt files to the certificates folder

    sudo cp /tmp/GlobalSign_Root_CA.crt /usr/local/share/ca-certificates/ sudo cp /tmp/GlobalSign_Root_CA_R2.crt /usr/local/share/ca-certificates/

  3. Update the trusted certificates database

    sudo update-ca-trust

4. How to compile

If you want to compile your own executable, you need first to download and install the Go compiler. Then follow these steps:

  1. go get github.com/dude333/rapina
  2. cd $GOPATH/src/github.com/dude333/rapina
  3. Change to the cli directory (cd cli)
  4. Compile using the Makefile (make). To cross compile for Windows on Linux, use make win.

5. Contributing

  1. Fork it
  2. cd $GOPATH/src/github.com/your_username
  3. Download your fork to your PC (git clone https://github.com/your_username/rapina && cd rapina)
  4. Create your feature branch (git checkout -b my-new-feature)
  5. Make changes and add them (git add .)
  6. Commit your changes (git commit -m 'Add some feature')
  7. Push to the branch (git push origin my-new-feature)
  8. Create new pull request

6. Screenshot

WEG

7. License

MIT

Extension points exported contracts — how you extend this code

StockStorage (Interface)
StockStorage is the interface that contains the methods needed to parse, save and retrieve stock data to/from a storage. [1 …
stock.go
Logger (Interface)
Logger interface contains the methods needed to poperly display log messages. [1 implementers]
logger.go
FIIStorage (Interface)
FIIStorage is the interface that contains the methods needed to parse, save and retrieve FII data to/from a storage. [1 …
fii.go
ServerOption (FuncType)
(no doc)
server/server.go

Core symbols most depended-on inside this repo

Printf
called by 37
logger.go
axis
called by 25
reports/excel.go
output
called by 24
progress/progress.go
safeDiv
called by 18
reports/reports.go
Run
called by 12
logger.go
newFormat
called by 10
reports/format.go
newStyle
called by 10
reports/format.go
ErrorMsg
called by 9
progress/progress.go

Shape

Function 188
Method 100
Struct 55
Interface 3
FuncType 2
TypeAlias 2

Languages

Go100%

Modules by API surface

reports/db.go30 symbols
parsers/stock.go19 symbols
progress/progress.go18 symbols
reports/excel.go17 symbols
reports/reports.go15 symbols
fetch/fetch_fii.go15 symbols
fetch/fetch.go15 symbols
reports/logger.go14 symbols
server/server.go13 symbols
parsers/fiidb.go11 symbols
logger.go11 symbols
fetch/fetch_stock.go11 symbols

For agents

$ claude mcp add rapina \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page