forked from sklinkert/alphavantage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbalance_sheets.go
113 lines (106 loc) · 6.58 KB
/
balance_sheets.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package alphavantage
import (
"encoding/json"
"fmt"
)
type BalanceSheets struct {
Symbol string `json:"symbol"`
AnnualReports []AnnualReport `json:"annualReports"`
QuarterlyReports []QuarterlyReport `json:"quarterlyReports"`
}
type AnnualReport struct {
FiscalDateEnding string `json:"fiscalDateEnding"`
ReportedCurrency string `json:"reportedCurrency"`
TotalAssets float64 `json:"totalAssets"`
TotalCurrentAssets float64 `json:"totalCurrentAssets"`
CashAndCashEquivalentsAtCarryingValue float64 `json:"cashAndCashEquivalentsAtCarryingValue"`
CashAndShortTermInvestments float64 `json:"cashAndShortTermInvestments"`
Inventory float64 `json:"inventory"`
CurrentNetReceivables float64 `json:"currentNetReceivables"`
TotalNonCurrentAssets float64 `json:"totalNonCurrentAssets"`
PropertyPlantEquipment float64 `json:"propertyPlantEquipment"`
AccumulatedDepreciationAmortizationPPE float64 `json:"accumulatedDepreciationAmortizationPPE"`
IntangibleAssets float64 `json:"intangibleAssets"`
IntangibleAssetsExcludingGoodwill float64 `json:"intangibleAssetsExcludingGoodwill"`
Goodwill float64 `json:"goodwill"`
Investments float64 `json:"investments"`
LongTermInvestments float64 `json:"longTermInvestments"`
ShortTermInvestments float64 `json:"shortTermInvestments"`
OtherCurrentAssets float64 `json:"otherCurrentAssets"`
OtherNonCurrentAssets float64 `json:"otherNonCurrentAssets"`
TotalLiabilities float64 `json:"totalLiabilities"`
TotalCurrentLiabilities float64 `json:"totalCurrentLiabilities"`
CurrentAccountsPayable float64 `json:"currentAccountsPayable"`
DeferredRevenue float64 `json:"deferredRevenue"`
CurrentDebt float64 `json:"currentDebt"`
ShortTermDebt float64 `json:"shortTermDebt"`
TotalNonCurrentLiabilities float64 `json:"totalNonCurrentLiabilities"`
CapitalLeaseObligations float64 `json:"capitalLeaseObligations"`
LongTermDebt float64 `json:"longTermDebt"`
CurrentLongTermDebt float64 `json:"currentLongTermDebt"`
LongTermDebtNoncurrent float64 `json:"longTermDebtNoncurrent"`
ShortLongTermDebtTotal float64 `json:"shortLongTermDebtTotal"`
OtherCurrentLiabilities float64 `json:"otherCurrentLiabilities"`
OtherNonCurrentLiabilities float64 `json:"otherNonCurrentLiabilities"`
TotalShareholderEquity float64 `json:"totalShareholderEquity"`
TreasuryStock float64 `json:"treasuryStock"`
RetainedEarnings float64 `json:"retainedEarnings"`
CommonStock float64 `json:"commonStock"`
CommonStockSharesOutstanding float64 `json:"commonStockSharesOutstanding"`
}
type QuarterlyReport struct {
FiscalDateEnding string `json:"fiscalDateEnding"`
ReportedCurrency string `json:"reportedCurrency"`
TotalAssets float64 `json:"totalAssets"`
TotalCurrentAssets float64 `json:"totalCurrentAssets"`
CashAndCashEquivalentsAtCarryingValue float64 `json:"cashAndCashEquivalentsAtCarryingValue"`
CashAndShortTermInvestments float64 `json:"cashAndShortTermInvestments"`
Inventory float64 `json:"inventory"`
CurrentNetReceivables float64 `json:"currentNetReceivables"`
TotalNonCurrentAssets float64 `json:"totalNonCurrentAssets"`
PropertyPlantEquipment float64 `json:"propertyPlantEquipment"`
AccumulatedDepreciationAmortizationPPE float64 `json:"accumulatedDepreciationAmortizationPPE"`
IntangibleAssets float64 `json:"intangibleAssets"`
IntangibleAssetsExcludingGoodwill float64 `json:"intangibleAssetsExcludingGoodwill"`
Goodwill float64 `json:"goodwill"`
Investments float64 `json:"investments"`
LongTermInvestments float64 `json:"longTermInvestments"`
ShortTermInvestments float64 `json:"shortTermInvestments"`
OtherCurrentAssets float64 `json:"otherCurrentAssets"`
OtherNonCurrentAssets float64 `json:"otherNonCurrentAssets"`
TotalLiabilities float64 `json:"totalLiabilities"`
TotalCurrentLiabilities float64 `json:"totalCurrentLiabilities"`
CurrentAccountsPayable float64 `json:"currentAccountsPayable"`
DeferredRevenue float64 `json:"deferredRevenue"`
CurrentDebt float64 `json:"currentDebt"`
ShortTermDebt float64 `json:"shortTermDebt"`
TotalNonCurrentLiabilities float64 `json:"totalNonCurrentLiabilities"`
CapitalLeaseObligations float64 `json:"capitalLeaseObligations"`
LongTermDebt float64 `json:"longTermDebt"`
CurrentLongTermDebt float64 `json:"currentLongTermDebt"`
LongTermDebtNoncurrent float64 `json:"longTermDebtNoncurrent"`
ShortLongTermDebtTotal float64 `json:"shortLongTermDebtTotal"`
OtherCurrentLiabilities float64 `json:"otherCurrentLiabilities"`
OtherNonCurrentLiabilities float64 `json:"otherNonCurrentLiabilities"`
TotalShareholderEquity float64 `json:"totalShareholderEquity"`
TreasuryStock float64 `json:"treasuryStock"`
RetainedEarnings float64 `json:"retainedEarnings"`
CommonStock float64 `json:"commonStock"`
CommonStockSharesOutstanding float64 `json:"commonStockSharesOutstanding"`
}
func toBalanceSheets(buf []byte) (*BalanceSheets, error) {
balanceSheets := &BalanceSheets{}
if err := json.Unmarshal(buf, balanceSheets); err != nil {
return nil, err
}
return balanceSheets, nil
}
func (c *Client) BalanceSheets(symbol string) (*BalanceSheets, error) {
const function = "BALANCE_SHEET"
url := fmt.Sprintf("%s/query?function=%s&symbol=%s&apikey=%s", baseURL, function, symbol, c.apiKey)
body, err := c.makeHTTPRequest(url)
if err != nil {
return nil, err
}
return toBalanceSheets(body)
}