Skip to content

Commit 02f88f9

Browse files
committed
added csv tags to structs
1 parent e2d6921 commit 02f88f9

File tree

1 file changed

+140
-140
lines changed

1 file changed

+140
-140
lines changed

yfin.go

Lines changed: 140 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,39 @@ type Params struct {
7777
type Equity struct {
7878
Quote
7979
// Equity-only fields.
80-
LongName string `json:"longName"`
81-
EpsTrailingTwelveMonths float64 `json:"epsTrailingTwelveMonths"`
82-
EpsForward float64 `json:"epsForward"`
83-
EarningsTimestamp int `json:"earningsTimestamp"`
84-
EarningsTimestampStart int `json:"earningsTimestampStart"`
85-
EarningsTimestampEnd int `json:"earningsTimestampEnd"`
86-
TrailingAnnualDividendRate float64 `json:"trailingAnnualDividendRate"`
87-
DividendDate int `json:"dividendDate"`
88-
TrailingAnnualDividendYield float64 `json:"trailingAnnualDividendYield"`
89-
TrailingPE float64 `json:"trailingPE"`
90-
ForwardPE float64 `json:"forwardPE"`
91-
BookValue float64 `json:"bookValue"`
92-
PriceToBook float64 `json:"priceToBook"`
93-
SharesOutstanding int `json:"sharesOutstanding"`
94-
MarketCap int64 `json:"marketCap"`
80+
LongName string `json:"longName" csv:"longName"`
81+
EpsTrailingTwelveMonths float64 `json:"epsTrailingTwelveMonths" csv:"epsTrailingTwelveMonths"`
82+
EpsForward float64 `json:"epsForward" csv:"epsForward"`
83+
EarningsTimestamp int `json:"earningsTimestamp" csv:"earningsTimestamp"`
84+
EarningsTimestampStart int `json:"earningsTimestampStart" csv:"earningsTimestampStart"`
85+
EarningsTimestampEnd int `json:"earningsTimestampEnd" csv:"earningsTimestampEnd"`
86+
TrailingAnnualDividendRate float64 `json:"trailingAnnualDividendRate" csv:"trailingAnnualDividendRate"`
87+
DividendDate int `json:"dividendDate" csv:"dividendDate"`
88+
TrailingAnnualDividendYield float64 `json:"trailingAnnualDividendYield" csv:"trailingAnnualDividendYield"`
89+
TrailingPE float64 `json:"trailingPE" csv:"trailingPE"`
90+
ForwardPE float64 `json:"forwardPE" csv:"forwardPE"`
91+
BookValue float64 `json:"bookValue" csv:"bookValue"`
92+
PriceToBook float64 `json:"priceToBook" csv:"priceToBook"`
93+
SharesOutstanding int `json:"sharesOutstanding" csv:"sharesOutstanding"`
94+
MarketCap int64 `json:"marketCap" csv:"marketCap"`
9595
}
9696

9797
// ETF represents a single etf quote.
9898
type ETF struct {
9999
Quote
100100
// MutualFund/ETF-only fields.
101-
YTDReturn float64 `json:"ytdReturn"`
102-
TrailingThreeMonthReturns float64 `json:"trailingThreeMonthReturns"`
103-
TrailingThreeMonthNavReturns float64 `json:"trailingThreeMonthNavReturns"`
101+
YTDReturn float64 `json:"ytdReturn" csv:"ytdReturn"`
102+
TrailingThreeMonthReturns float64 `json:"trailingThreeMonthReturns" csv:"trailingThreeMonthReturns"`
103+
TrailingThreeMonthNavReturns float64 `json:"trailingThreeMonthNavReturns" csv:"trailingThreeMonthNavReturns"`
104104
}
105105

106106
// MutualFund represents a single mutual fund share quote.
107107
type MutualFund struct {
108108
Quote
109109
// MutualFund/ETF-only fields.
110-
YTDReturn float64 `json:"ytdReturn"`
111-
TrailingThreeMonthReturns float64 `json:"trailingThreeMonthReturns"`
112-
TrailingThreeMonthNavReturns float64 `json:"trailingThreeMonthNavReturns"`
110+
YTDReturn float64 `json:"ytdReturn" csv:"ytdReturn"`
111+
TrailingThreeMonthReturns float64 `json:"trailingThreeMonthReturns" csv:"trailingThreeMonthReturns"`
112+
TrailingThreeMonthNavReturns float64 `json:"trailingThreeMonthNavReturns" csv:"trailingThreeMonthNavReturns"`
113113
}
114114

115115
// Index represents a single market Index quote.
@@ -125,25 +125,25 @@ type Index struct {
125125
type Option struct {
126126
Quote
127127
// Options/Futures-only fields.
128-
UnderlyingSymbol string `json:"underlyingSymbol"`
129-
OpenInterest int `json:"openInterest"`
130-
ExpireDate int `json:"expireDate"`
131-
Strike float64 `json:"strike"`
132-
UnderlyingExchangeSymbol string `json:"underlyingExchangeSymbol"`
128+
UnderlyingSymbol string `json:"underlyingSymbol" csv:"underlyingSymbol"`
129+
OpenInterest int `json:"openInterest" csv:"openInterest"`
130+
ExpireDate int `json:"expireDate" csv:"expireDate"`
131+
Strike float64 `json:"strike" csv:"strike"`
132+
UnderlyingExchangeSymbol string `json:"underlyingExchangeSymbol" csv:"underlyingExchangeSymbol"`
133133
}
134134

135135
// Future represents a single futures contract quote
136136
// for a specified strike and expiration.
137137
type Future struct {
138138
Quote
139139
// Options/Futures-only fields.
140-
UnderlyingSymbol string `json:"underlyingSymbol"`
141-
OpenInterest int `json:"openInterest"`
142-
ExpireDate int `json:"expireDate"`
143-
Strike float64 `json:"strike"`
144-
UnderlyingExchangeSymbol string `json:"underlyingExchangeSymbol"`
145-
HeadSymbolAsString string `json:"headSymbolAsString"`
146-
IsContractSymbol bool `json:"contractSymbol"`
140+
UnderlyingSymbol string `json:"underlyingSymbol" csv:"underlyingSymbol"`
141+
OpenInterest int `json:"openInterest" csv:"openInterest"`
142+
ExpireDate int `json:"expireDate" csv:"expireDate"`
143+
Strike float64 `json:"strike" csv:"strike"`
144+
UnderlyingExchangeSymbol string `json:"underlyingExchangeSymbol" csv:"underlyingExchangeSymbol"`
145+
HeadSymbolAsString string `json:"headSymbolAsString" csv:"headSymbolAsString"`
146+
IsContractSymbol bool `json:"contractSymbol" csv:"contractSymbol"`
147147
}
148148

149149
// ForexPair represents a single forex currency pair quote.
@@ -155,12 +155,12 @@ type ForexPair struct {
155155
type CryptoPair struct {
156156
Quote
157157
// Cryptocurrency-only fields.
158-
Algorithm string `json:"algorithm"`
159-
StartDate int `json:"startDate"`
160-
MaxSupply int `json:"maxSupply"`
161-
CirculatingSupply int `json:"circulatingSupply"`
162-
VolumeLastDay int `json:"volume24Hr"`
163-
VolumeAllCurrencies int `json:"volumeAllCurrencies"`
158+
Algorithm string `json:"algorithm" csv:"algorithm"`
159+
StartDate int `json:"startDate" csv:"startDate"`
160+
MaxSupply int `json:"maxSupply" csv:"maxSupply"`
161+
CirculatingSupply int `json:"circulatingSupply" csv:"circulatingSupply"`
162+
VolumeLastDay int `json:"volume24Hr" csv:"volume24Hr"`
163+
VolumeAllCurrencies int `json:"volumeAllCurrencies" csv:"volumeAllCurrencies"`
164164
}
165165

166166
// Quote is the basic quote structure shared across
@@ -170,72 +170,72 @@ type CryptoPair struct {
170170
// possible assets.
171171
type Quote struct {
172172
// Quote classifying fields.
173-
Symbol string `json:"symbol"`
174-
MarketState MarketState `json:"marketState"`
175-
QuoteType QuoteType `json:"quoteType"`
176-
ShortName string `json:"shortName"`
173+
Symbol string `json:"symbol" csv:"symbol"`
174+
MarketState MarketState `json:"marketState" csv:"marketState"`
175+
QuoteType QuoteType `json:"quoteType" csv:"quoteType"`
176+
ShortName string `json:"shortName" csv:"shortName"`
177177

178178
// Regular session quote data.
179-
RegularMarketChangePercent float64 `json:"regularMarketChangePercent"`
180-
RegularMarketPreviousClose float64 `json:"regularMarketPreviousClose"`
181-
RegularMarketPrice float64 `json:"regularMarketPrice"`
182-
RegularMarketTime int `json:"regularMarketTime"`
183-
RegularMarketChange float64 `json:"regularMarketChange"`
184-
RegularMarketOpen float64 `json:"regularMarketOpen"`
185-
RegularMarketDayHigh float64 `json:"regularMarketDayHigh"`
186-
RegularMarketDayLow float64 `json:"regularMarketDayLow"`
187-
RegularMarketVolume int `json:"regularMarketVolume"`
179+
RegularMarketChangePercent float64 `json:"regularMarketChangePercent" csv:"regularMarketChangePercent"`
180+
RegularMarketPreviousClose float64 `json:"regularMarketPreviousClose" csv:"regularMarketPreviousClose"`
181+
RegularMarketPrice float64 `json:"regularMarketPrice" csv:"regularMarketPrice"`
182+
RegularMarketTime int `json:"regularMarketTime" csv:"regularMarketTime"`
183+
RegularMarketChange float64 `json:"regularMarketChange" csv:"regularMarketChange"`
184+
RegularMarketOpen float64 `json:"regularMarketOpen" csv:"regularMarketOpen"`
185+
RegularMarketDayHigh float64 `json:"regularMarketDayHigh" csv:"regularMarketDayHigh"`
186+
RegularMarketDayLow float64 `json:"regularMarketDayLow" csv:"regularMarketDayLow"`
187+
RegularMarketVolume int `json:"regularMarketVolume" csv:"regularMarketVolume"`
188188

189189
// Quote depth.
190-
Bid float64 `json:"bid"`
191-
Ask float64 `json:"ask"`
192-
BidSize int `json:"bidSize"`
193-
AskSize int `json:"askSize"`
190+
Bid float64 `json:"bid" csv:"bid"`
191+
Ask float64 `json:"ask" csv:"ask"`
192+
BidSize int `json:"bidSize" csv:"bidSize"`
193+
AskSize int `json:"askSize" csv:"askSize"`
194194

195195
// Pre-market quote data.
196-
PreMarketPrice float64 `json:"preMarketPrice"`
197-
PreMarketChange float64 `json:"preMarketChange"`
198-
PreMarketChangePercent float64 `json:"preMarketChangePercent"`
199-
PreMarketTime int `json:"preMarketTime"`
196+
PreMarketPrice float64 `json:"preMarketPrice" csv:"preMarketPrice"`
197+
PreMarketChange float64 `json:"preMarketChange" csv:"preMarketChange"`
198+
PreMarketChangePercent float64 `json:"preMarketChangePercent" csv:"preMarketChangePercent"`
199+
PreMarketTime int `json:"preMarketTime" csv:"preMarketTime"`
200200

201201
// Post-market quote data.
202-
PostMarketPrice float64 `json:"postMarketPrice"`
203-
PostMarketChange float64 `json:"postMarketChange"`
204-
PostMarketChangePercent float64 `json:"postMarketChangePercent"`
205-
PostMarketTime int `json:"postMarketTime"`
202+
PostMarketPrice float64 `json:"postMarketPrice" csv:"postMarketPrice"`
203+
PostMarketChange float64 `json:"postMarketChange" csv:"postMarketChange"`
204+
PostMarketChangePercent float64 `json:"postMarketChangePercent" csv:"postMarketChangePercent"`
205+
PostMarketTime int `json:"postMarketTime" csv:"postMarketTime"`
206206

207207
// 52wk ranges.
208-
FiftyTwoWeekLowChange float64 `json:"fiftyTwoWeekLowChange"`
209-
FiftyTwoWeekLowChangePercent float64 `json:"fiftyTwoWeekLowChangePercent"`
210-
FiftyTwoWeekHighChange float64 `json:"fiftyTwoWeekHighChange"`
211-
FiftyTwoWeekHighChangePercent float64 `json:"fiftyTwoWeekHighChangePercent"`
212-
FiftyTwoWeekLow float64 `json:"fiftyTwoWeekLow"`
213-
FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh"`
208+
FiftyTwoWeekLowChange float64 `json:"fiftyTwoWeekLowChange" csv:"fiftyTwoWeekLowChange"`
209+
FiftyTwoWeekLowChangePercent float64 `json:"fiftyTwoWeekLowChangePercent" csv:"fiftyTwoWeekLowChangePercent"`
210+
FiftyTwoWeekHighChange float64 `json:"fiftyTwoWeekHighChange" csv:"fiftyTwoWeekHighChange"`
211+
FiftyTwoWeekHighChangePercent float64 `json:"fiftyTwoWeekHighChangePercent" csv:"fiftyTwoWeekHighChangePercent"`
212+
FiftyTwoWeekLow float64 `json:"fiftyTwoWeekLow" csv:"fiftyTwoWeekLow"`
213+
FiftyTwoWeekHigh float64 `json:"fiftyTwoWeekHigh" csv:"fiftyTwoWeekHigh"`
214214

215215
// Averages.
216-
FiftyDayAverage float64 `json:"fiftyDayAverage"`
217-
FiftyDayAverageChange float64 `json:"fiftyDayAverageChange"`
218-
FiftyDayAverageChangePercent float64 `json:"fiftyDayAverageChangePercent"`
219-
TwoHundredDayAverage float64 `json:"twoHundredDayAverage"`
220-
TwoHundredDayAverageChange float64 `json:"twoHundredDayAverageChange"`
221-
TwoHundredDayAverageChangePercent float64 `json:"twoHundredDayAverageChangePercent"`
216+
FiftyDayAverage float64 `json:"fiftyDayAverage" csv:"fiftyDayAverage"`
217+
FiftyDayAverageChange float64 `json:"fiftyDayAverageChange" csv:"fiftyDayAverageChange"`
218+
FiftyDayAverageChangePercent float64 `json:"fiftyDayAverageChangePercent" csv:"fiftyDayAverageChangePercent"`
219+
TwoHundredDayAverage float64 `json:"twoHundredDayAverage" csv:"twoHundredDayAverage"`
220+
TwoHundredDayAverageChange float64 `json:"twoHundredDayAverageChange" csv:"twoHundredDayAverageChange"`
221+
TwoHundredDayAverageChangePercent float64 `json:"twoHundredDayAverageChangePercent" csv:"twoHundredDayAverageChangePercent"`
222222

223223
// Volume metrics.
224-
AverageDailyVolume3Month int `json:"averageDailyVolume3Month"`
225-
AverageDailyVolume10Day int `json:"averageDailyVolume10Day"`
224+
AverageDailyVolume3Month int `json:"averageDailyVolume3Month" csv:"averageDailyVolume3Month"`
225+
AverageDailyVolume10Day int `json:"averageDailyVolume10Day" csv:"averageDailyVolume10Day"`
226226

227227
// Quote meta-data.
228-
QuoteSource string `json:"quoteSourceName"`
229-
CurrencyID string `json:"currency"`
230-
IsTradeable bool `json:"tradeable"`
231-
QuoteDelay int `json:"exchangeDataDelayedBy"`
232-
FullExchangeName string `json:"fullExchangeName"`
233-
SourceInterval int `json:"sourceInterval"`
234-
ExchangeTimezoneName string `json:"exchangeTimezoneName"`
235-
ExchangeTimezoneShortName string `json:"exchangeTimezoneShortName"`
236-
GMTOffSetMilliseconds int `json:"gmtOffSetMilliseconds"`
237-
MarketID string `json:"market"`
238-
ExchangeID string `json:"exchange"`
228+
QuoteSource string `json:"quoteSourceName" csv:"quoteSourceName"`
229+
CurrencyID string `json:"currency" csv:"currency"`
230+
IsTradeable bool `json:"tradeable" csv:"tradeable"`
231+
QuoteDelay int `json:"exchangeDataDelayedBy" csv:"exchangeDataDelayedBy"`
232+
FullExchangeName string `json:"fullExchangeName" csv:"fullExchangeName"`
233+
SourceInterval int `json:"sourceInterval" csv:"sourceInterval"`
234+
ExchangeTimezoneName string `json:"exchangeTimezoneName" csv:"exchangeTimezoneName"`
235+
ExchangeTimezoneShortName string `json:"exchangeTimezoneShortName" csv:"exchangeTimezoneShortName"`
236+
GMTOffSetMilliseconds int `json:"gmtOffSetMilliseconds" csv:"gmtOffSetMilliseconds"`
237+
MarketID string `json:"market" csv:"market"`
238+
ExchangeID string `json:"exchange" csv:"exchange"`
239239
}
240240

241241
// ChartBar is a single instance of a chart bar.
@@ -262,71 +262,71 @@ type OHLCHistoric struct {
262262

263263
// ChartMeta is meta data associated with a chart response.
264264
type ChartMeta struct {
265-
Currency string `json:"currency"`
266-
Symbol string `json:"symbol"`
267-
ExchangeName string `json:"exchangeName"`
268-
QuoteType QuoteType `json:"instrumentType"`
269-
FirstTradeDate int `json:"firstTradeDate"`
270-
Gmtoffset int `json:"gmtoffset"`
271-
Timezone string `json:"timezone"`
272-
ExchangeTimezoneName string `json:"exchangeTimezoneName"`
273-
ChartPreviousClose float64 `json:"chartPreviousClose"`
265+
Currency string `json:"currency" csv:"currency"`
266+
Symbol string `json:"symbol" csv:"symbol"`
267+
ExchangeName string `json:"exchangeName" csv:"exchangeName"`
268+
QuoteType QuoteType `json:"instrumentType" csv:"instrumentType"`
269+
FirstTradeDate int `json:"firstTradeDate" csv:"firstTradeDate"`
270+
Gmtoffset int `json:"gmtoffset" csv:"gmtoffset"`
271+
Timezone string `json:"timezone" csv:"timezone"`
272+
ExchangeTimezoneName string `json:"exchangeTimezoneName" csv:"exchangeTimezoneName"`
273+
ChartPreviousClose float64 `json:"chartPreviousClose" csv:"chartPreviousClose"`
274274
CurrentTradingPeriod struct {
275275
Pre struct {
276-
Timezone string `json:"timezone"`
277-
Start int `json:"start"`
278-
End int `json:"end"`
279-
Gmtoffset int `json:"gmtoffset"`
280-
} `json:"pre"`
276+
Timezone string `json:"timezone" csv:"timezone"`
277+
Start int `json:"start" csv:"start"`
278+
End int `json:"end" csv:"end"`
279+
Gmtoffset int `json:"gmtoffset" csv:"gmtoffset"`
280+
} `json:"pre" csv:"pre_,inline"`
281281
Regular struct {
282-
Timezone string `json:"timezone"`
283-
Start int `json:"start"`
284-
End int `json:"end"`
285-
Gmtoffset int `json:"gmtoffset"`
286-
} `json:"regular"`
282+
Timezone string `json:"timezone" csv:"timezone"`
283+
Start int `json:"start" csv:"start"`
284+
End int `json:"end" csv:"end"`
285+
Gmtoffset int `json:"gmtoffset" csv:"gmtoffset"`
286+
} `json:"regular" csv:"regular_,inline"`
287287
Post struct {
288-
Timezone string `json:"timezone"`
289-
Start int `json:"start"`
290-
End int `json:"end"`
291-
Gmtoffset int `json:"gmtoffset"`
292-
} `json:"post"`
293-
} `json:"currentTradingPeriod"`
294-
DataGranularity string `json:"dataGranularity"`
295-
ValidRanges []string `json:"validRanges"`
288+
Timezone string `json:"timezone" csv:"timezone"`
289+
Start int `json:"start" csv:"start"`
290+
End int `json:"end" csv:"end"`
291+
Gmtoffset int `json:"gmtoffset" csv:"gmtoffset"`
292+
} `json:"post" csv:"post_,inline"`
293+
} `json:"currentTradingPeriod" csv:"currentTradingPeriod_,inline"`
294+
DataGranularity string `json:"dataGranularity" csv:"dataGranularity"`
295+
ValidRanges []string `json:"validRanges" csv:"-"`
296296
}
297297

298298
// OptionsMeta is meta data associated with an options response.
299299
type OptionsMeta struct {
300-
UnderlyingSymbol string
301-
ExpirationDate int
302-
AllExpirationDates []int
303-
Strikes []float64
304-
HasMiniOptions bool
305-
Quote *Quote
300+
UnderlyingSymbol string `json:"underlyingSymbol" csv:"underlyingSymbol"`
301+
ExpirationDate int `json:"expirationDate" csv:"expirationDate"`
302+
AllExpirationDates []int `json:"allExpirationDates" csv:"-"`
303+
Strikes []float64 `json:"strikes" csv:"-"`
304+
HasMiniOptions bool `json:"hasMiniOptions"`
305+
Quote *Quote `json:"quote,omitempty" csv:"quote_,inline"`
306306
}
307307

308308
// Straddle is a put/call straddle for a particular strike.
309309
type Straddle struct {
310-
Strike float64 `json:"strike"`
311-
Call *Contract `json:"call,omitempty"`
312-
Put *Contract `json:"put,omitempty"`
310+
Strike float64 `json:"strike" csv:"strike"`
311+
Call *Contract `json:"call,omitempty" csv:"call_,inline"`
312+
Put *Contract `json:"put,omitempty" csv:"put_,inline"`
313313
}
314314

315315
// Contract is a struct containing a single option contract, usually part of a chain.
316316
type Contract struct {
317-
Symbol string `json:"contractSymbol"`
318-
Strike float64 `json:"strike"`
319-
Currency string `json:"currency"`
320-
LastPrice float64 `json:"lastPrice"`
321-
Change float64 `json:"change"`
322-
PercentChange float64 `json:"percentChange"`
323-
Volume int `json:"volume"`
324-
OpenInterest int `json:"openInterest"`
325-
Bid float64 `json:"bid"`
326-
Ask float64 `json:"ask"`
327-
Size string `json:"contractSize"`
328-
Expiration int `json:"expiration"`
329-
LastTradeDate int `json:"lastTradeDate"`
330-
ImpliedVolatility float64 `json:"impliedVolatility"`
331-
InTheMoney bool `json:"inTheMoney"`
317+
Symbol string `json:"contractSymbol" csv:"contractSymbol"`
318+
Strike float64 `json:"strike" csv:"strike"`
319+
Currency string `json:"currency" csv:"currency"`
320+
LastPrice float64 `json:"lastPrice" csv:"lastPrice"`
321+
Change float64 `json:"change" csv:"change"`
322+
PercentChange float64 `json:"percentChange" csv:"percentChange"`
323+
Volume int `json:"volume" csv:"volume"`
324+
OpenInterest int `json:"openInterest" csv:"openInterest"`
325+
Bid float64 `json:"bid" csv:"bid"`
326+
Ask float64 `json:"ask" csv:"ask"`
327+
Size string `json:"contractSize" csv:"contractSize"`
328+
Expiration int `json:"expiration" csv:"expiration"`
329+
LastTradeDate int `json:"lastTradeDate" csv:"lastTradeDate"`
330+
ImpliedVolatility float64 `json:"impliedVolatility" csv:"impliedVolatility"`
331+
InTheMoney bool `json:"inTheMoney" csv:"inTheMoney"`
332332
}

0 commit comments

Comments
 (0)