pt 1.0.3

A client for polygon.io, a financial data platform for stocks, forex and crypto.
Documentation
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
/* 
 * Polygon API
 *
 * The future of fintech.
 *
 * OpenAPI spec version: 1.0.1
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 */
#![allow(unused_imports)]

use serde_json::Value;
use bigdecimal::BigDecimal;
use chrono::{NaiveDateTime, DateTime, FixedOffset, Utc};

use crate::models::*;
//use crate::date_serializer;
//use crate::datetime_serializer;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Financial {
  #[serde(rename = "symbol")]
  symbol: String,  // AAPL 
  #[serde(rename = "reportDate")]
  report_date: String,  // 2017-12-31T00:00:00.000Z 
  #[serde(rename = "reportDateStr")]
  report_date_str: String,  // 2017-12-31 
  #[serde(rename = "grossProfit")]
  gross_profit: Option<i64>,  // 33912000000 
  #[serde(rename = "costOfRevenue")]
  cost_of_revenue: Option<i64>,  // 54381000000 
  #[serde(rename = "operatingRevenue")]
  operating_revenue: Option<i64>,  // 88293000000 
  #[serde(rename = "totalRevenue")]
  total_revenue: Option<i64>,  // 88293000000 
  #[serde(rename = "operatingIncome")]
  operating_income: Option<i64>,  // 26274000000 
  #[serde(rename = "netIncome")]
  net_income: Option<i64>,  // 20065000000 
  #[serde(rename = "researchAndDevelopment")]
  research_and_development: Option<i64>,  // 3407000000 
  #[serde(rename = "operatingExpense")]
  operating_expense: Option<i64>,  // 7638000000 
  #[serde(rename = "currentAssets")]
  current_assets: Option<i64>,  // 143810000000 
  #[serde(rename = "totalAssets")]
  total_assets: Option<i64>,  // 406794000000 
  #[serde(rename = "totalLiabilities")]
  total_liabilities: Option<i64>,  // 266595000000 
  #[serde(rename = "currentCash")]
  current_cash: Option<i64>,  // 27491000000 
  #[serde(rename = "currentDebt")]
  current_debt: Option<i64>,  // 18478000000 
  #[serde(rename = "totalCash")]
  total_cash: Option<i64>,  // 77153000000 
  #[serde(rename = "totalDebt")]
  total_debt: Option<i64>,  // 122400000000 
  #[serde(rename = "shareholderEquity")]
  shareholder_equity: Option<i64>,  // 140199000000 
  #[serde(rename = "cashChange")]
  cash_change: Option<i64>,  // 7202000000 
  #[serde(rename = "cashFlow")]
  cash_flow: Option<i64>,  // 28293000000 
  #[serde(rename = "operatingGainsLosses")]
  operating_gains_losses: Option<f32> 
}

impl Financial {
  pub fn new(symbol: String, report_date: String, report_date_str: String, ) -> Financial {
    Financial {
      symbol: symbol,
      report_date: report_date,
      report_date_str: report_date_str,
      gross_profit: None,
      cost_of_revenue: None,
      operating_revenue: None,
      total_revenue: None,
      operating_income: None,
      net_income: None,
      research_and_development: None,
      operating_expense: None,
      current_assets: None,
      total_assets: None,
      total_liabilities: None,
      current_cash: None,
      current_debt: None,
      total_cash: None,
      total_debt: None,
      shareholder_equity: None,
      cash_change: None,
      cash_flow: None,
      operating_gains_losses: None
    }
  }

  pub fn set_symbol(&mut self, symbol: String) {
    self.symbol = symbol;
  }

  pub fn with_symbol(mut self, symbol: String) -> Financial {
    self.symbol = symbol;
    self
  }

  pub fn symbol(&self) -> &String {
    &self.symbol
  }


  pub fn set_report_date(&mut self, report_date: String) {
    self.report_date = report_date;
  }

  pub fn with_report_date(mut self, report_date: String) -> Financial {
    self.report_date = report_date;
    self
  }

  pub fn report_date(&self) -> &String {
    &self.report_date
  }


  pub fn set_report_date_str(&mut self, report_date_str: String) {
    self.report_date_str = report_date_str;
  }

  pub fn with_report_date_str(mut self, report_date_str: String) -> Financial {
    self.report_date_str = report_date_str;
    self
  }

  pub fn report_date_str(&self) -> &String {
    &self.report_date_str
  }


  pub fn set_gross_profit(&mut self, gross_profit: i64) {
    self.gross_profit = Some(gross_profit);
  }

  pub fn with_gross_profit(mut self, gross_profit: i64) -> Financial {
    self.gross_profit = Some(gross_profit);
    self
  }

  pub fn gross_profit(&self) -> Option<&i64> {
    self.gross_profit.as_ref()
  }

  pub fn reset_gross_profit(&mut self) {
    self.gross_profit = None;
  }

  pub fn set_cost_of_revenue(&mut self, cost_of_revenue: i64) {
    self.cost_of_revenue = Some(cost_of_revenue);
  }

  pub fn with_cost_of_revenue(mut self, cost_of_revenue: i64) -> Financial {
    self.cost_of_revenue = Some(cost_of_revenue);
    self
  }

  pub fn cost_of_revenue(&self) -> Option<&i64> {
    self.cost_of_revenue.as_ref()
  }

  pub fn reset_cost_of_revenue(&mut self) {
    self.cost_of_revenue = None;
  }

  pub fn set_operating_revenue(&mut self, operating_revenue: i64) {
    self.operating_revenue = Some(operating_revenue);
  }

  pub fn with_operating_revenue(mut self, operating_revenue: i64) -> Financial {
    self.operating_revenue = Some(operating_revenue);
    self
  }

  pub fn operating_revenue(&self) -> Option<&i64> {
    self.operating_revenue.as_ref()
  }

  pub fn reset_operating_revenue(&mut self) {
    self.operating_revenue = None;
  }

  pub fn set_total_revenue(&mut self, total_revenue: i64) {
    self.total_revenue = Some(total_revenue);
  }

  pub fn with_total_revenue(mut self, total_revenue: i64) -> Financial {
    self.total_revenue = Some(total_revenue);
    self
  }

  pub fn total_revenue(&self) -> Option<&i64> {
    self.total_revenue.as_ref()
  }

  pub fn reset_total_revenue(&mut self) {
    self.total_revenue = None;
  }

  pub fn set_operating_income(&mut self, operating_income: i64) {
    self.operating_income = Some(operating_income);
  }

  pub fn with_operating_income(mut self, operating_income: i64) -> Financial {
    self.operating_income = Some(operating_income);
    self
  }

  pub fn operating_income(&self) -> Option<&i64> {
    self.operating_income.as_ref()
  }

  pub fn reset_operating_income(&mut self) {
    self.operating_income = None;
  }

  pub fn set_net_income(&mut self, net_income: i64) {
    self.net_income = Some(net_income);
  }

  pub fn with_net_income(mut self, net_income: i64) -> Financial {
    self.net_income = Some(net_income);
    self
  }

  pub fn net_income(&self) -> Option<&i64> {
    self.net_income.as_ref()
  }

  pub fn reset_net_income(&mut self) {
    self.net_income = None;
  }

  pub fn set_research_and_development(&mut self, research_and_development: i64) {
    self.research_and_development = Some(research_and_development);
  }

  pub fn with_research_and_development(mut self, research_and_development: i64) -> Financial {
    self.research_and_development = Some(research_and_development);
    self
  }

  pub fn research_and_development(&self) -> Option<&i64> {
    self.research_and_development.as_ref()
  }

  pub fn reset_research_and_development(&mut self) {
    self.research_and_development = None;
  }

  pub fn set_operating_expense(&mut self, operating_expense: i64) {
    self.operating_expense = Some(operating_expense);
  }

  pub fn with_operating_expense(mut self, operating_expense: i64) -> Financial {
    self.operating_expense = Some(operating_expense);
    self
  }

  pub fn operating_expense(&self) -> Option<&i64> {
    self.operating_expense.as_ref()
  }

  pub fn reset_operating_expense(&mut self) {
    self.operating_expense = None;
  }

  pub fn set_current_assets(&mut self, current_assets: i64) {
    self.current_assets = Some(current_assets);
  }

  pub fn with_current_assets(mut self, current_assets: i64) -> Financial {
    self.current_assets = Some(current_assets);
    self
  }

  pub fn current_assets(&self) -> Option<&i64> {
    self.current_assets.as_ref()
  }

  pub fn reset_current_assets(&mut self) {
    self.current_assets = None;
  }

  pub fn set_total_assets(&mut self, total_assets: i64) {
    self.total_assets = Some(total_assets);
  }

  pub fn with_total_assets(mut self, total_assets: i64) -> Financial {
    self.total_assets = Some(total_assets);
    self
  }

  pub fn total_assets(&self) -> Option<&i64> {
    self.total_assets.as_ref()
  }

  pub fn reset_total_assets(&mut self) {
    self.total_assets = None;
  }

  pub fn set_total_liabilities(&mut self, total_liabilities: i64) {
    self.total_liabilities = Some(total_liabilities);
  }

  pub fn with_total_liabilities(mut self, total_liabilities: i64) -> Financial {
    self.total_liabilities = Some(total_liabilities);
    self
  }

  pub fn total_liabilities(&self) -> Option<&i64> {
    self.total_liabilities.as_ref()
  }

  pub fn reset_total_liabilities(&mut self) {
    self.total_liabilities = None;
  }

  pub fn set_current_cash(&mut self, current_cash: i64) {
    self.current_cash = Some(current_cash);
  }

  pub fn with_current_cash(mut self, current_cash: i64) -> Financial {
    self.current_cash = Some(current_cash);
    self
  }

  pub fn current_cash(&self) -> Option<&i64> {
    self.current_cash.as_ref()
  }

  pub fn reset_current_cash(&mut self) {
    self.current_cash = None;
  }

  pub fn set_current_debt(&mut self, current_debt: i64) {
    self.current_debt = Some(current_debt);
  }

  pub fn with_current_debt(mut self, current_debt: i64) -> Financial {
    self.current_debt = Some(current_debt);
    self
  }

  pub fn current_debt(&self) -> Option<&i64> {
    self.current_debt.as_ref()
  }

  pub fn reset_current_debt(&mut self) {
    self.current_debt = None;
  }

  pub fn set_total_cash(&mut self, total_cash: i64) {
    self.total_cash = Some(total_cash);
  }

  pub fn with_total_cash(mut self, total_cash: i64) -> Financial {
    self.total_cash = Some(total_cash);
    self
  }

  pub fn total_cash(&self) -> Option<&i64> {
    self.total_cash.as_ref()
  }

  pub fn reset_total_cash(&mut self) {
    self.total_cash = None;
  }

  pub fn set_total_debt(&mut self, total_debt: i64) {
    self.total_debt = Some(total_debt);
  }

  pub fn with_total_debt(mut self, total_debt: i64) -> Financial {
    self.total_debt = Some(total_debt);
    self
  }

  pub fn total_debt(&self) -> Option<&i64> {
    self.total_debt.as_ref()
  }

  pub fn reset_total_debt(&mut self) {
    self.total_debt = None;
  }

  pub fn set_shareholder_equity(&mut self, shareholder_equity: i64) {
    self.shareholder_equity = Some(shareholder_equity);
  }

  pub fn with_shareholder_equity(mut self, shareholder_equity: i64) -> Financial {
    self.shareholder_equity = Some(shareholder_equity);
    self
  }

  pub fn shareholder_equity(&self) -> Option<&i64> {
    self.shareholder_equity.as_ref()
  }

  pub fn reset_shareholder_equity(&mut self) {
    self.shareholder_equity = None;
  }

  pub fn set_cash_change(&mut self, cash_change: i64) {
    self.cash_change = Some(cash_change);
  }

  pub fn with_cash_change(mut self, cash_change: i64) -> Financial {
    self.cash_change = Some(cash_change);
    self
  }

  pub fn cash_change(&self) -> Option<&i64> {
    self.cash_change.as_ref()
  }

  pub fn reset_cash_change(&mut self) {
    self.cash_change = None;
  }

  pub fn set_cash_flow(&mut self, cash_flow: i64) {
    self.cash_flow = Some(cash_flow);
  }

  pub fn with_cash_flow(mut self, cash_flow: i64) -> Financial {
    self.cash_flow = Some(cash_flow);
    self
  }

  pub fn cash_flow(&self) -> Option<&i64> {
    self.cash_flow.as_ref()
  }

  pub fn reset_cash_flow(&mut self) {
    self.cash_flow = None;
  }

  pub fn set_operating_gains_losses(&mut self, operating_gains_losses: f32) {
    self.operating_gains_losses = Some(operating_gains_losses);
  }

  pub fn with_operating_gains_losses(mut self, operating_gains_losses: f32) -> Financial {
    self.operating_gains_losses = Some(operating_gains_losses);
    self
  }

  pub fn operating_gains_losses(&self) -> Option<&f32> {
    self.operating_gains_losses.as_ref()
  }

  pub fn reset_operating_gains_losses(&mut self) {
    self.operating_gains_losses = None;
  }

}