diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2020-07-25 01:35:31 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2020-07-25 01:35:31 +0300 |
commit | 4b35f7c2c3edc5c2fc8a9198dca3cd4031ecc2ed (patch) | |
tree | c39fd7d8e1fd2ccd9a224c179d33e1225b318a51 /main.go |
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -0,0 +1,42 @@ +package main + +import "log" + +const ( + OFZ_URL = `https://iss.moex.com/iss/engines/stock/markets/bonds/boards/TQOB/securities.xml?iss.meta=off&iss.only=securities&securities.columns=SECID,NEXTCOUPON,COUPONVALUE,SECNAME,COUPONPERCENT,MATDATE,COUPONPERIOD` + CORP_URL = `https://iss.moex.com/iss/engines/stock/markets/bonds/boards/TQCB/securities.xml?iss.meta=off&iss.only=securities&securities.columns=SECID,NEXTCOUPON,COUPONVALUE,SECNAME,COUPONPERCENT,MATDATE,COUPONPERIOD` +) + +func main() { + d1, err := processFile(OFZ_URL) + if err != nil { + log.Fatal(err) + } + if err := export("офз.csv", d1); err != nil { + log.Fatal(err) + } + d2, err := processFile(CORP_URL) + if err != nil { + log.Fatal(err) + } + if err := export("корп.csv", d2); err != nil { + log.Fatal(err) + } +} + +func processFile(url string) ([]*Document, error) { + in, err := download(url) + if err != nil { + return nil, err + } + var documents []*Document + for _, item := range in.Data.Rows.Items { + d, err := parse(item) + if err != nil { + log.Println(err) + continue + } + documents = append(documents, d) + } + return documents, nil +} |