-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathAPI.cs
More file actions
1669 lines (1525 loc) · 82.7 KB
/
Copy pathAPI.cs
File metadata and controls
1669 lines (1525 loc) · 82.7 KB
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
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using EOD.APIs;
using EOD.APIs.Abstract;
using EOD.Model;
using EOD.Model.BondsFundamentalData;
using EOD.Model.BulkFundamental;
using EOD.Model.Bulks;
using EOD.Model.EarningTrends;
using EOD.Model.ExchangeDetails;
using EOD.Model.Fundamental;
using EOD.Model.IPOs;
using EOD.Model.OptionsData;
using EOD.Model.Screener;
using EOD.Model.TechnicalIndicators;
using EOD.Model.UpcomingEarnings;
using EOD.Model.UpcomingSplits;
using EODHistoricalData.Wrapper.Model.Bulks;
using EODHistoricalData.Wrapper.Model.TechnicalIndicators;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
namespace EOD
{
/// <summary>
/// Provides clients with access to the library functionality.
/// </summary>
public class API
{
private readonly IIntradayHistoricalDataAPI intradayHistoricalDataAPI;
private readonly IEndOfDayHistoricalDataAPI endOfDayHistoricalDataAPI;
private readonly IFundamentalDataAPI fundamentalDataAPI;
private readonly ISearchAPI searchAPI;
private readonly IUserAPI userAPI;
private readonly ILiveStockPricesAPI liveStockPricesAPI;
private readonly IExchangesAPI exchangesAPI;
private readonly IHistoricalDividendsAPI historicalDividendsAPI;
private readonly IMacroIndicatorsAPI macroIndicatorsAPI;
private readonly IExchangeSymbolsAPI exchangeSymbolsAPI;
private readonly IOptionalDataAPI optionalDataAPI;
private readonly IEconomicEventDataAPI economicEventDataAPI;
private readonly IInsiderTransactionsAPI insiderTransactionsAPI;
private readonly ICalendarAPI calendarAPI;
private readonly IBondsFundamentalsAndHistoricalAPI bondsFundamentalsAndHistoricalAPI;
private readonly IBulkAPI bulkAPI;
private readonly IExchangeDetailsAPI exchangeDetailsAPI;
private readonly IFinancialNewsAPI financialNewsAPI;
private readonly IStockMarketScreenerAPI stockMarketScreenerAPI;
private readonly ITechnicalIndicatorAPI technicalIndicatorAPI;
private readonly ISentimentsAPI sentimentsAPI;
#region Enums
/// <summary>
/// The period of end of day historical data
/// </summary>
public enum HistoricalPeriod
{
/// <summary>
/// 1 day
/// </summary>
Daily,
/// <summary>
/// 1 week
/// </summary>
Weekly,
/// <summary>
/// 1 month
/// </summary>
Monthly
}
/// <summary>
/// The interval of intraday historical data
/// </summary>
public enum IntradayHistoricalInterval
{
/// <summary>
/// 1 minute
/// </summary>
OneMinute,
/// <summary>
/// 5 minutes
/// </summary>
FiveMinutes,
/// <summary>
/// 1 hour
/// </summary>
OneHour
}
/// <summary>
/// Comparison by some periods
/// </summary>
public enum Comparison
{
/// <summary>
/// Month-over-Month
/// </summary>
MoM,
/// <summary>
/// Quarter-on-Quarter
/// </summary>
QoQ,
/// <summary>
/// Year-over-Year
/// </summary>
YoY
}
/// <summary>
/// Sort response data
/// </summary>
public enum Order
{
/// <summary>
/// Ascending order
/// </summary>
Ascending,
/// <summary>
/// Descending order
/// </summary>
Descending
}
/// <summary>
/// Screener API supported fields
/// </summary>
public enum Field
{
/// <summary>
/// ticker code - string
/// </summary>
Code,
/// <summary>
/// ticker name - string
/// </summary>
Name,
/// <summary>
/// exchange code - string
/// </summary>
Exchange,
/// <summary>
/// sector - string
/// </summary>
Sector,
/// <summary>
/// industry - string
/// </summary>
Industry,
/// <summary>
/// Number - Market Capitalization, the latest value. Please note, that input for market_capitalization in USD
/// </summary>
MarketCapitalization,
/// <summary>
/// Number - Earnings-per-share (EPS), the latest value.
/// </summary>
EarningsShare,
/// <summary>
/// Number - Dividend yield, the latest value.
/// </summary>
DividendYield,
/// <summary>
/// Number - The last day gain/loss in percent. Useful to get top gainers, losers for the past day.
/// </summary>
Refund1dP,
/// <summary>
/// Number - The last 5 days gain/loss in percent. Useful to get top gainers, losers for the past week.
/// </summary>
Refund5dP,
/// <summary>
/// Number - The last day volume.
/// </summary>
Avgvol1d,
/// <summary>
/// Number - The average last 200 days volume.
/// </summary>
Avgvol200d
}
/// <summary>
/// Screnner API supported operations
/// </summary>
public enum Operation
{
/// <summary>
/// to compare strings
/// </summary>
Matches,
/// <summary>
/// to compare strings and numbers
/// </summary>
Equals,
/// <summary>
/// to compare numbers
/// </summary>
More,
/// <summary>
/// to compare numbers
/// </summary>
Less,
/// <summary>
/// to compare numbers
/// </summary>
NotLess,
/// <summary>
/// to compare numbers
/// </summary>
NotMore,
/// <summary>
/// to compare numbers
/// </summary>
NotEquals
}
/// <summary>
/// Screener API supported signals. Filter out tickers by signals, the calculated fields.
/// </summary>
public enum Signal
{
/// <summary>
/// Filters tickers that have new 50 days lows
/// </summary>
New_50d_low,
/// <summary>
/// Filters tickers that have new 50 days highs
/// </summary>
New_50d_hi,
/// <summary>
/// Filters tickers that have new 200 days lows
/// </summary>
New_200d_low,
/// <summary>
/// Filters tickers that have new 200 days highs
/// </summary>
New_200d_hi,
/// <summary>
/// Filters tickers with Negative Book Value
/// </summary>
Bookvalue_neg,
/// <summary>
/// Filters tickers with Positive Book Value
/// </summary>
Bookvalue_pos,
/// <summary>
/// Filters tickers that have a price lower than expected by Wall Street analysts
/// </summary>
Wallstreet_low,
/// <summary>
/// Filters tickers that have a price higher than expected by Wall Street analysts
/// </summary>
Wallstreet_hi
}
#endregion
/// <summary>
/// Constructor fasade class API.eod
/// </summary>
/// <param name="apiKey">your api key</param>
/// <param name="proxy">proxy settings</param>
/// <param name="source">app name</param>
public API(string apiKey, IWebProxy proxy = null, string source = null)
{
intradayHistoricalDataAPI = new IntradayHistoricalDataAPI(apiKey, proxy, source);
endOfDayHistoricalDataAPI = new EndOfDayHistoriacalDataAPI(apiKey, proxy, source);
fundamentalDataAPI = new FundamentalDataAPI(apiKey, proxy, source);
searchAPI = new SearchAPI(apiKey, proxy, source);
userAPI = new UserAPI(apiKey, proxy, source);
liveStockPricesAPI = new LiveStockPricesAPI(apiKey, proxy, source);
exchangesAPI = new ExchangesAPI(apiKey, proxy, source);
historicalDividendsAPI = new HistoricalDividendsAPI(apiKey, proxy, source);
macroIndicatorsAPI = new MacroIndicatorsAPI(apiKey, proxy, source);
exchangeSymbolsAPI = new ExchangeSymbolsAPI(apiKey, proxy, source);
optionalDataAPI = new OptionsDataAPI(apiKey, proxy, source);
economicEventDataAPI = new EconomicEventDataAPI(apiKey, proxy, source);
insiderTransactionsAPI = new InsiderTransactionsAPI(apiKey, proxy, source);
calendarAPI = new CalendarAPI(apiKey, proxy, source);
bondsFundamentalsAndHistoricalAPI = new BondsFundamentalsAndHistoricalAPI(apiKey, proxy, source);
bulkAPI = new BulkAPI(apiKey, proxy, source);
exchangeDetailsAPI = new ExchangeDetailsAPI(apiKey, proxy, source);
financialNewsAPI = new FinancialNewsAPI(apiKey, proxy, source);
stockMarketScreenerAPI = new StockMarketScreenerAPI(apiKey, proxy, source);
technicalIndicatorAPI = new TechnicalIndicatorAPI(apiKey, proxy, source);
sentimentsAPI = new SentimentsApi(apiKey, proxy, source);
}
/// <summary>
/// Get Financial News Sentiment Data or Tweets Sentiment Data
/// </summary>
/// <param name="symbols">[REQUIRED] list os symbols</param>
/// <param name="from">[OPTIONAL] date from</param>
/// <param name="to">[OPTIONAL] date to</param>
/// <param name="tweets">[OPTIONAL] true for Tweets Sentiment Data</param>
/// <returns></returns>
public async Task<Dictionary<string, List<SentimentsData>>> GetSentimentsAsync(List<string> symbols, DateTime? from = null, DateTime? to = null, bool? tweets = null)
{
return await sentimentsAPI.GetSentimentsAsync(symbols, from, to, tweets);
}
/// <summary>
/// Get intraday historical stock price data
/// </summary>
/// <param name="ticker">ticker consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use, for example, AAPL.MX for Mexican Stock Exchange. or AAPL.US for NASDAQ.</param>
/// <param name="from"></param>
/// <param name="to"></param>
/// <param name="interval">the possible intervals: ‘5m’ for 5-minutes, ‘1h’ for 1 hour, and ‘1m’ for 1-minute intervals</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<List<IntradayHistoricalStockPrice>> GetIntradayHistoricalStockPriceAsync(string ticker, DateTime from, DateTime to, IntradayHistoricalInterval interval)
{
CheckTicker(ticker);
string intervalToString;
switch (interval)
{
case IntradayHistoricalInterval.OneMinute:
intervalToString = "1m";
break;
case IntradayHistoricalInterval.FiveMinutes:
intervalToString = "5m";
break;
case IntradayHistoricalInterval.OneHour:
intervalToString = "1h";
break;
default:
intervalToString = "1m";
break;
}
return await intradayHistoricalDataAPI.GetDataAsync(ticker, from, to, intervalToString);
}
/// <summary>
/// Get end-of-day historical stock price data
/// </summary>
/// <param name="ticker">ticker consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use, for example, AAPL.MX for Mexican Stock Exchange. or AAPL.US for NASDAQ.</param>
/// <param name="from">start search period</param>
/// <param name="to">end search period</param>
/// <param name="period">search data interval</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<List<HistoricalStockPrice>> GetEndOfDayHistoricalStockPriceAsync(string ticker, DateTime from, DateTime to, HistoricalPeriod period)
{
CheckTicker(ticker);
string periodToString;
switch (period)
{
case HistoricalPeriod.Daily:
periodToString = "d";
break;
case HistoricalPeriod.Weekly:
periodToString = "w";
break;
case HistoricalPeriod.Monthly:
periodToString = "m";
break;
default:
periodToString = "d";
break;
}
return await endOfDayHistoricalDataAPI.GetDataAsync(ticker, from, to, periodToString);
}
/// <summary>
/// Get fundamental data feed
/// </summary>
/// <param name="ticker">consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use, for example, AAPL.MX for Mexican Stock Exchange. Or AAPL.US for NASDAQ.</param>
/// <param name="filters">supports several, comma-separated, filters (for example: filter=Financials::Balance_Sheet::yearly or filter=General::Code,General,Earnings)</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<FundamentalData> GetFundamentalDataAsync(string ticker, string filters = null)
{
CheckTicker(ticker);
return await fundamentalDataAPI.GetFundamentalsDataAsync(ticker, filters);
}
/// <summary>
/// Bulk Fundamentals Output
/// </summary>
/// <param name="ticker">{EXCHANGE_ID}, for example, MX for Mexican Stock Exchange.</param>
/// <param name="offset">The first symbol you will get</param>
/// <param name="limit">The number of symbols you will get</param>
/// <param name="symbols">To get the data for several symbols instead of the entire exchange.
/// in this case, the exchange code will be ignored</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<Dictionary<string, BulkFundamentalData>> GetBulkFundamentalsDataAsync(string ticker, int? offset = null, int? limit = null, string symbols = null)
{
if (ticker == string.Empty) throw new ArgumentNullException(nameof(ticker));
return await fundamentalDataAPI.GetBulkFundamentalsDataAsync(ticker, offset, limit, symbols);
}
/// <summary>
/// Bulk Fundamentals Extended data
/// </summary>
/// <param name="ticker">{EXCHANGE_ID}, for example, MX for Mexican Stock Exchange.</param>
/// <param name="offset">The first symbol you will get</param>
/// <param name="limit">The number of symbols you will get</param>
/// <param name="symbols">To get the data for several symbols instead of the entire exchange.
/// in this case, the exchange code will be ignored</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<BulkFundamentalData>> GetBulkFundamentalsExtendedDataAsync(string ticker, int? offset = null, int? limit = null, string symbols = null)
{
if (ticker == string.Empty) throw new ArgumentNullException(nameof(ticker));
return await fundamentalDataAPI.GetBulkFundamentalsExtendedDataAsync(ticker, offset, limit, symbols);
}
/// <summary>
/// Get user data
/// </summary>
public async Task<User> GetUserDataAsync()
{
return await userAPI.GetUserAsync();
}
/// <summary>
/// Search API for Stocks, ETFs, Mutual Funds, and Indices
/// </summary>
/// <param name="searchString">String. REQUIRED. Could be any string with a ticker code or company name.
/// Examples: ‘AAPL’, ‘Apple Inc’, ‘Apple’. You can also use ISINs for the search: US0378331005.
/// There are no limitations to a minimum number of symbols in the query string</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<SearchExtendedResult>> GetSearchExtendedResultAsync(string searchString)
{
if (searchString == string.Empty) throw new ArgumentNullException(nameof(searchString));
return await searchAPI.GetQuerySearchExtendedAsync(searchString);
}
/// <summary>
/// Search API for Stocks, ETFs, Mutual Funds, and Indices
/// </summary>
/// <param name="searchString">String. REQUIRED. Could be any string with a ticker code or company name.
/// Examples: ‘AAPL’, ‘Apple Inc’, ‘Apple’. You can also use ISINs for the search: US0378331005.
/// There are no limitations to a minimum number of symbols in the query string</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<SearchResult>> GetSearchResultAsync(string searchString)
{
if (searchString == string.Empty) throw new ArgumentNullException(nameof(searchString));
return await searchAPI.GetQuerySearchAsync(searchString);
}
/// <summary>
/// Get live stock prices data
/// </summary>
/// <param name="ticker">consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use,
/// for example, AAPL.MX for Mexican Stock Exchange. Or AAPL.US for NASDAQ.</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<LiveStockPrice> GetLiveStockPricesAsync(string ticker)
{
CheckTicker(ticker);
return await liveStockPricesAPI.GetLiveStockPricesAsync(ticker);
}
/// <summary>
/// Get live stock prices data
/// </summary>
/// <param name="ticker">consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use,
/// for example, AAPL.MX for Mexican Stock Exchange. Or AAPL.US for NASDAQ.</param>
/// <param name="symbols">to get data for multiple tickers at one request</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<List<LiveStockPrice>> GetLiveStockPricesAsync(string ticker, List<string> symbols)
{
CheckTicker(ticker);
return await liveStockPricesAPI.GetManyLiveStockPricesAsync(ticker, symbols);
}
/// <summary>
/// Get the full list of supported exchanges with names, codes, operating MICs, country, and currency
/// </summary>
public async Task<List<Exchange>> GetExchangeAsync()
{
return await exchangesAPI.GetExchangeAsync();
}
/// <summary>
/// Get a list of symbols for exchange
/// </summary>
/// /// <param name="code">EXCHANGE_CODE</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<ExchangeSymbol>> GetExchangeSymbolsAsync(string code)
{
if (code == string.Empty) throw new ArgumentNullException(nameof(code));
return await exchangeSymbolsAPI.GetExchangeSymbolsAsync(code);
}
/// <summary>
/// Get historical dividends
/// </summary>
/// <param name="ticker">ticker consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}, then you can use,
/// for example, AAPL.MX for Mexican Stock Exchange. or AAPL.US for NASDAQ.</param>
/// <param name="from">start search period</param>
/// <param name="to">end search period</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<List<HistoricalDividend>> GetHistoricalDividendsAsync(string ticker, DateTime from, DateTime to)
{
CheckTicker(ticker);
return await historicalDividendsAPI.GetDataAsync(ticker, from, to);
}
/// <summary>
/// To get splits for any tickers
/// </summary>
/// <param name="ticker">consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID}</param>
/// <param name="from">date from with format “Y-m-d”</param>
/// <param name="to">date to with format “Y-m-d”</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<List<HistoricalSplit>> GetHistoricalSplitsAsync(string ticker, DateTime? from, DateTime? to)
{
CheckTicker(ticker);
return await historicalDividendsAPI.GetHistoricalSplitsAsync(ticker, from, to);
}
/// <summary>
/// Get macro indicator
/// </summary>
/// <param name="country">Defines the country for which the indicator will be shown. The country should be defined in the Alpha-3 ISO format.</param>
/// <param name="indicator">Defines which macroeconomics data indicator will be shown.</param>
/// <returns></returns>
public async Task<List<MacroIndicator>> GetMacroIndicatorsAsync(string country, string indicator)
{
return await macroIndicatorsAPI.GetDataAsync(country, indicator);
}
/// <summary>
/// Get stock optional data
/// </summary>
/// <param name="ticker">Consists of two parts: {SYMBOL_NAME}.{EXCHANGE_ID},
/// then you can use, for example, AAPL.MX for Mexican Stock Exchange.
/// Or AAPL.US for NASDAQ.</param>
/// <param name="from">filters OPTIONS by expirationDate. Default value: today.</param>
/// <param name="to">filters OPTIONS by expirationDate. Default value: '2100-01-01'.</param>
/// <param name="trade_date_from">filters OPTIONS by lastTradeDateTime. Default value: NONE.</param>
/// <param name="trade_date_to">filters OPTIONS by lastTradeDateTime. Default value: NONE.</param>
/// <param name="contract_name">returns only the data for particular contract.</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<OptionsData> GetOptionsDataAsync(string ticker, DateTime? from, DateTime? to, DateTime? trade_date_from, DateTime? trade_date_to, string contract_name)
{
CheckTicker(ticker);
return await optionalDataAPI.GetOptionsDataAsync(ticker, from, to, trade_date_from, trade_date_to, contract_name);
}
/// <summary>
/// Provides the past and future events from all around the world like Retail Sails, Bond Auctions, PMI Releases and many other Economic Events data
/// </summary>
/// <param name="from">Optional. The format is ‘YYYY-MM-DD’.</param>
/// <param name="to">Optional. The format is ‘YYYY-MM-DD’.</param>
/// <param name="country">OPTIONAL. The country code in ISO 3166 format, 2 symbols.</param>
/// <param name="comparison">OPTIONAL. Possible values: mom, qoq, yoy.</param>
/// <param name="offset">OPTIONAL. Possible values from 0 to 1000.</param>
/// <param name="limit">OPTIONAL. POssible values from 0 to 1000.</param>
/// <returns></returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public async Task<List<EconomicEventData>> GetEconomicEventsDataAsync(DateTime? from, DateTime? to, string country, Comparison? comparison, int? offset, int? limit)
{
if (offset < 0 && offset > 1000) throw new ArgumentOutOfRangeException(nameof(offset));
if (limit < 0 && limit > 1000) throw new ArgumentOutOfRangeException(nameof(offset));
string comparisonToString;
switch (comparison)
{
case Comparison.MoM:
comparisonToString = "mom";
break;
case Comparison.QoQ:
comparisonToString = "qoq";
break;
case Comparison.YoY:
comparisonToString = "yoy";
break;
default:
comparisonToString = null;
break;
}
return await economicEventDataAPI.GetEconomicEventsDataAsync(from, to, country, comparisonToString, offset, limit);
}
/// <summary>
/// To get insider transactions
/// </summary>
/// <param name="limit">OPTIONAL. The limit for entries per result, from 1 to 1000. Default value: 100.</param>
/// <param name="from">OPTIONAL. The format is ‘YYYY-MM-DD’.</param>
/// <param name="to">OPTIONAL. The format is ‘YYYY-MM-DD’.</param>
/// <param name="ticker">OPTIONAL. To get the data only for Apple Inc (AAPL), use AAPL.US or AAPL ticker code. By default, all possible symbols will be displayed.</param>
/// <returns></returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public async Task<List<InsiderTransaction>> GetInsiderTransactionsAsync(int? limit, DateTime? from, DateTime? to, string ticker)
{
if (limit < 1 && limit > 1000) throw new ArgumentOutOfRangeException(nameof(limit));
return await insiderTransactionsAPI.GetInsiderTransactionsAsync(limit, from, to, ticker);
}
/// <summary>
/// To get upcoming earnings
/// </summary>
/// <param name="from">OPTIONAL. Format: YYYY-MM-DD. The start date for earnings data, if not provided, today will be used.</param>
/// <param name="to">OPTIONAL. Format: YYYY-MM-DD. The end date for earnings data, if not provided, today + 7 days will be used.</param>
/// <param name="ticker">OPTIONAL. You can request specific symbols to get historical and upcoming data. If ‘symbols’ used, then ‘from’ and ‘to’ parameters will be ignored.
/// You can use one symbol: ‘AAPL.US’ or several symbols separated by a comma: ‘AAPL.US, MS’</param>
/// <returns></returns>
public async Task<UpcomingEarning> GetUpcomingEarningsAsync(DateTime? from, DateTime? to, string ticker)
{
return await calendarAPI.GetUpcomingEarningsAsync(from, to, ticker);
}
/// <summary>
/// To get earning trends
/// </summary>
/// <param name="ticker">REQUIRED. You can request specific symbols to get historical and upcoming data.
/// You can use one symbol: ‘AAPL.US’ or several symbols separated by a comma: ‘AAPL.US, MS’</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
public async Task<EarningTrend> GetEarningTrendsAsync(string ticker)
{
CheckTicker(ticker);
return await calendarAPI.GetEarningTrendsAsync(ticker);
}
/// <summary>
/// To get Upcoming IPOs
/// </summary>
/// <param name="from">OPTIONAL. Format: YYYY-MM-DD. The start date for ipos data, if not provided, today will be used.</param>
/// <param name="to">OPTIONAL. Format: YYYY-MM-DD. The end date for ipos data, if not provided, today + 7 days will be used.</param>
/// <returns></returns>
public async Task<UpcomingIPO> GetUpcomingIPOsAsync(DateTime? from = null, DateTime? to = null)
{
return await calendarAPI.GetUpcomingIPOsAsync(from, to);
}
/// <summary>
/// To get Upcoming Splits
/// </summary>
/// <param name="from">OPTIONAL. Format: YYYY-MM-DD. The start date for splits data, if not provided, today will be used.</param>
/// <param name="to">OPTIONAL. Format: YYYY-MM-DD. The end date for splits data, if not provided, today + 7 days will be used.</param>
/// <returns></returns>
public async Task<UpcomingSplit> GetUpcomingSplitsAsync(DateTime? from = null, DateTime? to = null)
{
return await calendarAPI.GetUpcomingSplitsAsync(from, to);
}
/// <summary>
/// To get bonds fundamental data feed
/// </summary>
/// <param name="code">CUSIP of a particular bond, it’s also could be an ISIN</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<BondsFundamentalData> GetBondsFundamentalDataAsync(string code)
{
if (code == string.Empty) throw new ArgumentNullException(nameof(code));
return await bondsFundamentalsAndHistoricalAPI.GetBondsFundamendalDataAsync(code);
}
/// <summary>
/// To get bond historical data
/// </summary>
/// <param name="code">You should use ISIN ID and “.BOND”</param>
/// <param name="from">the format is ‘YYYY-MM-DD’.</param>
/// <param name="to">the format is ‘YYYY-MM-DD’.</param>
/// <param name="order">Use ‘a’ for ascending dates (from old to new), ‘d’ for descending dates (from new to old)</param>
/// <param name="period">Period of prices.</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<BondHistoricalData>> GetBondHistoricalDataAsync(string code, DateTime? from = null, DateTime? to = null, Order? order = null, HistoricalPeriod? period = null)
{
if (code == string.Empty) throw new ArgumentNullException(nameof(code));
string orderToString= GetOrderSwitch(order);
string periodToString;
switch (period)
{
case HistoricalPeriod.Daily:
periodToString = "d";
break;
case HistoricalPeriod.Weekly:
periodToString = "w";
break;
case HistoricalPeriod.Monthly:
periodToString = "m";
break;
default:
periodToString = "d";
break;
}
return await bondsFundamentalsAndHistoricalAPI.GetBondHistoricalDataAsync(code, from, to, orderToString, periodToString);
}
/// <summary>
/// To get macroeconomic data
/// </summary>
/// <param name="ticker">"County code + period" or "Bank code" + ".ExchangeCode"</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<List<MacroeconomicsData>> GetMacroeconomicsDataAsync(string ticker)
{
if (ticker == string.Empty) throw new ArgumentNullException(nameof(ticker));
return await macroIndicatorsAPI.GetMacroeconomicsDataAsync(ticker);
}
/// <summary>
/// To get the data for the entire exchange for a particular day
/// </summary>
/// <param name="code">country code or ticker</param>
/// <param name="type">"Splits", "dividends" or empty for EOD</param>
/// <param name="date">if you need any specific date</param>
/// <param name="symbols">To download last day data for several symbols, for example, for MSFT and AAPL</param>
/// <returns></returns>
public async Task<List<Bulk>> GetBulksAsync(string code, BulkQueryTypes type, DateTime? date, string symbols)
{
return await bulkAPI.GetBulksAsync(code, type, date, symbols);
}
/// <summary>
/// If you need more data for the entire exchange for a particular day, like company name, EMA 50 and EMA 200 and average volumes for 14, 50 and 200 days.
/// </summary>
/// <param name="code">country code or ticker</param>
/// <param name="type">"Splits", "dividends" or empty for EOD</param>
/// <param name="date">if you need any specific date</param>
/// <param name="symbols">To download last day data for several symbols (example: MSFT,AAPL,BMW.XETRA,SAP.F)</param>
/// <returns></returns>
public async Task<List<ExtendedBulk>> GetExtendedBulksAsync(string code, BulkQueryTypes type, DateTime? date, string symbols)
{
return await bulkAPI.GetExtendedBulksAsync(code, type, date, symbols);
}
/// <summary>
/// Get details on each exchange
/// </summary>
/// <param name="code">EXCHANGE_CODE</param>
/// <param name="from">the format is ‘YYYY-MM-DD’. The default value is 6 months before the current date.</param>
/// <param name="to">the format is ‘YYYY-MM-DD’. The default value is 6 months after the current date.</param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
public async Task<ExchangeDetail> GetExchangeDetailsAsync(string code, DateTime? from = null, DateTime? to = null)
{
if (code == string.Empty) throw new ArgumentNullException(nameof(code));
return await exchangeDetailsAPI.GetExchangeDetailsAsync(code, from, to);
}
/// <summary>
/// a powerful tool that helps you get company news and filter out them by date,
/// type of news and certain tickers with the given parameters.
/// </summary>
/// <param name="s">REQUIRED if parameter ‘t’ not set. The ticker code to get news for.</param>
/// <param name="t">REQUIRED if parameter ‘s’ not set. The tag to get news on a given topic.</param>
/// <param name="from">the format is ‘YYYY-MM-DD’</param>
/// <param name="to">the format is ‘YYYY-MM-DD’</param>
/// <param name="limit">OPTIONAL. The number of results should be returned with the query.
/// Default value: 50, minimum value: 1, maximum value: 1000.</param>
/// <param name="offset">OPTIONAL. The offset of the data. Default value: 0, minimum value: 0, maximum value: 100.
/// For example, to get 100 symbols starting from 200 you should use limit=100 and offset=200.</param>
/// <returns></returns>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public async Task<List<FinancialNews>> GetFinancialNewsAsync(string s = null, string t = null,
DateTime? from = null, DateTime? to = null, int? limit = null, int? offset = null)
{
if (!(t != null ^ s != null)) throw new ArgumentException("One of the parameters (s or t) must be set");
if (offset != null && (offset < 0 || offset > 100)) throw new ArgumentOutOfRangeException(nameof(offset));
if (limit != null && (limit < 1 || limit > 1000)) throw new ArgumentOutOfRangeException(nameof(offset));
return await financialNewsAPI.GetFinancialNewsAsync(s, t, from, to, limit, offset);
}
/// <summary>
/// The Screener API is a powerful tool that helps you filter out tickers with the given parameters.
/// </summary>
/// <param name="filters">OPTIONAL. Filters out tickers by different fields.</param>
/// <param name="signals">OPTIONAL. Usage: signals=signal1,signal2,…,signalN. Filter out tickers by signals, the calculated fields.</param>
/// <param name="sort">OPTIONAL. Usage: sort=field_name.(asc|desc). Sorts all fields with type ‘Number’ in ascending/descending order.</param>
/// <param name="limit">OPTIONAL. The number of results should be returned with the query. Default value: 50</param>
/// <param name="offset">OPTIONAL. The offset of the data. Default value: 0</param>
/// <returns></returns>
/// <exception cref="ArgumentOutOfRangeException"></exception>
public async Task<StockMarkerScreener> GetStockMarketScreenerAsync(List<(Field, Operation, string)> filters = null, List<Signal> signals = null,
(Field, Order)? sort = null, int? limit = null, int? offset = null)
{
if (offset < 0 && offset > 1000) throw new ArgumentOutOfRangeException(nameof(offset));
if (limit < 1 && limit > 100) throw new ArgumentOutOfRangeException(nameof(offset));
string filterstring = null;
if (filters != null)
{
filterstring = FiltersToString(filters);
}
string signalstring = null;
if (signals != null)
{
signalstring = SignalsToString(signals);
}
string sortstring = null;
if (sort != null)
{
sortstring = SortToString(((Field, Order))sort);
}
return await stockMarketScreenerAPI.GetStockMarketScreenerAsync(filterstring, signalstring, sortstring, limit, offset);
}
/// <summary>
/// Сollects a string from a list of tuples
/// </summary>
/// <param name="filters"></param>
/// <returns>String</returns>
/// <exception cref="ArgumentException"></exception>
private static string FiltersToString(List<(Field, Operation, string)> filters)
{
string filterstring = "[";
for (int i = 0; i < filters.Count; i++)
{
string field;
switch (filters[i].Item1)
{
case Field.Code:
field = "\"code\"";
break;
case Field.Name:
field = "\"name\"";
break;
case Field.Exchange:
field = "\"exchange\"";
break;
case Field.Sector:
field = "\"sector\"";
break;
case Field.Industry:
field = "\"industry\"";
break;
case Field.MarketCapitalization:
field = "\"market_capitalization\"";
break;
case Field.EarningsShare:
field = "\"earnings_share\"";
break;
case Field.DividendYield:
field = "\"dividend_yield\"";
break;
case Field.Refund1dP:
field = "\"refund_1d_p\"";
break;
case Field.Refund5dP:
field = "\"refund_5d_p\"";
break;
default:
throw new NotImplementedException();
}
string operation = string.Empty;
switch (filters[i].Item2)
{
case Operation.Matches:
operation = "\"match\"";
break;
case Operation.Equals:
operation = "\"=\"";
break;
case Operation.More:
operation = "\">\"";
break;
case Operation.Less:
operation = "\"<\"";
break;
case Operation.NotLess:
operation = "\">=\"";
break;
case Operation.NotMore:
operation = "\"<=\"";
break;
case Operation.NotEquals:
operation = "\"!=\"";
break;
default:
throw new NotImplementedException();
}
if (Double.TryParse(filters[i].Item3, out _))
{
filterstring += '[' + field + ',' + operation + ',' + filters[i].Item3 + "],";
}
else
{
filterstring += '[' + field + ',' + operation + ",\"" + filters[i].Item3 + "\"],";
}
}
filterstring = filterstring.Remove(filterstring.Length - 1);
filterstring += ']';
return filterstring;
}
/// <summary>
/// Collects a string from a list of Signals
/// </summary>
/// <param name="signals"></param>
/// <returns>String</returns>
/// <exception cref="NotImplementedException"></exception>
private static string SignalsToString(List<Signal> signals)
{
string signalstring = string.Empty;
for (int i = 0; i < signals.Count; i++)
{
string signal;
switch (signals[i])
{
case Signal.New_50d_low:
signal = "50d_new_lo";
break;
case Signal.New_50d_hi:
signal = "50d_new_hi";
break;
case Signal.New_200d_low:
signal = "200d_new_lo";
break;
case Signal.New_200d_hi:
signal = "200d_new_hi";
break;
case Signal.Bookvalue_neg:
signal = "bookvalue_neg";
break;
case Signal.Bookvalue_pos:
signal = "bookvalue_pos";
break;
case Signal.Wallstreet_low:
signal = "wallstreet_lo";
break;
case Signal.Wallstreet_hi:
signal = "wallstreet_hi";
break;
default:
throw new NotImplementedException();
}
signalstring += signal + ',';
}
signalstring = signalstring.Remove(signalstring.Length - 1);
return signalstring;
}
/// <summary>
/// Collects a string from a tuple of Field and Order
/// </summary>
/// <param name="sort"></param>
/// <returns>String</returns>
/// <exception cref="NotImplementedException"></exception>
private static string SortToString((Field, Order) sort)
{
string sortfield;
switch (sort.Item1)
{
case Field.Code:
sortfield = "code";
break;
case Field.Name:
sortfield = "name";
break;
case Field.Exchange:
sortfield = "exchange";
break;
case Field.Sector:
sortfield = "sector";
break;
case Field.Industry:
sortfield = "industry";
break;