# Cycling data via Mathematica

Modern cycling trainers show a video and correlate resistance with what’s being shown on screen. You can “ride” a stage of the Tour de France and it will be tougher as you ride up steeper hills. Zwift has created virtual courses that cyclists from around the world can ride simultaneously, interacting with each other. It records detailed information about your virtual progress in a .FIT file, along with your heart rate, cadence, and other data from third party monitors you may be using.

Using fitparse, I created software that converts these into a format that Mathematica can understand, and using Mathematica, it is possible to break down the data a million ways. A few graphical examples are shown below.

The topography of an evening’s ride in Zwift’s Watopia as decoded by Mathematica

Velocity on the course, roughly the inverse of changes in elevation except where there are sprints

My heart rate as measured by a Wahoo heart rate monitor

# Bloomberg-to-Mathematica interface now supports overrides

Reference data requests made via the Bloomberg API can be simple (“current price of IBM Equity”) or complex (“trailing 12 month beta between AAPL US Equity and the Nasdaq index”). To send those more complex requests via external software requires overriding Blomberg’s default fields, something the Bloomberg-to-Mathematica interface did not allow. Until now.

```moStarts = DateRange[{1990, 1, 1}, {2016, 4, 1}, "Month"]; moToInclude = 12; corr1 = Table[{moStarts[[i + moToInclude - 1]], msGetBBG["SPX Index", "CORR_COEF", "noisy" -> False, "overrides" -> <|"BETA_OVERRIDE_REL_INDEX" -> "NDX Index", "BETA_OVERRIDE_START_DT" -> bbgifyDate[moStarts[[i]]], "BETA_OVERRIDE_END_DT" -> bbgifyDate[moStarts[[i + moToInclude - 1]]]|>]}, {i, 1, Length[moStarts] - moToInclude}]; corr2 = Table[{moStarts[[i + moToInclude - 1]], msGetBBG["SPX Index", "CORR_COEF", "noisy" -> False, "overrides" -> <|"BETA_OVERRIDE_REL_INDEX" -> "USGG10YR Index", "BETA_OVERRIDE_START_DT" -> bbgifyDate[moStarts[[i]]], "BETA_OVERRIDE_END_DT" -> bbgifyDate[moStarts[[i + moToInclude - 1]]]|>]}, {i, 1, Length[moStarts] - moToInclude}];```

``` ```

`DateListPlot[{corr1, corr2}, PlotLabel -> "Trailing 12-Month Correlations", Frame -> {True, True, False, False}, PlotStyle -> {Blue, Purple}, Epilog -> {(Text[Style["SPX vs. NDX", FontSize -> 10, Blue], {{2010, 9, 2}, 1.01}]), (Text[Style["SPX vs. U.S. 10 Yr Rates", FontSize -> 10, Purple], {{2007, 3, 2}, .65}])}, ImageSize -> Large, Axes -> True]`

The interface and source code can be found at GitHub

# WordFrequencyData — a mathematica function I never knew I needed

```DateListPlot[WordFrequencyData[{"Okeh", "Okay"}, "TimeSeries"], Frame -> {True, True, False, False}, PlotLabel -> "Word Frequency in English"]```

OK, OK, OK

# More revisions to the Bloomberg-to-Mathematica code

It can now take multiple simultaneous securities requests for current data, for a speedup of about 20x. You can download the WSTP conduits and source code at Github. https://github.com/MichaelSternNYC Sample below with some of The Economist‘s Big Mac Indices.

``` indices = {"BIGMUS", "BIGMBZ", "BIGMMX"};```

``` data = Map[ msBBGgetHistory[# <> " Index", "Px_Last", {1997, 1, 1}, "", "Monthly"] &, indices]; ```

`DateListPlot[data, PlotStyle -> {Red, Blue, Purple}, PlotRange -> {1.1, 6.4}, Frame -> {True, True, False, False}, PlotLabel -> "Global Big Mac Prices (USD)", Epilog -> {(Text[Style["U.S.", FontFamily -> "Calibri", FontSize -> 10, Red], {{2007, 1, 10, 16}, 3.4}]), (Text[Style["Brazil", FontFamily -> "Calibri", FontSize -> 10, Blue], {{2007, 5, 10, 16}, 4}]), (Text[Style["Mexico", FontFamily -> "Calibri", FontSize -> 10, Purple], {{2007, 1, 10, 16}, 2.3}])}, ImageSize -> Large];`

# New release of the Bloomberg-to-Mathematica link

Those who use Bloomberg and Mathematica should find this useful. This interface allows the direct loading of Bloomberg data (historical prices, bulk data like dividends, current data like stock prices, etc.) into Mathematica. I’ve made the interface freely available since 2008, but this release represents the largest changes in over six years. Most importantly, it can now handle bulk data like current holders of a security and historical dividends, and it’s much more robust about errors.

Historically I’ve thrown source code in the .zip file with the binaries but starting with this release, the source code and the binaries will be in separate GitHub repositories. See https://github.com/MichaelSternNYC for everything. If you just want to install the links, check out https://github.com/MichaelSternNYC/bloomberg-to-mathematica in particular.

``` histLink = msBBGgetHistoryMakeLinkObject[];```

``` ```

```x1 = msBBGgetHistory["IBM US Equity", "Px_Last", {2014, 1, 1}, "", "Day", "use DPDF" -> False, LinkObject -> histLink]; x2 = msBBGgetHistory["IBM US Equity", "Px_Last", {2014, 1, 1}, "", "Day", "use DPDF" -> True, LinkObject -> histLink]; DateListPlot[{x1, x2}, PlotStyle -> {Orange, Purple}, PlotLabel -> "IBM Stock Price via the new interface", ImageSize -> Large, Epilog -> {(Text[ Style["not dividend-adjusted", FontFamily -> "Times New Roman", FontSize -> 10, Orange], {{2015, 1, 22}, 169}]), (Text[Style["dividend-adjusted", FontFamily -> "Times New Roman", FontSize -> 10, Purple], {{2015, 1, 22}, 140}]) }]```