Assist my content material by changing into a referred Medium Member or studying extra about C++ programming or AI in finance.
When investing within the inventory market good knowledge sources are paramount. Whether or not your funding choices are based mostly on elementary evaluation, technical evaluation, or a mixture of the 2, it may be difficult to seek out the requisite knowledge. Luckily for me, after I was constructing my inventory market analysis web site, ntrinsically.com, I discovered a wealthy (and reasonably priced) knowledge supply that offered each elementary and technical knowledge, FMP Cloud. With a free tier that offers plenty of monthly requests for the average user and a starter tier offering unlimited requests for only $14/month, in my thoughts, entry to this API was important.
One drawback with any API when constructing computational instruments is definitely and effectively accessing the information. In my case, I’ve many upcoming finance-focused tasks utilizing C++ and thought it could be extraordinarily helpful to have entry to FMP Cloud’s API endpoints so I’ve constructed a wrapper across the API that abstracts entry to its endpoints and returns RapidJSON Document objects. I’ve written earlier than about building API wrappers in Python and parsing JSON data in C++ using RapidJSON, readers considering both of those matters are inspired to learn these weblog posts for extra info.
On this submit, I’ll introduce FMPCloudAPI, a C++ header-only wrapper across the FMP Cloud API. Slightly than displaying how the wrapper was constructed (which was fairly tedious) I’ll present instance utilization in C++. Extra instance utilization will be discovered within the take a look at and instance directories on the mission’s GitHub repository. The wrapper implements virtually each endpoint within the API so the API documentation is an effective place to begin to see precisely what knowledge is offered.
For starters, anybody wanting to make use of the API wrapper will want an API key. These are offered by FMP Cloud. Readers considering making an attempt out the API can join the free tier and get 250 requests monthly. I don’t consider any of the endpoints are hidden behind a paywall so any API key, free or in any other case, ought to have full entry to the API performance.
As many of the methodology names within the wrapper class’ header file are self-documenting, under I share the category methodology declarations. As seen on this code snippet there may be a variety of knowledge accessible within the API which, once more, is extra simply seen in FMP Cloud’s documentation.
That is most likely not one of the simplest ways to show this info however with a lot knowledge accessible this submit could be an hour lengthy simply describing what every endpoint does. As a substitute, I’ll leap proper into some examples that exhibit some key endpoints (observe that the examples under are simply what I discover most helpful within the API, every consumer will discover various quantities of utility from these endpoints).
Earlier than utilizing the API wrapper, cURL will need to be installed on your system of choice (I’m utilizing Debian Linux). Moreover, RapidJSON is a header-only C++ JSON parsing library so that will need to be downloaded from their GitHub as effectively. RapidJSON may also be put in through CMake in the event you choose to make use of the dependency that means, don’t overlook to incorporate the linker flag when compiling your code in the event you take that route.
The supply code for these examples will be discovered in the project’s GitHub repository underneath the examples listing.
Fundamental Firm Info
The primary instance will fetch firm profile and inventory peer info.
The corporate profile returns necessary details about the corporate such because the title, an outline of the corporate, its web site’s URL, the CEO, the sector it belongs to, and many others.
The subsequent API name fetches the friends for a specific firm offered the inventory’s ticker image. An organization’s friends are different firms which can be deemed to be most associated to the corporate.
Value Quotes
No inventory market knowledge API could be full with out fundamental value quote info. FMP Cloud provides many endpoints to fetch inventory pricing info together with present quotes, historic value knowledge, and batch end-of-day pricing knowledge. A few of this performance is demonstrated on this instance.
For starters, a single inventory value quote is fetched for Intel Company (INTC) ensuing within the following JSON.
Subsequent, a vector of ticker symbols is offered to the identical perform name to fetch quote knowledge for a lot of tickers directly.
The ultimate two examples fetch historic minute-by-minute value knowledge and hourly value knowledge. These two calls return a LOT of information so, for brevity, solely a small quantity is proven under.
Technical Indicators
Different helpful buying and selling methods are created with technical indicators equivalent to varied transferring averages, RSI, and commonplace deviation. This info is definitely retrieved from the API. The symptoms accessible are SMA, EMA, WMA, DEMA, TEMA, WILLIAMS, RSI, ADX, and STDDEV. The instance under demonstrates fetching this knowledge.
As with the historic knowledge above, a variety of knowledge is returned from the API for these technical indicator calls so a small snippet of the information is proven under.
Monetary Statements and SEC Paperwork
In my view, a few of the most helpful info from FMP Cloud is the monetary assertion knowledge. These endpoints return knowledge from the revenue, money circulation, and steadiness sheet statements which is crucial for elementary evaluation. Since a lot knowledge is returned through these API calls, solely the code used to fetch the information is proven under.
Foreign exchange and Crypto
Lastly, FMP Cloud provides restricted international alternate and cryptocurrency knowledge. This knowledge consists of present and historic value quotes for the foreign money exchanges.
Once more, for brevity’s sake, the output from these calls will not be included on this submit. readers are invited to run the examples within the GitHub repository with the provided Makefile, or, higher but, to develop purposes of their very own utilizing the API wrapper.
In conclusion, the FMP Cloud API is a wonderful and reasonably priced useful resource for any sort of inventory market investing. The aim of this weblog submit was to introduce a C++ header-only wrapper across the API which makes the performance rather more accessible to C++ builders. The wrapper depends upon the cURL and RapidJSON libraries. This submit offered some instance utilization of the API wrapper however the demonstrations barely scratch the floor of what’s accessible from FMP Cloud and, thusly, from this API wrapper.