ShinyApp setup and usage

The Alphavantagepf package contains a Shiny Application which can be used to query, save, and visualize basic market information without having to navigate the asset-specific functions provided by the Alphavantage API. The app provides an intuitive way to compare small baskets of assets both technically and fundamentally.

This vignette will first go through some overall design goals and conventions before providing an overview of how to start and configure the application. Once the basic configuration is set, we then show how to get results (and what happens underneath the hood), what can be done, and how to maximize productivity with list management and function recall features.

Overall design goals and conventions

The app is designed to

A few conventions which are helpful to know before using the app are 1

Item Convention Example
Asset Sets Semicolon ; delimited tickers "IBM;NDX;USD/MXN"
Relative Dates (Signed) integers followed by [m|d|y], relative to today "-4m"
Date Ranges Relative dates separated by "::" "-4m::", "-1y::+1y"

“Assets” can be any (common) symbol for an Equity, ETF, Currency (in the usual form of an alphabetic string of the form (countercurrency / currency), cryptocurrency2, index, or user defined time series.

App invocation, permissionings, and initial setup.

To invoke the app, just run the following from the R console.

require(alphavantagepf)
av_runShiny()

When av_runShiny() is first run, the following screen will be shown, with the AVOPTS tab selected.

Before using, the app needs to ensure thatAlpha Vantage API permissions are set up. The development of this app assumes the lowest (i.e. cheapest) real-time permissionings. Better data may be obtained for some uses with higher-frequency permissionings (e.g. Realtime option quotes), but are not used currently. Use with delayed data may (as of v0.8.4) break some commands.

To set the permissionings, just type or copy in both your API key and your entitlement status (delayed or realtime), and hit the blue Set Opts button.

avopts
avopts

When the Set Opts button is pressed, a table of internal state variables is shown, with any changes highlighted. There are several options which can be set, all described in the Options Vignette, but one in particular is worth changing up front.

The app fills in a default data cache location determined by [tools::R_user_dir()]. Since that directory is a cache directory typically buried in long paths, you may find it helpful to set an alternative location in the Cache Data Directory field as has been done above. This will provide a consistent and easily accessable portal between the data used by the app and any external analyses or data collection mechanisms already in place.

After the first invocation, the app will start on the INVENTORY tab, so a user can immediately see what’s been updated and search for tickers.

General Usage

Analyses are all done by invoking “functions” or commands on a set of assets in the yellow line shown above. As described in the README file, commands which start with AV. are asset-less commands and mostly oriented towards app-specific information such as data inventories or help pages. All other commands refer to the semi-colon delimited asset or ticker list given first.

Once you know what you want, just type it in and hit “Enter”. To start, the app will copy the command to the green line (and clear the input for the next command). The, the command will get any data it needs and then produce a set of tables, time series graphs, or other plots. See Data Vignette for details as to how this done. Most commands require a timeframe of historical data to analyze. The date range (formatted as above) in HistDates is used, but other date ranges within that range may be added as parameters.

The app responds as follows:

Examples

You might want to start with AV.H which describes all the commands available. Some examples of commands that can be run are

Command Description
EEM;HEEM GP Graph raw time series of the EEM ETF and it’s hedged counterpart.
QQQ;SPY GPI2 Graph time series of QQQ and SPY rebased to 100 at start below the first graph.
QQQ;SPY GPD -6m:: Graph total return indices of the two ETFs rebased to 100 as of 6 months ago
IBM;ORCL EA Table of earnings and estimates for IBM and ORCL
IBM;ORCL GEP Graph Earnings Yield for IBM and ORCL
IBM;ORCL CN Table of linked News items for IBM and ORCL
IBM;ORCL DES Table of descriptive items for IBM and ORCL
ORCL OS Table of options for ORCL
ORCL RV Active returns and correlations with the counterasset (default is SPY)
av.r Recall the last executed command into the yellow input area
AV.EQINV Show a list of all ETFs and Equities with downloaded data

To see how the date conventions work, the results of the third command are shown below. Note that there is a slider (provided by dygraphs()) which allows you to zoom in or out to specific time windows. In this case, the graph starts at -6m::, where both indices are rebased to 100, but can be zoomed out to a maximum of 4 years (HistDates has -4y::) from today. Finally, the last option in TSopts puts a horizontal bar showing the last values of each series.

gpd2 Example
gpd2 Example

Here is another example which highlights both the comprehensive abilities to combine assets in the app with graphing abilities. Suppose we wish to plot the fair value history of the crypto ETF IBIT, and add some visual indication of overall market direction. Editing the counterasset to BTC/USD, adding doi:regm in Events, and running IBIT RV gives the following.

Asset Lists

Securities are seldom analyzed in isolation. It is easy to create and use ad-hoc groups of securities in this app.

The best way to see how this works is with the short clip shown here

You can see a table of current asset lists by running the AV.INV command, and can add asset lists outside of the app using av_add_assetgroups(). See Data Vignette for details.

Usage Notes

Interacting with the app from the command line.

A great and recent innovation in shiny() is the ability to run an app and return to the console. The internal data can be accessed in one of three ways:

In addition, internal states and data can be extracted via functions such as dump_state().

Other notes

Specific command notes


  1. A “cheatsheet” with these conventions is displayed when AV.H is run, unless the showGeneralHelp option is deselected.↩︎

  2. See AV.TICKERS for a list of cryptocurrencies available. Not all are available as symmetric pairs, so please use only those on the list.↩︎

  3. unless the verbose option is deselected in the AVOPTS tab.↩︎

  4. Adding and using component weights to the asset lists is planned for a future release.↩︎

  5. The app looks up the current spot to determine moneyness.↩︎