├── .config
└── dotnet-tools.json
├── .gitattributes
├── .github
├── FUNDING.yml
├── dependabot.yml
└── workflows
│ ├── codeql.yml
│ ├── release.yml
│ └── stale.yml
├── .gitignore
├── Configuration.xml
├── LICENSE.txt
├── OoplesFinance.YahooFinanceAPI.sln
├── README.md
├── src
├── Enums
│ ├── Country.cs
│ ├── DataFrequency.cs
│ ├── DataType.cs
│ ├── Language.cs
│ ├── ScreenerType.cs
│ ├── TimeInterval.cs
│ ├── TimeRange.cs
│ └── YahooModule.cs
├── Helpers
│ ├── AllHistoricalHelper.cs
│ ├── AnalystHelper.cs
│ ├── AssetProfileHelper.cs
│ ├── AutoCompleteHelper.cs
│ ├── BalanceSheetHistoryHelper.cs
│ ├── BalanceSheetHistoryQuarterlyHelper.cs
│ ├── CalendarEventsHelper.cs
│ ├── CapitalGainHelper.cs
│ ├── CashflowStatementHistoryHelper.cs
│ ├── CashflowStatementHistoryQuarterlyHelper.cs
│ ├── ChartHelper.cs
│ ├── CrumbHelper.cs
│ ├── DateTimeHelper.cs
│ ├── DividendHelper.cs
│ ├── DownloadHelper.cs
│ ├── EarningsHelper.cs
│ ├── EarningsHistoryHelper.cs
│ ├── EarningsTrendHelper.cs
│ ├── EsgScoresHelper.cs
│ ├── ExternalInit.cs
│ ├── FinancialDataHelper.cs
│ ├── FundOwnershipHelper.cs
│ ├── FundProfileHelper.cs
│ ├── HistoricalHelper.cs
│ ├── IncomeStatementHistoryHelper.cs
│ ├── IncomeStatementHistoryQuarterlyHelper.cs
│ ├── IndexTrendHelper.cs
│ ├── InsiderHolderHelper.cs
│ ├── InsiderTransactionHelper.cs
│ ├── InsightsHelper.cs
│ ├── InstitutionHelper.cs
│ ├── InstitutionOwnershipHelper.cs
│ ├── KeyStatisticsHelper.cs
│ ├── MajorDirectHoldersHelper.cs
│ ├── MajorHoldersBreakdownHelper.cs
│ ├── MarketSummaryHelper.cs
│ ├── NetSharePurchaseActivityHelper.cs
│ ├── PriceHelper.cs
│ ├── QuoteTypeHelper.cs
│ ├── RealTimeQuoteHelper.cs
│ ├── RecommendationHelper.cs
│ ├── RecommendationTrendHelper.cs
│ ├── ScreenerHelper.cs
│ ├── SecFilingsHelper.cs
│ ├── SectorTrendHelper.cs
│ ├── SparkChartHelper.cs
│ ├── StockSplitHelper.cs
│ ├── StocksOwnedHelper.cs
│ ├── SummaryDetailsHelper.cs
│ ├── TrendingHelper.cs
│ ├── TrendingStocksHelper.cs
│ ├── UpgradeDowngradeHistoryHelper.cs
│ ├── UrlHelper.cs
│ └── Usings.cs
├── Images
│ └── Favicon.jpg
├── Interfaces
│ ├── YahooCsvBase.cs
│ └── YahooJsonBase.cs
├── IsExternalInit.cs
├── Models
│ ├── AnalystData.cs
│ ├── AssetProfileData.cs
│ ├── AutoCompleteData.cs
│ ├── BalanceSheetHistoryData.cs
│ ├── BalanceSheetHistoryQuarterlyData.cs
│ ├── CalendarEventsData.cs
│ ├── CapitalGainData.cs
│ ├── CashFlowStatementHistoryData.cs
│ ├── CashflowStatementHistoryQuarterlyData.cs
│ ├── ChartData.cs
│ ├── DayGainersLosersData.cs
│ ├── DividendData.cs
│ ├── EarningsData.cs
│ ├── EarningsHistoryData.cs
│ ├── EarningsTrendData.cs
│ ├── EsgScoresData.cs
│ ├── FinancialData.cs
│ ├── FundOwnershipData.cs
│ ├── FundProfileData.cs
│ ├── HistoricalData.cs
│ ├── IncomeStatementHistoryData.cs
│ ├── IncomeStatementHistoryQuarterlyData.cs
│ ├── IndexTrendData.cs
│ ├── InsiderHolderData.cs
│ ├── InsiderTransactionData.cs
│ ├── InsightsData.cs
│ ├── InstitutionData.cs
│ ├── InstitutionOwnershipData.cs
│ ├── KeyStatisticData.cs
│ ├── MajorDirectHoldersData.cs
│ ├── MajorHoldersBreakdownData.cs
│ ├── MarketSummaryData.cs
│ ├── NetSharePurchaseActivityData.cs
│ ├── PriceData.cs
│ ├── QuoteTypeData.cs
│ ├── RealTimeQuoteData.cs
│ ├── RecommendData.cs
│ ├── RecommendationTrendData.cs
│ ├── SecFilingsData.cs
│ ├── SectorTrendData.cs
│ ├── SparkChartData.cs
│ ├── StockSplitData.cs
│ ├── StocksOwnedData.cs
│ ├── SummaryData.cs
│ ├── TrendingData.cs
│ ├── TrendingStocksData.cs
│ └── UpgradeDowngradeHistoryData.cs
├── OoplesFinance.YahooFinanceAPI.csproj
└── YahooClient.cs
└── tests
├── TestConsoleApp
├── Program.cs
└── TestConsoleApp.csproj
└── UnitTests
├── OoplesFinance.YahooFinanceAPI.Tests.Unit.csproj
├── Usings.cs
└── YahooClientTests.cs
/.config/dotnet-tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "isRoot": true,
4 | "tools": {
5 | "jetbrains.dotcover.globaltool": {
6 | "version": "2023.2.5",
7 | "commands": [
8 | "dotnet-dotcover"
9 | ]
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: ooples
4 | patreon: cheatcountry
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: cheatcountry
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: cheatcountry
10 | issuehunt: ooples
11 | otechie: cheatcountry
12 | custom: ["https://www.paypal.me/cheatcountry", "https://www.buymeacoffee.com/cheatcountry"]
13 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "nuget" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "daily"
12 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: CodeQL Analyis
2 |
3 | on:
4 | push:
5 | pull_request:
6 | branches: [ develop ]
7 | schedule:
8 | - cron: '0 8 * * 1'
9 |
10 | jobs:
11 | analyze:
12 | name: Analyze
13 | runs-on: ubuntu-latest
14 | permissions:
15 | actions: read
16 | contents: read
17 | security-events: write
18 |
19 | strategy:
20 | fail-fast: false
21 | matrix:
22 | language: [ 'csharp', 'javascript' ]
23 |
24 | steps:
25 | - name: Checkout repository
26 | uses: actions/checkout@v4
27 |
28 | - name: Setup .NET 8.0.x
29 | uses: actions/setup-dotnet@v3
30 | with:
31 | dotnet-version: '8.0.x'
32 |
33 | - name: Initialize CodeQL
34 | uses: github/codeql-action/init@v2
35 | with:
36 | languages: ${{ matrix.language }}
37 |
38 | - name: Cache NuGet Packages
39 | uses: actions/cache@v3
40 | with:
41 | path: ~/.nuget/packages
42 | key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
43 | restore-keys: |
44 | ${{ runner.os }}-nuget-
45 |
46 | - name: Dotnet Build
47 | run: dotnet build -c Release
48 |
49 | - name: Perform CodeQL Analysis
50 | uses: github/codeql-action/analyze@v2
51 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Build and Release
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 | name: Create Release
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - name: Checkout Code
12 | uses: actions/checkout@v3
13 |
14 | - name: Setup .NET 8.0.x
15 | uses: actions/setup-dotnet@v3
16 | with:
17 | dotnet-version: '8.0.x'
18 |
19 | - name: Cache NuGet Packages
20 | uses: actions/cache@v3
21 | with:
22 | path: ~/.nuget/packages
23 | key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
24 | restore-keys: |
25 | ${{ runner.os }}-nuget-
26 |
27 | - name: Restore .NET Tools
28 | run: dotnet tool restore
29 | working-directory: ./tests/UnitTests
30 |
31 | - name: Dotnet Test (Debug)
32 | run: dotnet dotcover test --dcXML=Configuration.xml
33 |
34 | - name: Dotnet Build (Release)
35 | run: dotnet build -c Release
36 |
37 | - name: Save SDK Packages
38 | uses: actions/upload-artifact@v3
39 | with:
40 | name: sdk-packages
41 | path: |
42 | src/bin/Release/*.nupkg
43 | src/bin/Release/*.snupkg
44 |
45 | - name: Send Coverage to Codacy
46 | if: "${{env.CODACY_PROJECT_TOKEN != ''}}"
47 | env:
48 | CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
49 | run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r OoplesFinance.YahooFinanceAPI.Coverage.xml
50 |
51 | publish-sdk:
52 | name: Publish SDK Binaries
53 | runs-on: ubuntu-latest
54 | needs: build
55 | if: github.repository == 'ooples/OoplesFinance.YahooFinanceAPI'
56 |
57 | steps:
58 | - name: Load SDK Packages
59 | uses: actions/download-artifact@v4.1.7
60 | with:
61 | name: sdk-packages
62 |
63 | - name: Create NuGet Version
64 | run: dotnet nuget push **.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
65 |
66 | - name: Publish Github Packages
67 | uses: tanaka-takayoshi/nuget-publish-to-github-packages-action@v2.1
68 | with:
69 | nupkg-path: './artifacts/*.nupkg'
70 | repo-owner: 'ooples'
71 | gh-user: 'ooples'
72 | token: ${{ secrets.GITHUB_TOKEN }}
73 |
74 | - name: Create GitHub Release
75 | uses: softprops/action-gh-release@v1
76 | with:
77 | name: SDK ${{ github.ref }}
78 | draft: true
79 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
2 | #
3 | # You can adjust the behavior by modifying this file.
4 | # For more information, see:
5 | # https://github.com/actions/stale
6 | name: Mark stale issues and pull requests
7 |
8 | on:
9 | schedule:
10 | - cron: '25 7 * * *'
11 |
12 | jobs:
13 | stale:
14 |
15 | runs-on: ubuntu-latest
16 | permissions:
17 | issues: write
18 | pull-requests: write
19 |
20 | steps:
21 | - uses: actions/stale@v5
22 | with:
23 | repo-token: ${{ secrets.GITHUB_TOKEN }}
24 | stale-issue-message: 'Stale issue message'
25 | stale-pr-message: 'Stale pull request message'
26 | stale-issue-label: 'no-issue-activity'
27 | stale-pr-label: 'no-pr-activity'
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/Configuration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | OoplesFinance.YahooFinanceAPI
7 |
8 |
9 |
10 |
11 | DetailedXml
12 |
13 |
--------------------------------------------------------------------------------
/OoplesFinance.YahooFinanceAPI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33209.295
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OoplesFinance.YahooFinanceAPI", "src\OoplesFinance.YahooFinanceAPI.csproj", "{F783EAAC-E1BF-4AA9-B9C6-BC0F1519613F}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OoplesFinance.YahooFinanceAPI.Tests.Unit", "tests\UnitTests\OoplesFinance.YahooFinanceAPI.Tests.Unit.csproj", "{CECB02A3-7D31-4AE6-AB3E-52E46B62BF4B}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleApp", "tests\TestConsoleApp\TestConsoleApp.csproj", "{8FC9B783-0941-4623-BC98-AA31A8678808}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {F783EAAC-E1BF-4AA9-B9C6-BC0F1519613F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {F783EAAC-E1BF-4AA9-B9C6-BC0F1519613F}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {F783EAAC-E1BF-4AA9-B9C6-BC0F1519613F}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {F783EAAC-E1BF-4AA9-B9C6-BC0F1519613F}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {CECB02A3-7D31-4AE6-AB3E-52E46B62BF4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {CECB02A3-7D31-4AE6-AB3E-52E46B62BF4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {CECB02A3-7D31-4AE6-AB3E-52E46B62BF4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {CECB02A3-7D31-4AE6-AB3E-52E46B62BF4B}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {8FC9B783-0941-4623-BC98-AA31A8678808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {8FC9B783-0941-4623-BC98-AA31A8678808}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {8FC9B783-0941-4623-BC98-AA31A8678808}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {8FC9B783-0941-4623-BC98-AA31A8678808}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {ABAB5149-23B2-4D15-BD69-05993065166E}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/src/Enums/Country.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum Country
4 | {
5 | UnitedStates,
6 | Australia,
7 | Canada,
8 | France,
9 | Germany,
10 | HongKong,
11 | India,
12 | Italy,
13 | Spain,
14 | UnitedKingdom
15 | }
16 |
--------------------------------------------------------------------------------
/src/Enums/DataFrequency.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum DataFrequency
4 | {
5 | Daily,
6 | Weekly,
7 | Monthly
8 | }
9 |
--------------------------------------------------------------------------------
/src/Enums/DataType.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum DataType
4 | {
5 | HistoricalPrices,
6 | Dividends,
7 | StockSplits,
8 | CapitalGains,
9 | All
10 | }
11 |
--------------------------------------------------------------------------------
/src/Enums/Language.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum Language
4 | {
5 | English,
6 | French,
7 | German,
8 | Italian,
9 | Mandarin,
10 | Spanish
11 | }
12 |
--------------------------------------------------------------------------------
/src/Enums/ScreenerType.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum ScreenerType
4 | {
5 | AggressiveSmallCaps,
6 | AnalystStrongBuyStocks,
7 | BearishStocksRightNow,
8 | BullishStocksRightNow,
9 | ConservativeForeignFunds,
10 | DayGainers,
11 | DayLosers,
12 | GrowthTechnologyStocks,
13 | HighYieldBond,
14 | LatestAnalystUpgradedStocks,
15 | MorningstarFiveStarStocks,
16 | MostActives,
17 | MostInstitutionallyBoughtLargeCapStocks,
18 | MostInstitutionallyHeldLargeCapStocks,
19 | MostInstitutionallySoldLargeCapStocks,
20 | MostShortedStocks,
21 | PortfolioAnchors,
22 | SmallCapGainers,
23 | SolidLargeGrowthFunds,
24 | SolidMidcapGrowthFunds,
25 | StocksMostBoughtByHedgeFunds,
26 | StocksMostBoughtByPensionFunds,
27 | StocksMostBoughtByPrivateEquity,
28 | StocksMostBoughtBySovereignWealthFunds,
29 | StocksWithMostInstitutionalBuyers,
30 | StocksWithMostInstitutionalSellers,
31 | StrongUndervaluedStocks,
32 | TopMutualFunds,
33 | TopStocksOwnedByCathieWood,
34 | TopStocksOwnedByGoldmanSachs,
35 | TopStocksOwnedByRayDalio,
36 | TopStocksOwnedByWarrenBuffet,
37 | UndervaluedGrowthStocks,
38 | UndervaluedLargeCaps,
39 | UndervaluedWideMoatStocks,
40 | UpsideBreakoutStocksDaily
41 | }
42 |
--------------------------------------------------------------------------------
/src/Enums/TimeInterval.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum TimeInterval
4 | {
5 | _1Minute,
6 | _2Minutes,
7 | _5Minutes,
8 | _15Minutes,
9 | _30Minutes,
10 | _60Minutes,
11 | _90Minutes,
12 | _1Hour,
13 | _1Day,
14 | _5Days,
15 | _1Week,
16 | _1Month,
17 | _3Months
18 | }
19 |
--------------------------------------------------------------------------------
/src/Enums/TimeRange.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum TimeRange
4 | {
5 | _1Day,
6 | _5Days,
7 | _1Month,
8 | _3Months,
9 | _6Months,
10 | _1Year,
11 | _2Years,
12 | _5Years,
13 | _10Years,
14 | YearToDate,
15 | Max
16 | }
17 |
--------------------------------------------------------------------------------
/src/Enums/YahooModule.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Enums;
2 |
3 | public enum YahooModule
4 | {
5 | AssetProfile,
6 | BalanceSheetHistory,
7 | BalanceSheetHistoryQuarterly,
8 | CalendarEvents,
9 | CashflowStatementHistory,
10 | CashflowStatementHistoryQuarterly,
11 | Earnings,
12 | EarningsHistory,
13 | EarningsTrend,
14 | EsgScores,
15 | FinancialData,
16 | FundOwnership,
17 | FundProfile,
18 | IncomeStatementHistory,
19 | IncomeStatementHistoryQuarterly,
20 | IndexTrend,
21 | InsiderHolders,
22 | InsiderTransactions,
23 | Insights,
24 | InstitutionOwnership,
25 | KeyStatistics,
26 | MajorDirectHolders,
27 | MajorHoldersBreakdown,
28 | NetSharePurchaseActivity,
29 | Price,
30 | QuoteType,
31 | RecommendationTrend,
32 | SecFilings,
33 | SectorTrend,
34 | SummaryDetails,
35 | UpgradeDowngradeHistory
36 | }
37 |
--------------------------------------------------------------------------------
/src/Helpers/AllHistoricalHelper.cs:
--------------------------------------------------------------------------------
1 | // AllHistoricalHelper.cs
2 | // Andrew Baylis
3 | // Created: 12/10/2024
4 |
5 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
6 |
7 | internal class AllHistoricalHelper
8 | {
9 | #region Internal Methods
10 |
11 | internal HistoricalFullData ParseYahooJsonData(string jsonData)
12 | {
13 | var root = JsonConvert.DeserializeObject(jsonData)?.Chart?.Result.FirstOrDefault() ??
14 | throw new InvalidOperationException("No data available from Yahoo Finance");
15 |
16 | var result = new HistoricalFullData {Meta = root.Meta};
17 |
18 | for (var i = 0; i < root.Timestamp.Count; i++)
19 | {
20 | result.Prices.Add(new HistoricalChartInfo
21 | {
22 | Meta = root.Meta,
23 | Date = root.Timestamp[i].GetValueOrDefault().FromUnixTimeStamp(),
24 | Open = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Open[i] ?? 0, 4),
25 | High = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.High[i] ?? 0, 4),
26 | Low = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Low[i] ?? 0, 4),
27 | Close = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Close[i] ?? 0, 4),
28 | AdjustedClose = Math.Round(root.Indicators?.Adjclose.FirstOrDefault()?.Adjclose[i] ?? 0, 4),
29 | Volume = root.Indicators?.Quote.FirstOrDefault()?.Volume[i] ?? 0
30 | });
31 | }
32 |
33 | if (result.Prices.Count == 0)
34 | {
35 | throw new InvalidOperationException("Requested Information Not Available On Yahoo Finance");
36 | }
37 |
38 | if (root.Events.DividendData.Count > 0)
39 | {
40 | foreach (var dividend in root.Events.DividendData)
41 | {
42 | result.Dividends.Add(new DividendInfo(dividend.Value));
43 | }
44 | }
45 |
46 | if (root.Events.SplitData.Count > 0)
47 | {
48 | foreach (var split in root.Events.SplitData)
49 | {
50 | result.Splits.Add(new SplitInfo(split.Value));
51 | }
52 | }
53 |
54 | return result;
55 | }
56 |
57 | #endregion
58 | }
--------------------------------------------------------------------------------
/src/Helpers/AnalystHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class AnalystHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Analyst data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var analystData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return analystData != null ? (IEnumerable)analystData.Finance.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/AssetProfileHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class AssetProfileHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Asset Profile data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var assetProfile = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return assetProfile != null ? (IEnumerable)assetProfile.QuoteSummary.Results.Select(x => x.AssetProfile) : [];
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Helpers/AutoCompleteHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class AutoCompleteHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the AutoComplete data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var autoComplete = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return autoComplete != null ? (IEnumerable)autoComplete.ResultSet.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/BalanceSheetHistoryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class BalanceSheetHistoryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Balance Sheet History data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var balanceSheetHistory = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return balanceSheetHistory != null ? (IEnumerable)balanceSheetHistory.QuoteSummary.Results.
16 | Select(x => x.BalanceSheetHistory).First().BalanceSheetStatements : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/BalanceSheetHistoryQuarterlyHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class BalanceSheetHistoryQuarterlyHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Balance Sheet History Quarterly data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var balanceSheetHistoryQuarterlyData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return balanceSheetHistoryQuarterlyData != null ? (IEnumerable)balanceSheetHistoryQuarterlyData.QuoteSummary.Results.
16 | Select(x => x.BalanceSheetHistoryQuarterly).First().BalanceSheetStatements : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/CalendarEventsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class CalendarEventsHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Calendar Events data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var calendarEvents = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return calendarEvents != null ? (IEnumerable)calendarEvents.QuoteSummary.Results.Select(x => x.CalendarEvents) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/CapitalGainHelper.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
4 |
5 | internal class CapitalGainHelper : YahooJsonBase
6 | {
7 | internal override IEnumerable ParseYahooJsonData(string jsonData)
8 | {
9 | var capitalGain = JsonConvert.DeserializeObject(jsonData);
10 |
11 | if (capitalGain != null && capitalGain.Chart?.Result != null)
12 | {
13 | var result = capitalGain.Chart.Result.Cast();
14 |
15 | return result;
16 | }
17 |
18 | return [];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Helpers/CashflowStatementHistoryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class CashflowStatementHistoryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Cashflow Statement History data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var balanceSheetHistory = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return balanceSheetHistory != null ? (IEnumerable)balanceSheetHistory.QuoteSummary.Results.
16 | Select(x => x.CashflowStatementHistory).First().CashflowStatements : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/CashflowStatementHistoryQuarterlyHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class CashflowStatementHistoryQuarterlyHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Cashflow Statement History Quarterly data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var cashflowStatementHistoryQuarterlyData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return cashflowStatementHistoryQuarterlyData != null ? (IEnumerable)cashflowStatementHistoryQuarterlyData.QuoteSummary.Results.
16 | Select(x => x.CashflowStatementHistoryQuarterly).First().CashflowStatements : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/ChartHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class ChartHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Chart data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var root = JsonConvert.DeserializeObject(jsonData)?.Chart.Result.FirstOrDefault();
14 |
15 | var result = new ChartInfo
16 | {
17 | DateList = new List(root != null ? root.Timestamp.Select(x => x.FromUnixTimeStamp()) : []),
18 | CloseList = new List(root != null ? root.Indicators?.Quote.SelectMany(x => x.Close.Select(y => y.GetValueOrDefault())) ?? [] : []),
19 | OpenList = new List(root != null ? root.Indicators?.Quote.SelectMany(x => x.Open.Select(y => y.GetValueOrDefault())) ?? [] : []),
20 | HighList = new List(root != null ? root.Indicators?.Quote.SelectMany(x => x.High.Select(y => y.GetValueOrDefault())) ?? [] : []),
21 | VolumeList = new List(root != null ? root.Indicators?.Quote.SelectMany(x => x.Volume.Select(y => y.GetValueOrDefault())) ?? [] : []),
22 | LowList = new List(root != null ? root.Indicators?.Quote.SelectMany(x => x.Low.Select(y => y.GetValueOrDefault())) ?? [] : [])
23 | };
24 |
25 | if (result.DateList.Count == 0 || result.CloseList.Count == 0 || result.OpenList.Count == 0 || result.HighList.Count == 0 ||
26 | result.VolumeList.Count == 0 || result.LowList.Count == 0)
27 | {
28 | throw new InvalidOperationException("Requested Information Not Available On Yahoo Finance");
29 | }
30 |
31 | return new[] { result }.Cast();
32 | }
33 | }
--------------------------------------------------------------------------------
/src/Helpers/CrumbHelper.cs:
--------------------------------------------------------------------------------
1 | // CrumbHelper.cs
2 | // Andrew Baylis
3 | // Created: 29/10/2024
4 |
5 | #region using
6 |
7 | using System.Runtime.CompilerServices;
8 |
9 | #endregion
10 |
11 | [assembly: InternalsVisibleTo("OoplesFinance.YahooFinanceAPI.Tests.Unit")]
12 |
13 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
14 |
15 | internal sealed class CrumbHelper
16 | {
17 | #region Fields
18 |
19 | private static CrumbHelper? _instance;
20 |
21 | internal static HttpMessageHandler? handler;
22 | private List cookies = [];
23 |
24 | #endregion
25 |
26 | private CrumbHelper()
27 | {
28 | handler = GetClientHandler();
29 | Crumb = string.Empty;
30 | }
31 |
32 | #region Properties
33 |
34 | ///
35 | /// Crumb value for the Yahoo Finance API
36 | ///
37 | internal string Crumb { get; private set; }
38 |
39 | ///
40 | /// Single instance of the CrumbHelper
41 | ///
42 | private static CrumbHelper Instance
43 | {
44 | get { return _instance ??= new CrumbHelper(); }
45 | }
46 |
47 | #endregion
48 |
49 | #region Static Methods
50 |
51 | public static HttpClient GetHttpClient()
52 | {
53 | HttpClient client = new(handler ?? GetClientHandler());
54 | client.DefaultRequestHeaders.Add("Cookie", Instance.cookies);
55 | client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3");
56 | client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
57 | client.DefaultRequestHeaders.Add("Connection", "keep-alive");
58 | client.DefaultRequestHeaders.Add("Pragma", "no-cache");
59 | client.DefaultRequestHeaders.Add("Upgrade-Insecure-Requests", "1");
60 |
61 | return client;
62 | }
63 |
64 | public static async Task GetInstance(bool setCrumb = true)
65 | {
66 | if (string.IsNullOrEmpty(Instance.Crumb) && setCrumb)
67 | {
68 | await Instance.SetCrumbAsync();
69 | }
70 |
71 | return Instance;
72 | }
73 |
74 | private static HttpClientHandler GetClientHandler()
75 | {
76 | return YahooClient.IsThrottled
77 | ? new DownloadThrottleQueueHandler(40, TimeSpan.FromMinutes(1),4) //40 calls in a minute, no more than 4 simultaneously
78 | : new HttpClientHandler();
79 | }
80 |
81 | #endregion
82 |
83 | #region Public Methods
84 |
85 | public async Task SetCrumbAsync()
86 | {
87 | var client = GetHttpClient();
88 | var loginResponse = await client.GetAsync("https://login.yahoo.com/");
89 |
90 | if (loginResponse.IsSuccessStatusCode)
91 | {
92 | var login = await loginResponse.Content.ReadAsStringAsync();
93 | if (loginResponse.Headers.TryGetValues("Set-Cookie", out var setCookie))
94 | {
95 | cookies = new List(setCookie.Where(c => c.ToLower().IndexOf("domain=.yahoo.com") > 0));
96 | var crumbResponse = await client.GetAsync("https://query1.finance.yahoo.com/v1/test/getcrumb");
97 |
98 | if (crumbResponse.IsSuccessStatusCode)
99 | {
100 | Crumb = await crumbResponse.Content.ReadAsStringAsync();
101 | }
102 | }
103 | }
104 |
105 | if (string.IsNullOrEmpty(Crumb))
106 | {
107 | throw new Exception("Failed to get crumb");
108 | }
109 | }
110 |
111 | #endregion
112 |
113 | #region Internal Methods
114 |
115 | internal void Destroy()
116 | {
117 | _instance = null;
118 | }
119 |
120 | #endregion
121 | }
122 |
123 | internal class DownloadThrottleQueueHandler : HttpClientHandler
124 | {
125 | #region Fields
126 |
127 | private readonly TimeSpan _maxPeriod;
128 | private readonly SemaphoreSlim _throttleLoad, _throttleRate;
129 |
130 | #endregion
131 |
132 | public DownloadThrottleQueueHandler(int maxPerPeriod, TimeSpan maxPeriod, int maxParallel = -1)
133 | {
134 | if (maxParallel < 0 || maxParallel > maxPerPeriod)
135 | {
136 | maxParallel = maxPerPeriod;
137 | }
138 |
139 | _throttleLoad = new SemaphoreSlim(maxParallel, maxParallel);
140 | _throttleRate = new SemaphoreSlim(maxPerPeriod, maxPerPeriod);
141 | _maxPeriod = maxPeriod;
142 | }
143 |
144 | #region Override Methods
145 |
146 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
147 | {
148 | await _throttleLoad.WaitAsync(cancellationToken); // Allow bursts up to maxParallel requests at once
149 | cancellationToken.ThrowIfCancellationRequested();
150 | try
151 | {
152 | await _throttleRate.WaitAsync(cancellationToken);
153 |
154 | // Release after period [Note: Intentionally not awaited]
155 | // - Do not allow more than maxPerPeriod requests per period
156 | _ = Task.Delay(_maxPeriod).ContinueWith(tt => { _throttleRate.Release(1); }, cancellationToken);
157 | cancellationToken.ThrowIfCancellationRequested();
158 | return await base.SendAsync(request, cancellationToken);
159 | }
160 | finally
161 | {
162 | _throttleLoad.Release();
163 | }
164 | }
165 |
166 | #endregion
167 | }
--------------------------------------------------------------------------------
/src/Helpers/DateTimeHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | public static class DateTimeHelper
4 | {
5 | ///
6 | /// Converts a date to the Unix format which is the amount of seconds since Jan 1, 1970
7 | ///
8 | ///
9 | ///
10 | public static long ToUnixTimestamp(this DateTime dateTime)
11 | {
12 | return new DateTimeOffset(dateTime).ToUnixTimeSeconds();
13 | }
14 |
15 | ///
16 | /// Converts a data from the Unix format which is the amount of seconds since Jan 1, 1970 to a normal date
17 | ///
18 | ///
19 | ///
20 | public static DateTime FromUnixTimeStamp(this long unixTimestamp)
21 | {
22 | return DateTimeOffset.FromUnixTimeSeconds(unixTimestamp).DateTime;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Helpers/DividendHelper.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
3 |
4 | internal class DividendHelper : YahooJsonBase
5 | {
6 | internal override IEnumerable ParseYahooJsonData(string jsonData)
7 | {
8 | var dividendData = JsonConvert.DeserializeObject(jsonData);
9 |
10 | if (dividendData != null && dividendData.Chart?.Result != null)
11 | {
12 | var results = dividendData.Chart.Result.Cast();
13 |
14 | return results;
15 | }
16 |
17 | return [];
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Helpers/EarningsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class EarningsHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Earnings data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var earnings = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return earnings != null ? (IEnumerable)earnings.QuoteSummary.Results.Select(x => x.Earnings) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/EarningsHistoryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class EarningsHistoryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Earnings History data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var earningsHistory = JsonConvert.DeserializeObject(jsonData);
14 | var result = earningsHistory != null ? (IEnumerable?)earningsHistory.QuoteSummary.Results.Select(x => x.EarningsHistory).FirstOrDefault()?.History : [];
15 |
16 | return result ?? [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/EarningsTrendHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class EarningsTrendHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Earnings Trend data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var earningsTrend = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return earningsTrend != null ? (IEnumerable)earningsTrend.QuoteSummary.Results.
16 | Select(x => x.EarningsTrend).First().Trends : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/EsgScoresHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class EsgScoresHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Esg Scores data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var esgScores = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return esgScores != null ? (IEnumerable)esgScores.QuoteSummary.Results.Select(x => x.EsgScores) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/ExternalInit.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal static class IsExternalInit { }
4 |
--------------------------------------------------------------------------------
/src/Helpers/FinancialDataHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class FinancialDataHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Financial Data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var financialData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return financialData != null ? (IEnumerable)financialData.QuoteSummary.Results.Select(x => x.FinancialData) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/FundOwnershipHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class FundOwnershipHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Fund Ownership data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var fundOwnership = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return fundOwnership != null ? (IEnumerable)fundOwnership.QuoteSummary.Results.Select(x => x.FundOwnership).First().OwnershipList : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/FundProfileHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class FundProfileHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Fund Profile data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var fundProfile = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return fundProfile != null ? (IEnumerable)fundProfile.QuoteSummary.Results.Select(x => x.FundProfile) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/HistoricalHelper.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
3 |
4 | internal class HistoricalHelper : YahooJsonBase
5 | {
6 | ///
7 | /// Parses the raw json data for the Financial Data
8 | ///
9 | ///
10 | ///
11 | ///
12 | internal override IEnumerable ParseYahooJsonData(string jsonData)
13 | {
14 | var root = (JsonConvert.DeserializeObject(jsonData)?.Chart?.Result.FirstOrDefault()) ??
15 | throw new InvalidOperationException("No data available from Yahoo Finance");
16 | var historicalChartInfoList = new List();
17 |
18 | for (int i = 0; i < root.Timestamp.Count; i++)
19 | {
20 | historicalChartInfoList.Add(new HistoricalChartInfo
21 | {
22 | Date = root.Timestamp[i].GetValueOrDefault().FromUnixTimeStamp(),
23 | Open = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Open[i] ?? 0, 4),
24 | High = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.High[i] ?? 0, 4),
25 | Low = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Low[i] ?? 0, 4),
26 | Close = Math.Round(root.Indicators?.Quote.FirstOrDefault()?.Close[i] ?? 0, 4),
27 | AdjustedClose = Math.Round(root.Indicators?.Adjclose.FirstOrDefault()?.Adjclose[i] ?? 0, 4),
28 | Volume = root.Indicators?.Quote.FirstOrDefault()?.Volume[i] ?? 0
29 | });
30 | }
31 |
32 | if (historicalChartInfoList.Count == 0)
33 | {
34 | throw new InvalidOperationException("Requested Information Not Available On Yahoo Finance");
35 | }
36 |
37 | return historicalChartInfoList.Cast();
38 | }
39 | }
--------------------------------------------------------------------------------
/src/Helpers/IncomeStatementHistoryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class IncomeStatementHistoryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Income Statement History data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var incomeStatementHistory = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return incomeStatementHistory != null ? (IEnumerable)incomeStatementHistory.QuoteSummary.Results.
16 | Select(x => x.IncomeStatementHistory).First().IncomeStatementHistoryInfo : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/IncomeStatementHistoryQuarterlyHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class IncomeStatementHistoryQuarterlyHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Income Statement History Quarterly data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var incomeStatementHistoryQuarterly = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return incomeStatementHistoryQuarterly != null ? (IEnumerable)incomeStatementHistoryQuarterly.QuoteSummary.Results.
16 | Select(x => x.IncomeStatementHistoryQuarterly).First().IncomeStatementHistory : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/IndexTrendHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class IndexTrendHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Index Trend data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var indexTrend = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return indexTrend != null ? (IEnumerable)indexTrend.QuoteSummary.Results.Select(x => x.IndexTrend) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/InsiderHolderHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class InsiderHolderHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Insider Holders Data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var insiderHolderData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return insiderHolderData != null ? (IEnumerable)insiderHolderData.QuoteSummary.Results.Select(x => x.InsiderHolders).First().Holders : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/InsiderTransactionHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class InsiderTransactionHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Insider Transactions Data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var insiderTransactionData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return insiderTransactionData != null ? (IEnumerable)insiderTransactionData.QuoteSummary.Results.Select(x => x.InsiderTransactions).First().Transactions : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/InsightsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class InsightsHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Insights data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var insights = JsonConvert.DeserializeObject(jsonData);
14 |
15 | if (insights == null || !insights.Finance.Result.Reports.Any())
16 | {
17 | throw new InvalidOperationException("Requested Information Not Available On Yahoo Finance");
18 | }
19 |
20 | return new[] { insights.Finance.Result }.Cast();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Helpers/InstitutionHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class InstitutionHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Institution data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var institutionData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return institutionData != null ? (IEnumerable)institutionData.Finance.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/InstitutionOwnershipHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class InstitutionOwnershipHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Institution Ownership data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var institutionOwnership = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return institutionOwnership != null ? (IEnumerable)institutionOwnership.QuoteSummary.Results.Select(x => x.InstitutionOwnership).First().OwnershipList : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/KeyStatisticsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class KeyStatisticsHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Key Statistics Data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var keyStatisticData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return keyStatisticData != null ? (IEnumerable)keyStatisticData.QuoteSummary.Results.Select(x => x.DefaultKeyStatistics) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/MajorDirectHoldersHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class MajorDirectHoldersHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Major Direct Holders data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var majorDirectHolders = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return majorDirectHolders != null ? (IEnumerable)majorDirectHolders.QuoteSummary.Results.Select(x => x.MajorDirectHolders).First().Holders : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/MajorHoldersBreakdownHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class MajorHoldersBreakdownHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Major Holders Breakdown data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var majorHoldersBreakdown = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return majorHoldersBreakdown != null ? (IEnumerable)majorHoldersBreakdown.QuoteSummary.Results.Select(x => x.MajorHoldersBreakdown) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/MarketSummaryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class MarketSummaryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Market Summary data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var marketSummary = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return marketSummary != null ? (IEnumerable)marketSummary.MarketSummaryResponse.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/NetSharePurchaseActivityHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class NetSharePurchaseActivityHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Net Share Purchase Activity data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var netSharePurchaseActivity = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return netSharePurchaseActivity != null ? (IEnumerable)netSharePurchaseActivity.QuoteSummary.Results.Select(x => x.NetSharePurchaseActivity) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/PriceHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class PriceHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Price data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var priceInfo = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return priceInfo != null ? (IEnumerable)priceInfo.QuoteSummary.Results.Select(x => x.Price) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/QuoteTypeHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class QuoteTypeHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Quote Type data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var quoteType = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return quoteType != null ? (IEnumerable)quoteType.QuoteSummary.Results.Select(x => x.QuoteType) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/RealTimeQuoteHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class RealTimeQuoteHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Real-time Quote data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var realTimeQuoteData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return realTimeQuoteData != null ? (IEnumerable)realTimeQuoteData.QuoteResponse.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/RecommendationHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class RecommendationHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Recommendation Data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var rawRecommendData = JsonConvert.DeserializeObject(jsonData);
14 | var rawResults = rawRecommendData?.Finance.Results;
15 |
16 | if (rawResults == null || !rawResults.Any())
17 | {
18 | throw new InvalidOperationException("Requested Information Not Available On Yahoo Finance");
19 | }
20 |
21 | return rawRecommendData != null ? (IEnumerable)rawRecommendData.Finance.Results.First().RecommendedSymbols : [];
22 | }
23 | }
--------------------------------------------------------------------------------
/src/Helpers/RecommendationTrendHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class RecommendationTrendHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Recommendation Trend data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var recommendationTrend = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return recommendationTrend != null ? (IEnumerable)recommendationTrend.QuoteSummary.Results.Select(x => x.RecommendationTrend).First().Trend : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/ScreenerHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class ScreenerHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Screener data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var screener = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return screener != null ? (IEnumerable)screener.Finance.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/SecFilingsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | ///
4 | /// Parses the raw json data for the SEC Filings data
5 | ///
6 | internal class SecFilingsHelper : YahooJsonBase
7 | {
8 | internal override IEnumerable ParseYahooJsonData(string jsonData)
9 | {
10 | var secFilings = JsonConvert.DeserializeObject(jsonData);
11 |
12 | return secFilings != null ? (IEnumerable)secFilings.QuoteSummary.Results.Select(x => x.SecFilings).First().Filings : [];
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/Helpers/SectorTrendHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class SectorTrendHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Sector Trend data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var sectorTrend = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return sectorTrend != null ? (IEnumerable)sectorTrend.QuoteSummary.Results.Select(x => x.SectorTrend) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/SparkChartHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class SparkChartHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Spark Chart data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var root = JObject.Parse(jsonData).Children().FirstOrDefault();
14 | var result = root?.FirstOrDefault()?.ToObject();
15 |
16 | return new[] { result }.Cast();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/StockSplitHelper.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
3 |
4 | internal class StockSplitHelper : YahooJsonBase
5 | {
6 | internal override IEnumerable ParseYahooJsonData(string jsonData)
7 | {
8 | var stockSplitData = JsonConvert.DeserializeObject(jsonData);
9 |
10 | if (stockSplitData != null && stockSplitData.Chart?.Result != null)
11 | {
12 | var results = stockSplitData.Chart.Result.Cast();
13 |
14 | return results;
15 | }
16 |
17 | return [];
18 | }
19 | }
--------------------------------------------------------------------------------
/src/Helpers/StocksOwnedHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class StocksOwnedHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Stocks Owned data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var stocksOwned = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return stocksOwned != null ? (IEnumerable)stocksOwned.Finance.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/SummaryDetailsHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class SummaryDetailsHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Summary Details data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var summaryDetailsData = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return summaryDetailsData != null ? (IEnumerable)summaryDetailsData.QuoteSummary.Results.Select(x => x.SummaryDetail) : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/TrendingHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class TrendingHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Trending Data
7 | ///
8 | ///
9 | ///
10 | internal override IEnumerable ParseYahooJsonData(string jsonData)
11 | {
12 | var rawTrendingData = JsonConvert.DeserializeObject(jsonData);
13 |
14 | return rawTrendingData != null ? (IEnumerable)rawTrendingData.Finance.Results.First().Quotes.Select(x => x.Symbol) : [];
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Helpers/TrendingStocksHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class TrendingStocksHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Trending Stocks data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var trendingStocks = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return trendingStocks != null ? (IEnumerable)trendingStocks.Finance.Results : [];
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Helpers/UpgradeDowngradeHistoryHelper.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Helpers;
2 |
3 | internal class UpgradeDowngradeHistoryHelper : YahooJsonBase
4 | {
5 | ///
6 | /// Parses the raw json data for the Upgrade Downgrade History data
7 | ///
8 | ///
9 | ///
10 | ///
11 | internal override IEnumerable ParseYahooJsonData(string jsonData)
12 | {
13 | var upgradeDowngradeHistory = JsonConvert.DeserializeObject(jsonData);
14 |
15 | return upgradeDowngradeHistory != null ? (IEnumerable)upgradeDowngradeHistory.QuoteSummary.Results.
16 | Select(x => x.UpgradeDowngradeHistory).First().History : [];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Helpers/Usings.cs:
--------------------------------------------------------------------------------
1 | global using OoplesFinance.YahooFinanceAPI.Models;
2 | global using OoplesFinance.YahooFinanceAPI.Enums;
3 | global using OoplesFinance.YahooFinanceAPI.Helpers;
4 | global using System.Globalization;
5 | global using System.Net;
6 | global using static OoplesFinance.YahooFinanceAPI.Helpers.DownloadHelper;
7 | global using static OoplesFinance.YahooFinanceAPI.Helpers.UrlHelper;
8 | global using OoplesFinance.YahooFinanceAPI.Interfaces;
9 | global using Newtonsoft.Json;
10 | global using System.Net.Http;
11 | global using Newtonsoft.Json.Linq;
--------------------------------------------------------------------------------
/src/Images/Favicon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ooples/OoplesFinance.YahooFinanceAPI/1cff4fe27c120ba4a1a9e6cd5ce1e1d2c6294e0f/src/Images/Favicon.jpg
--------------------------------------------------------------------------------
/src/Interfaces/YahooCsvBase.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Interfaces;
2 |
3 | internal abstract class YahooCsvBase
4 | {
5 | internal abstract IEnumerable ParseYahooCsvData(IEnumerable csvData);
6 | }
--------------------------------------------------------------------------------
/src/Interfaces/YahooJsonBase.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Interfaces;
2 |
3 | internal abstract class YahooJsonBase
4 | {
5 | internal abstract IEnumerable ParseYahooJsonData(string jsonData);
6 | }
--------------------------------------------------------------------------------
/src/IsExternalInit.cs:
--------------------------------------------------------------------------------
1 | namespace System.Runtime.CompilerServices;
2 |
3 | internal static class IsExternalInit {}
--------------------------------------------------------------------------------
/src/Models/AnalystData.cs:
--------------------------------------------------------------------------------
1 | namespace OoplesFinance.YahooFinanceAPI.Models;
2 |
3 | public record AnalystCriteriaMeta(
4 | [property: JsonProperty("size", NullValueHandling = NullValueHandling.Ignore)] int? Size,
5 | [property: JsonProperty("offset", NullValueHandling = NullValueHandling.Ignore)] int? Offset,
6 | [property: JsonProperty("sortField", NullValueHandling = NullValueHandling.Ignore)] string SortField,
7 | [property: JsonProperty("sortType", NullValueHandling = NullValueHandling.Ignore)] string SortType,
8 | [property: JsonProperty("entityIdType", NullValueHandling = NullValueHandling.Ignore)] string EntityIdType,
9 | [property: JsonProperty("criteria", NullValueHandling = NullValueHandling.Ignore)] IReadOnlyList Criteria,
10 | [property: JsonProperty("topOperator", NullValueHandling = NullValueHandling.Ignore)] string TopOperator
11 | );
12 |
13 | public record AnalystCriterion(
14 | [property: JsonProperty("field", NullValueHandling = NullValueHandling.Ignore)] string Field,
15 | [property: JsonProperty("operators", NullValueHandling = NullValueHandling.Ignore)] IReadOnlyList Operators,
16 | [property: JsonProperty("values", NullValueHandling = NullValueHandling.Ignore)] IReadOnlyList Values,
17 | [property: JsonProperty("labelsSelected", NullValueHandling = NullValueHandling.Ignore)] IReadOnlyList LabelsSelected,
18 | [property: JsonProperty("dependentValues", NullValueHandling = NullValueHandling.Ignore)] IReadOnlyList