Question for quants, math geeks - reducing volatility in my costs?

Discuss all general (i.e. non-personal) investing questions and issues, investing news, and theory.
Locked
jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sat Apr 29, 2017 11:58 am

Hi,

Theoretical question here for any quants, math geeks or analytical wiz out there...
I buy a product in large quantities monthly (whose price in very volatile but I have been tracking it for years). It is a very large percent of my total costs.
Quantitatively, how can I find a basket of tradable securities (or commodities) that behave similar or identical to my product costs? If I have that, I can potentially trade options or futures to minimize my risks or have less volatility. Correlations and Regression?
Any pointers to techniques, research papers? Or even what terminology is used so I can Google this? I am guessing hedge funds, investment banks, etc must be doing stuff like this and more. I tried searching for hedging, risk management, etc but couldn't find what I was looking for.

Thanks!

EHEngineer
Posts: 713
Joined: Sat Feb 28, 2015 4:35 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by EHEngineer » Sat Apr 29, 2017 12:56 pm

What is the product? Gasoline?
Or, you can ... decline to let me, a stranger on the Internet, egg you on to an exercise in time-wasting, and you could say "I'm probably OK and I don't care about it that much." -Nisiprius

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sat Apr 29, 2017 2:06 pm

EHEngineer wrote:What is the product? Gasoline?
No, not gasoline. Gasoline has futures and other instruments that are traded. This one does not. For my business.
I am interested in the mathematical approach. It isn't as much about the specific product. I can find a bunch of securities and commodities that are correlated to it, but how do I go beyond that mathematically to find the mix?

EHEngineer
Posts: 713
Joined: Sat Feb 28, 2015 4:35 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by EHEngineer » Sat Apr 29, 2017 2:10 pm

jane1 wrote:
EHEngineer wrote:What is the product? Gasoline?
No, not gasoline. Gasoline has futures and other instruments that are traded. This one does not. For my business.
I am interested in the mathematical approach. It isn't as much about the specific product. I can find a bunch of securities and commodities that are correlated to it, but how do I go beyond that mathematically to find the mix?
The garden variety math tool for modeling is multiple linear regression. many software packages will do it. Matlab is super easy. Octave is a free option. Excel used to have a "data analysis toolkit" you could work with, but its no longer included in the version I have (was in Tools -> Add-ins -> Data Analysis Toolkit) If you need to learn MLR, check out http://www.coursera.org for free video classes.
Or, you can ... decline to let me, a stranger on the Internet, egg you on to an exercise in time-wasting, and you could say "I'm probably OK and I don't care about it that much." -Nisiprius

farnsy
Posts: 89
Joined: Tue Dec 15, 2015 8:49 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by farnsy » Sat Apr 29, 2017 3:36 pm

You can get as fancy as you want on this one. In pretty much every case, linear regression is going to be your basic tool.

Put the returns you are trying to hedge on the left hand side of the regression and the asset(s) you want to use as hedges on the right. The position you will take in each hedging asset is the negative of the coefficient on that asset times the dollar exposure you have to the thing you are trying to hedge against. You can use R^2 as an in-sample measure of how much of the risk you are getting rid of.

You will want to spend some time backtesting this, though. Regression betas of this type change over time. If you find that a beta estimated on data from two years ago doesn't hedge the risk over the past year very well, then the relationship may not be stable enough to make a good hedge. Good luck.

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sat Apr 29, 2017 4:11 pm

EHEngineer wrote:
jane1 wrote:
EHEngineer wrote:What is the product? Gasoline?
No, not gasoline. Gasoline has futures and other instruments that are traded. This one does not. For my business.
I am interested in the mathematical approach. It isn't as much about the specific product. I can find a bunch of securities and commodities that are correlated to it, but how do I go beyond that mathematically to find the mix?
The garden variety math tool for modeling is multiple linear regression. many software packages will do it. Matlab is super easy. Octave is a free option. Excel used to have a "data analysis toolkit" you could work with, but its no longer included in the version I have (was in Tools -> Add-ins -> Data Analysis Toolkit) If you need to learn MLR, check out http://www.coursera.org for free video classes.
Thanks! I was thinking Multiple Linear Regression too. Will give it a try as soon as I identify a bunch of securities/commodities that might have decent correlation with my cost data. I can use R or Excel.
Are Random Forest, ARIMA-X type techniques used for such things that you are aware of?

EHEngineer
Posts: 713
Joined: Sat Feb 28, 2015 4:35 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by EHEngineer » Sat Apr 29, 2017 4:20 pm

jane1 wrote:Are Random Forest, ARIMA-X type techniques used for such things that you are aware of?
Gosh, you are over my head already. A few months back I was hoping to learn R, and this book was recommended to me. Maybe it can help you.
Download the PDF here (free): http://www-bcf.usc.edu/~gareth/ISL/index.html
physical version at amazon: https://www.amazon.com/Introduction-Sta ... 1461471370
Or, you can ... decline to let me, a stranger on the Internet, egg you on to an exercise in time-wasting, and you could say "I'm probably OK and I don't care about it that much." -Nisiprius

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sat Apr 29, 2017 4:30 pm

farnsy wrote:You can get as fancy as you want on this one. In pretty much every case, linear regression is going to be your basic tool.

Put the returns you are trying to hedge on the left hand side of the regression and the asset(s) you want to use as hedges on the right. The position you will take in each hedging asset is the negative of the coefficient on that asset times the dollar exposure you have to the thing you are trying to hedge against. You can use R^2 as an in-sample measure of how much of the risk you are getting rid of.

You will want to spend some time backtesting this, though. Regression betas of this type change over time. If you find that a beta estimated on data from two years ago doesn't hedge the risk over the past year very well, then the relationship may not be stable enough to make a good hedge. Good luck.
Thanks! Very helpful. Will give it a try. You mentioned Linear Regression as the basic tool. What advanced techniques may be better? I am happy to learn if you can point to some decent references. For instance if I find that
Price of Product P = 0.3* SPY + 0.4*Oil Index + 0.1*AMZN - 1.1*Industrials Index
gives me satisfactory results for extended time and backtesting. Should I short/long on these or use options/futures? Again all theoretically. I won't rush into anything without understanding!
How are some of the derivatives types instruments created that might have an inverse relationship without as much cash investment to take opposite positions?

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sat Apr 29, 2017 4:39 pm

EHEngineer wrote:
jane1 wrote:Are Random Forest, ARIMA-X type techniques used for such things that you are aware of?
Gosh, you are over my head already. A few months back I was hoping to learn R, and this book was recommended to me. Maybe it can help you.
Download the PDF here (free): http://www-bcf.usc.edu/~gareth/ISL/index.html
physical version at amazon: https://www.amazon.com/Introduction-Sta ... 1461471370
I have the book - PDF and hard copy! Would strongly recommend their videos too.
https://www.r-bloggers.com/in-depth-int ... rt-videos/
I am kind of theoretically familiar with various techniques. Hoping to figure out which tool in my kit is typically used for such situations and gives best results. Any references for techniques used by quants for these kinds of problems. You gave a good idea, I will try some amazon searches (so far been doing google searches).

qwertyjazz
Posts: 1079
Joined: Tue Feb 23, 2016 4:24 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by qwertyjazz » Sat Apr 29, 2017 5:15 pm

You can use any of the model types you like. The biggest question though is the robustness of your model to predict out of sample results. All models have assumptions about the nature of the data which are approximations of reality. But the underlying problem is minus theory you are likely to find multiple sperious relationships due to testing thousands of things. (Multiple testing) You would to make sure what ever you found in a sample works in a different one. (Split samples)
You might want to be more explicit on what you are trying to model and try posting on stack exchange or another place where statisticians hang out.
Good luck
G.E. Box "All models are wrong, but some are useful."

avalpert
Posts: 6313
Joined: Sat Mar 22, 2008 4:58 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by avalpert » Sat Apr 29, 2017 8:36 pm

I've been paid more than I deserved to build models like this for different situations (like workforce models that predict the needed size and distribution of employees for given projects). In my experience, more often than not, you end up overfitting the data to get to a comfortable r^2 that you can defend with a narrative that is acceptable but not really true and then act all surprised when the forecasted relationships don't hold. With a workforce model it probably doesn't matter much - it becomes a self-fulfilling prophecy since you assign the resource the model spits out and they find a way to get the job done - for you it could set you up for a nasty surprise at just the wrong time.

I have no doubt you could find a basket that backtests well and even works out of sample somewhere - I would be wary of taking on too much financial risk using that basket. You might have better luck talking to reinsurers and see what it would cost to create price protection that way.

mccannr
Posts: 22
Joined: Mon Sep 05, 2016 10:54 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by mccannr » Sat Apr 29, 2017 10:42 pm

Totally agree with post giving caution to this.

That said, to do what you're proposing, here's how you could pursue.

First consider the data you have on your 'product.' Do you have prices for every day? Can you get data going back even further in time? The more, the better. Put dates in one column and prices in corresponding column in something like excel.

Then gather a bunch of other variables that you think are candidates for having the desired relationship to the product. Get data on price and dates corresponding to the data you have on the initial product. Create columns for these, too.

Now you have a data set to work with, and even in excel can do a lot of damage. You can simply run correlation coefficients and see what's related and to what extent. You can then model multiples variables together to see how much each additional fund or what have you adds to the variance explained by a given model. E.g., say I have 30 variables that I'm considering as being related to the one question. I could add one at a time to a multiple regression model and see what additional variance is accounted for by each additional variable. Find what is best and the point of diminished returns. This could help minimize the number of funds or what have you that you'd need to hold to get the desired result.

Keep in mind, you could do this, get an incredible amount of variance explained, and it still can go to heck because the model is built on past data. I get why you're wondering about this though.

afan
Posts: 3840
Joined: Sun Jul 25, 2010 4:01 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by afan » Sun Apr 30, 2017 9:01 am

Be careful about costs. For any financial products you use for hedging there will be spreads and transaction costs that could be substantial, particularly if your strategy involves much trading. Also, consider that for commodities the spot prices you may find in historical data may not reflect the actual prices at which you would buy or sell in real life.

Frankly, this sounds like a fun exercise but extremely risky to do for real.
We don't know how to beat the market on a risk-adjusted basis, and we don't know anyone that does know either | --Swedroe | We assume that markets are efficient, that prices are right | --Fama

Theoretical
Posts: 1422
Joined: Tue Aug 19, 2014 10:09 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by Theoretical » Sun Apr 30, 2017 10:59 am

Honestly, this sounds like something where you should consult a business consultant and a specialist financial consultant to evaluate what is and is not an appropriate hedging vehicle. Since it's not a readily traded commodity, I think you're very likely to do more harm than good by only DIY'ing it. By all means educate yourself first, but this can easily be treacherous ground.

Phil DeMuth
Posts: 131
Joined: Thu Mar 06, 2008 7:02 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by Phil DeMuth » Sun Apr 30, 2017 11:30 am

"With four parameters I can fit an elephant, and with five I can make him wiggle his trunk." - John von Neumann

alex_686
Posts: 3847
Joined: Mon Feb 09, 2015 2:39 pm

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by alex_686 » Sun Apr 30, 2017 2:03 pm

jane1 wrote:
EHEngineer wrote:
jane1 wrote:Are Random Forest, ARIMA-X type techniques used for such things that you are aware of?
Gosh, you are over my head already. A few months back I was hoping to learn R, and this book was recommended to me. Maybe it can help you.
Download the PDF here (free): http://www-bcf.usc.edu/~gareth/ISL/index.html
physical version at amazon: https://www.amazon.com/Introduction-Sta ... 1461471370
I have the book - PDF and hard copy! Would strongly recommend their videos too.
https://www.r-bloggers.com/in-depth-int ... rt-videos/
I am kind of theoretically familiar with various techniques. Hoping to figure out which tool in my kit is typically used for such situations and gives best results. Any references for techniques used by quants for these kinds of problems. You gave a good idea, I will try some amazon searches (so far been doing google searches).
I am starting to learn R. Are there any good packages out there with financial data? Specially anything with total return indexes. Or any other packages out there that people have found useful?

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sun Apr 30, 2017 3:07 pm

alex_686 wrote: I am starting to learn R. Are there any good packages out there with financial data? Specially anything with total return indexes. Or any other packages out there that people have found useful?
I am discovering too, just installed yesterday... I have come across Quandl, Quantmod and Thinknum which seem decent for financial data downloads and some analysis.
https://www.r-bloggers.com/financial-da ... -part-iii/
For Correlations I like the visualizations that corrplot offers. Don't know about total return indices.

jane1
Posts: 735
Joined: Mon Dec 26, 2011 2:00 am

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by jane1 » Sun Apr 30, 2017 3:20 pm

afan wrote:Be careful about costs. For any financial products you use for hedging there will be spreads and transaction costs that could be substantial, particularly if your strategy involves much trading. Also, consider that for commodities the spot prices you may find in historical data may not reflect the actual prices at which you would buy or sell in real life.

Frankly, this sounds like a fun exercise but extremely risky to do for real.
You hit the nail on the head.
Yes, the cost of hedging may be substantial.
If actual prices can be very different from spot prices, how can one reconcile this?

And the other issue is, whether futures and options actually do a good enough job of gauging the direction of the security/commodity. Even with hedging, one is (to some extent albeit smaller extent) betting on the direction. It would be interesting to see how, for instance, SPY options pricing was correlated to actual SPY performance over time. Although I am not sure what I mean by this :confused

User avatar
LadyGeek
Site Admin
Posts: 48024
Joined: Sat Dec 20, 2008 5:34 pm
Location: Philadelphia
Contact:

Re: Question for quants, math geeks - reducing volatility in my costs?

Post by LadyGeek » Sun Apr 30, 2017 3:33 pm

This thread has run its course and is locked (product costs are not relevant to personal investing). See: Investing - Theory, News & General
If it's investment related and it doesn't fall into the above category it goes here. Examples of acceptable topics include news about new fund offerings, pointers to academic papers about investing issues, questions about the proper role of a particular asset class in a portfolio, or questions about Vanguard policies.
jane1 wrote:
EHEngineer wrote:What is the product? Gasoline?
No, not gasoline. Gasoline has futures and other instruments that are traded. This one does not. For my business.
I am interested in the mathematical approach. It isn't as much about the specific product. I can find a bunch of securities and commodities that are correlated to it, but how do I go beyond that mathematically to find the mix?
Additionally, this forum is for use by personal investors only. Requesting assistance to further one's business interests is off-topic.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.

Locked