instruction
stringlengths
15
26.1k
I apologize for my persistence, i'm on a course of study and doubts increase every day. My goal is "just" to code a profitable forex trading strategy with machine learning. I'm trying to implement de Prado's techniques with time bars (ticks are expensive and require strong hardware) but it seems a mess. These are th...
I have cash inflows and cash outflows for a 7 year period and my MIRR and inflation rate. That's all the information I have. How do I calculation the IRR taking the inflation rate into account in Excel ?
I am trying to simulate commodity prices using the exponential Vasicek/Ornstein-Uhlenbeck model from [Schwartz 1997][1] p. 926 Equation (1). I am using the closed form solution from [Vega 2018][2] p. 5 Equation (9) which is: $$\ln(X_{t})=\ln(X_{t-1})e^{-\theta \Delta t}+\left(\mu-\frac{\sigma^2}{2\theta}\right)(1-e^...
I am aware that there exist several libraries and programs that allow to baktest a portfolio strategy by iterating through the OHLC dataframe of the stocks of interest (Backtrader, Backtesting, ...). However, these methods are useful when we are working on one or few stocks: when it comes to backtest a strategy that in...
In addition to Dimitri's comment and user35980's answer above, the following comes to mind: so much USD has been printed by the FED already and now with Democratic majority likely, more fiscal stimulus and even more FED balance sheet expansion is being priced in over the past few days. Because the market is awash w...
This should be easy, but for some reason I am struggling with it. Say you have a long position in the money market (you hold dollars), say you own a quantity of $Ke^{-r(T-t)}$ dollars at time $t$, where $K$ is some positive real number, $T$ is some future time $>t$ and $r>0$ is the risk-free interest rate earned by ...
AAPL.O maps to AAPL US Equity (composite) or AAPL UW Equity ( Nasdaq NSM) thats stright common stock but what about preferred stock ? HWM_p.A maps to EP051790@SAM2 Pf or Unit trust ? PHGE_u.A maps to PHGE/U UA Equity or exchanges where Refintiv dont use the exchnage symbol FEDq.L maps to FEDS LI Equity ...
How to show that a Brownian motion is normally distributed and that the covariance is zero?
I'm looking to do a Brinson performance attribution on a portfolio of stocks where instead of decomposing the returns in terms of sectors we use factors instead. Basically, I want to do what Style Analytics claims to do in their Factor Attribution module: https://www.styleanalytics.com/solutions/overview/#factor-re...
After reading papers on reinforcement learning with respect to the problem of optimal execution (Nevmyvaka et al (2006), Ning et al (2018), etc), I was wondering if the Markov property assumed in all these papers is rational? Has there been at least an empirical comparison/paper detailing tradeoffs & performance of non...
I implemented the Hull White one factor model in Monte Carlo simulation, and got the short rate on each node (time step =1month). my question is how to get the forward rate from the short rate? I am using the formula for zero coupon bond P(t,T)=A(t,T)*EXP(−B(t,T)*rt) (J.Hull's book), P(t,T) can be the discount factor...
how to get 3 month Forward rates from Hull white model simulation?
I'm trying to replicate the following FX vanilla option pricing exercise (and the conversion between the quote types), taken from Wystup (2006). [![enter image description here][1]][1] A call's value today is well-known given by BS / Garman-Kohlhagen formula: [![enter image description here][2]][2] This is ...
In portfolio theory, I often (with some justifications but the message is the same) come across the following statement: *"The most important quality of portfolio variance is that its value is a weighted combination of the individual variances of each of the assets adjusted by their covariances. **This means that t...
[![enter image description here][1]][1] Why is the second green candle stick green? Given that its closing price is less than the previous candlestick's closing price, shouldn't it be orange? [1]: https://i.stack.imgur.com/T2Bhh.png Source: coninbase 1m chart for ethereum: https://pro.coinbase.com/trad...
I'm trying to build a model that values futures for equity indicies like SPX. For example, this product [link here.][1] I know that the model is simple (please correct me if I'm wrong): $$ S_{T} =S_{0}e^{(r-d)(t-T)} $$ where $r$ is the risk-free rate, $d$ is the dividend yield/equity repo/cost of carry, $S_0$ ...
Which exact interest rate should I use for valuing equity index futures (ie. SPX, MXEA)?
Consider the following initial-boundary value problem for $u = u(x,t),$ $$u_t - a u _{xx} = f(x,t) \text { for } 0 < x < L \text { and } 0 < t< T$$ along with bunch of initial and boundary conditions. If we want to employ finite difference method to solve the above parabolic problem in 1D, then under explicit Eul...
Consider the following initial-boundary value problem for $u = u(x,t),$ $$u_t - a u _{xx} = f(x,t) \text { for } 0 < x < L \text { and } 0 < t< T$$ along with bunch of initial and boundary conditions. If we want to employ finite difference method to solve the above parabolic problem in 1D, then under explicit Eul...
Consider the following initial-boundary value problem for $u = u(x,t),$ $$u_t - a u _{xx} = f(x,t) \text { for } 0 < x < L \text { and } 0 < t< T$$ along with bunch of initial and boundary conditions. If we want to employ finite difference method to solve the above parabolic problem in 1D, then under explicit Eul...
My trading returns is about 50% monthly(alpha) and maximum drawdown is about 20%. Is there a mathematical way to define the optimal withdrawal rate X%(say when profit level reach y%) to avoid risk of 50% ruin? i.e. how to find X% & y% for the best balance between risk vs compounding rate? For e.g, withdrawing 50% of m...
In my exercise, I take out a 240,000€ mortgage from a bank which I pay off over a period of 30 years. The interest rate is a market index plus a spread. Initally the market index is 1% and the spread is 0.99%. After 1 year the market spread rises 0.10% and continuously does so until the last year, where my market index...
My trading returns is about 50% monthly(alpha) and maximum drawdown is about 20%. Is there a mathematical way to define the optimal withdrawal rate X%(say when profit level reach y%) to avoid risk of 50% ruin? i.e. how to find X% & y% for the best balance between risk vs compounding rate? For e.g, withdrawing 50% of m...
I have all the CIKs and relative tickers of all the traded securities that I need (https://www.sec.gov/include/ticker.txt). My question is: **How do I find the stock exchange that a gives security is traded in, given any CIK?** (I am looking for an official data source for this, possibly sec.gov) I found some oth...
Find the stock exchanges a security is traded in given a CIK?
I have all the CIKs and relative tickers of all the traded securities that I need (https://www.sec.gov/include/ticker.txt). My question is: **How do I find the stock exchange that a gives security is traded in, given any CIK?** (I am looking for an official data source for this, possibly the sec.gov website) I fo...
I've put aside 1000 EUR for trading strategy test. Made number of trades where each position was worth 5 EUR. At any moment there was invested from 0 to 80 EUR. Entered all cashflows to XIRR function and it shows 0,14. What does it mean? I suppose it means 14% return from some sum over some period. I assume the period ...
What does XIRR show?
I have a task to do but it is very difficult.. I have to calculate the: 1. Delta Sensitivity analytically, that is the first derivative of caplet price wrt the forward rate, using the black model to price a generic caplet 2. Delta Vega analytically, that is the first derivative of caplet price wrt the volatilit...
I understand while equity derivatives require the modelling of stock price at expiry, interest rate derivatives typically require modeling both the expiry and tenor, thus increasing the dimensionality of the underlying factors by one. Other than the modeling/ calibration of the yield curve, what are the other challenge...
What makes modeling interest rate derivatives very difficult compared to equity derivatives?
I've put aside 1000 EUR for trading strategy test. Made number of trades where each position was worth 5 EUR. At any moment there was invested from 0 to 80 EUR. Entered all cashflows to XIRR function and it shows 0,14. What does it mean? I suppose it means 14% return from some sum over some period. I assume the period ...
I've put aside 1000 EUR for trading strategy test. Made number of trades where each position was worth 5 EUR. At any moment there was invested from 0 to 80 EUR. Entered all cashflows to XIRR function and it shows 0,14. What does it mean? I suppose it means 14% return from some sum over some period. I assume the period ...
In its simplest form, for a series of irregular and/or intermittent cashflows that defy description in traditional terms (like bond coupons, dividends, etc.)... XIRR tells you "what interest rate would a bank have to offer to give me the same end result, given all the same cashflows at the same times?". The imp...
Could someone please explain why certain Cross currency pairs like EURUSD or GBPUSD show higher bids then offers in Bloomberg? e.g for a 5y GBP/USD Xccy Swap bids could be at -5 bps and the offer at -5.5bps. This seems very counter-intuitive. Any response would be greatly appreciated.
Cross Currency Swap Bids and Offers?
In Hull's book (9th edition), on pages 202-203, there is an example for computing the payoff of an OIS that I am confused about. It says suppose in a US 3-month OIS the notional principal is \$100 million and the fixed rate (i.e. the OIS rate) is 3% per annum. If the geometric average of overnight effective federal fun...
When it comes to return on investment, there are two dimensions one needs to consider - time and risk. The kind of questions we want an answer for is: for an investment such that I expect payout in this amount of time with these kinds of risks, what kind of return should I expect, or what kind of return does the market...
I am currently developing a software that needs to store stock prices and the amount of stocks (sold/purchased) of a given company. Now I am wondering which data types I need to use to store this data. The issue I have with that is that I don't know which numbers (how many decimals) can occur: 1. Is there any stand...
Are there any standards for the precision of stocks prices, amount of stocks etc.?
**Giving my 2 cents on your questions:** I believe the amount of decimal places is dependent on (the exchange and) the type of financial product. However, an [Investopedia article](https://www.investopedia.com/terms/d/decimal-trading.asp) writes: > In 2005, the Securities and Exchange Commission introduced Rule 612...
In Hull's book (9th edition), on page 83, there is a simple example of par yield: [![par yield example][1]][1] [1]: https://i.stack.imgur.com/iF2mX.png I am a bit confused when it says "this has semiannual compounding because payments are assumed to be made every 6 months. With continuous compounding, the...
I'm currently reading through Analysis of Financial Time Series by Ruey Tsay. The AR model is introduced in chapter 2 and its properties in 2.4.1. The difference equations are explained and then its stated (for an AR(2)) that if $\phi^2_1 - 4\phi_2 <0$, a complex conjugate pair exists. The average length of the stoch...
I am interested in deeply understanding the way ETF market makers operate to profit. I already know that market makers profit from buying at the bid price and selling at the ask price, and I am also aware of the creation/redemption mechanism that allows them to make a profit if the ETF value deviates too much from th...
For **market practitioners** such as swap traders out there: in your experience, does the below clause when ***bilateral*** is similar to a difference between `European` and `American` exercise on a vanilla option? Asking in the context of a TRS contract (either equity or fixed income). In other words, does it th...
A database only has transactions/trades for a given instrument. In order to recreate bid-ask of the instrument to estimate the average bid-ask spread, what process does one need to follow? what are the various assumptions involved. have not found anything concrete.
I'm working on a data that deals with start-up/similar companies data. A lot of the companies have negative P/E and/or little to no sales. Is there good ways to create meaningful data (like averages, medians) from this? I obviously should not use negative values in calculations, since low P/E is meant be a positive...
Best way to treat negative P/E and extremely high P/S in data?
For tickerized portfolios, I want to extract Sharpe ratios and historic volatilities per annum or for 1, 3, 5 years from Bloomberg. So far, I have been using [BBG V3COM API wrapper][1] to extract historical prices and performances for my portfolios. Now I want to add risk measures and implement these into my existing a...
For tickerized portfolios in `PRTU`, I want to extract Sharpe ratios and historic volatilities per annum or for 1, 3, 5 years from Bloomberg. So far, I have been using [BBG V3COM API wrapper][1] to extract historical prices and performances for my portfolios. Now I want to add risk measures and implement these into my ...
What would be the best money management strategy if I know that approximately every 3rd trade is profitable. What is the best MM strategy?
If we consider the CRR-model in two periods, i.e. T=2. Let $S^1$ be the risky asset with $S_0^1=100$ and $S^0$ the bond with $S_0^0=1$. Furthermore, we assume the model is arbitrage-free with $y_b=-0.1<r=0.05<y_g=0.2$. Therefore, an unique equivalent martingale measure $Q$ exists with $Q(\lbrace\omega\rbrace) =0.5^{Z_1...
What's the price of a lookback call option in the arbitrage-free CRR-model?
I'm pretty new to trading, and I couldn't really find anything helpful online. Say I want to buy a stock for a maximum of 21 USD per share. However, if the price hits 21, I don't want my order to fill instantly and instead want my order to trail down with the price **if** the price keeps going down past 21, and then fi...
What BUY order type should I use if I have a limit price in mind, but I still want to capture best price if it goes below my limit?
I have the following well-known formula for Fama and French's three-factor model $ R_{it}-R_{ft}=\alpha_i+\beta_{i1}(R_{m,t}-R_{f,t})+\beta_{i2}SMB_t+\beta_{i3}HML_t+\epsilon_{it}$. My question is: Why do we not take the size (market capitalization) of the firm itself instead of constructing a risk factor ba...
I have the following portfolio of all ETFs: [![enter image description here][1]][1] I am attempting to apply Black Litterman and on the step of calculating market weights. I have the following questions: 1. How can I define what index to use as a benchmark? ( Is it the average of all index tracked? and...
How do a find an index to track my portfolio of all etfs?
I have the following portfolio of all ETFs: [![enter image description here][1]][1] I am attempting to apply Black Litterman and on the step of calculating market weights. I have the following questions: 1. How can I define what index to use as a benchmark? ( Is it the average of all index tracked? and...
I have the following portfolio of all ETFs: [![enter image description here][1]][1] I am attempting to apply Black Litterman and on the step of calculating market weights. I have the following questions: 1. How can I define what index to use as a benchmark? ( Is it the average of all index tracked? and...
It's said the theoretical aim of the ECB Two-tier system (exempt a portion of the excess reserves from negative rates) was designed to: 1) offset the direct costs of negative interest rates on banks, thereby helping to sustain the pass-through of low policy rates to bank lending rates 2) push banks to trade...
It's said the theoretical aim of the [ECB Two-tier system][1] (exempt a portion of the excess reserves from negative rates) was designed to: 1) offset the direct costs of negative interest rates on banks, thereby helping to sustain the pass-through of low policy rates to bank lending rates 2) push banks to ...
I am working with the eigenvector centrality of a minimum spanning tree, which can be calculated as: ```v(i) = lambda^-1 * sum[Omega(i,j)*v(j)] ``` where: - ```v(i)``` is the eigenvector centrality of the node i-th - ```Omega``` is an adjacency matrix (square) - ```lambda``` is the biggest eigenvalue of the ...
How do I find the value of bonds with continuous coupon yields and interest rates that are both a function of time?
**Heston model** is a stochastic volatility extension of the Black-Scholes model. On the other hand, there is also closed-form expression for option pricing that uses **GARCH stochastic volatility model**. Which model to use for option pricing? I guess there is no clear cut answer, but still, what are the criteria ...
How do I find the value of bonds with continuous coupon yields and interest rates that are both a function of time? The bond has a redemption of 2000 at time $t=2$ and pays continuous coupon payments of $K(t)=100e^{-t}$. The spot interest rate is $r(t)=\frac{2}{50-t}$.
To echo on @Dimitri Vulis comment on your question, this kind of bond structure is rather *contrived*, but nevertheless let me try to give you some starting pointers. I am assuming that your interest rate is a zero rate, i.e. the discount factor for time t equals $D(t)=e^{-r(t)t}$. Then the present value fo the bond...
I am trying to implement a code that uses Kalman filter to improve the performance of traditional style analysis. I have come across a paper called "Return based style analysis with time varying exposures" which has proved to be quite helpful. I have read some chapter from various book on the Kalman filter and now I ha...
My data has stock returns over n periods for x stocks and m factor exposures for each stock ( ex: value, momentum) for n periods(output of regressions ) . Can I club this data together and then compute the correlation matrix (x by x matrix) and then run pca Do I need to standardize each data set separately ( returns a...
I am quite new to studying finance so apologies if this turns out to be a trivial question. I am writing my first essay where I want to test a value strategy from 2009-2019 by yearly ranking of the stocks by their P/CF ratio, forming 5 portfolios, evaluating their performance. Regarding survivorship bias, I understa...
eqI am very confused about a very basic question. This is probably more statistics than quantitative finance, but still, should be useful for this stackexchange board as well. Let's assume I have monthly returns $r_1, r_2, ...., r_T$. I can compute average return and standard deviation as: \begin{equation} ...
I thought about it and think that in this case it does not really matter how $f$ looks exactly, because $f(S_2^1(\omega ))=\gamma (\omega)$ should be true. Then, with the formular for the equivalent risk-neutral measure $Q$ given above we can compute the probabilities $Q((0,0))=Q((1,0))=Q((0,1))=Q((1,1))=0.25$. Further...
Often no pre-made dataset exists when you have such specific requirements. **Therefore, you have to find your own data by searching for penny-stocks that matches your criteria. This can be done via a stock-screener**. Doing a quick google search on "Gap-up stock screener" I found [this website](https://www.barchart.com...
I am trying to implement a code that uses Kalman filter to improve the performance of traditional style analysis. I have come across a paper called "Return based style analysis with time varying exposures" (can be found [here](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=291640)) which has proved to be quite hel...
I'm struggling to understand the end-of-month option embedded in Treasury Futures. Specifically, I'm looking at what would happen to CTD when yields rise or fall. What are the main differences between the end-of-month option and the switch option before the end of trading for treasury futures? I read in [Burghar...
What quantifiable factors contribute to the globalization of a currency?
From what I understand the only entity that controls M1 in US is the Federal Reserve. Is it true that M2-M1( M2 minus M1; the part of M2 that is NOT in M1 like timed deposits) is controlled by the commercial banks?
The Capital Asset Pricing Model (CAPM) model states that, on efficient market, expected return of an asset should be given by a linear function of its volatility (as measure by standard deviation of returns). $ avg(R_i) = R_f + \beta_i \cdot (R_m - R_f), $ where $\beta_i$ is the asset "beta" (which measure "ris...
What mechanisms does the market use to brining an asset back to the market line, as defined by CAPM?
The Capital Asset Pricing Model (CAPM) model states that, on efficient market, expected return of an asset should be given by a linear function of its volatility (as measure by standard deviation of returns). $ avg(R_i) = R_f + \beta_i \cdot (R_m - R_f), $ where $\beta_i$ is the asset "beta" (which measure "ris...
From what I understand the only entity that controls M1 in US is the Federal Reserve. Is it true that M2-M1( M2 minus M1; the part of M2 that is NOT in M1 like timed deposits) is controlled by the commercial banks? **Edit** (by JS): I think the question is of interest and of importance in current market condition...
What drives the difference between M1 & M2 money supply (in the US)?
If we consider the CRR-model in two periods, i.e. T=2. Let $S^1$ be the risky asset with $S_0^1=100$ and $S^0$ the bond with $S_0^0=1$. Furthermore, we assume the model is arbitrage-free with $y_b=-0.1<r=0.05<y_g=0.2$. Therefore, an unique equivalent martingale measure $\mathbb{Q}$ exists with $$\mathbb{Q}(\lbrace\omeg...
I thought about it and think that in this case it does not really matter how $f$ looks exactly, because $f(S_2^1(\omega ))=\gamma (\omega)$ should be true. Then, with the formular for the equivalent risk-neutral measure $\mathbb{Q}$ given above we can compute the probabilities $Q((0,0))=Q((1,0))=Q((0,1))=Q((1,1))=0.25$...
Assume that dividend = 0, then the price of call option is $$ C = S\cdot P_{s}[S(T) > K] - e^{-rT}K\cdot P_F[S(T) > K] = SN(d_1)-e^{-rT}KN(d_2) $$ where $P_s[S(T) > K]$ = Probability of ITM when $S(t)$ is set to be a numeraire and $P_F[S(T) > K]$ = Prabability of ITM under Forward measure When $T \righ...
From what I understand the only entity that controls M1 in US is the Federal Reserve. Is it true that M2-M1( M2 minus M1; the part of M2 that is NOT in M1 like timed deposits) is controlled by the commercial banks? **Edit** (by JS): I think the question is of interest and of importance in current market condition...
1. The mode of the lognormal tends towards 0 when T increases, but the risk-neutral mean (assuming no dividends) is S0*exp(rT) which increases with time Then in Black Scholes, discounting cancels out the risk neutral drift of the stock (S0*exp(rT)*DF = S0) 2. Not sure I get the second point, could you please re-f...
What is a proper way to evaluate a backtested strategy if its trading asset has a strong trend?
Most large orders nowadays are done through TWAP or VWAP based order execution. For example, if Alice wants to sell $60 million in EURUSD she will break up her order into 50,000 tiny orders and then send them to the broker over the course of T time. Are there any papers/known methods in detecting such behaviour?
How do you detect order execution algorithms?
Suppose there are three assets, and the first asset has volatility 18%, the second asset has volatility 16%, and the third asset has volatility 16%. Suppose also that the first two assets' returns are correlated with each other with correlation coefficient 0.7, but the third asset is not correlated with the first t...
In the very long run, stock prices will diverge to infinity under the risk neutral measure and at the distribution will spread more and more. Thus, in the very long run, we will have $E(S(t)) \to \infty$ and the fraction of the cdf that covers the range $0\ldots X$ becomes smaller and smaller. Thus, a very (very)long ...
The assumption for calculating the roll of a fixed income instrument is that you roll down the current spot curve. So if 10y rate is 2% and 9.5y is 1.8% the carry for the coming 6 month horizon is 20bp. But why is it market practice to use rolling down the current spot curve? Why isn't the forward curve also used for t...
Carry & Roll, roll down current curve valid assumption?
This is in response to the part of your question that asks about M1 versus M2, although it seems you've more or less answered parts of your own question. M1 is the simplest monetary aggregate and includes items most widely used as a medium of exchange (approximately 85% of household purchases are made using M1 balances...
In the very long run, expected stock prices will diverge to infinity under the risk neutral measure and at the distribution will spread more and more. Thus, in the very long run, we will have $E(S(t)) \to \infty$ and the fraction of the cdf that covers the range $0\ldots X$ becomes smaller and smaller. Thus, a very (v...
You indeed seem to have an error in your calculation somewhere. Let the covariance matrix be $$\Sigma=\begin{pmatrix}0.0324&0.021016&0\\ 0.021016 & 0.0256 & 0 \\ 0 & 0 & 0.0256\end{pmatrix}$$ and the vector of (excess) returns are $$ \mu-r_f=\begin{pmatrix}0.05 \\ 0.02 \\ 0.03\end{pmatrix} $$ Ultimate...
I'm a student and i amm looking for a swaps rates historical data for long tenors in purpose to estimate yield curve (for example in GBP). My question is where could I find it?
What is the idea behind using Machine Learning in finance? Let's assume that we have just one instrument given by its prices. At a given moment of time, we can "compress" the available history of prices into a vector of features (for example, momentum, volatility, some other technical indicators). In addition to that w...
How to use machine learning to generate optimal allocations for an instrument?