7

When you sample stock market data, you really need to understand what source(s) and rules are being used, and any adjustments applied to the data. Different rules might also exist for different periodicities sampled too. There are may different/methodologies applied to Consolidated tape price versus listed exchange price versus a specific exchange price. ...


3

You need to get the open of the first candle, the high and low over all candles in the time frame and the close of the last candle. R has a package for this, your language of choice might have it as well.


2

In R, the simplest way to brute force through a predefined number of portfolio combinations would be to simply iterate over them: set.seed(42) returns <- matrix(rnorm(200),40,5) weights <- list(c(1,0,0,0,0), c(0,1,0,0,0), c(0,0,1,0,0), c(0,0,0,1,0), c(0,0,0,0,1)) conf <- 0.99 sapply(...


2

I will write some pseudocode. N = 10 /* number of orders */ prices = [100, 108.01, 116.65, 125.99, 136.08, 146.97, 158.74, 171.45, 185.17, 200.0] /* these are the given prices */ ones = [1,1,1,1,1,1,1,1,1,1] /* N ones */ staircase = [0,1,2,3,4,5,6,7,8,9] /* starts at 0 and counts up by 1 until N-1 */ desired_avg_price = 135 avg_price_eqweighted = AVERAGE(...


2

Try casting, something like c = as_coupon(cf) if not c.__nonzero__(): print "principal redemption" You can likewise attempt casting the cf to as_fixed_rate_coupon(cf) or to as_floating_rate_coupon(cf), and if they work, then access other useful info. Also, redemptions is another available inspector. Related question: how can i see the ...


1

The fair rate calculated in the above example is the rate to be used for fixed rate leg to yield 0 NPV. You would need to reconstruct the swap with the float leg as is but a fixed leg with fair rate from above. That should yield a 0 NPV for the swap.


1

backtrader's Data Replay feature, does exactly what I was looking for. So, all you need to do is the following: Create a CSV data file with 1min timeframe. Load the data into a CSV data feed of backtrader. Pass the data feed to cerebro (backtrader's engine) with replaydata utility. Finally, add a strategy and other steps. A code example to use replaydata ...


Only top voted, non community-wiki answers of a minimum length are eligible