Posts by RiskTech • 847 points
22 posts
-
1
votes1
answer56
viewsQ: String equivalent using variables - Python 3.x
What would be the string equivalent : values = """ { "exchange_code": "PLNX", "exchange_market": "BTC/USDT" } """ Which the result is : '\n { n "exchange_code": "PLNX", n "exchange_market":…
-
1
votes1
answer1118
viewsQ: Typeerror: POST data should be bytes, an iterable of bytes, or a file Object. It cannot be of type str
I’m trying to translate a code from Python 2.7 to 3.6 Code 2.7 works perfectly: from urllib2 import Request, urlopen values = """ { "exchange_code": "PLNX", "exchange_market": "BTC/USDT" } """…
-
7
votes2
answers87
viewsQ: Somatoria accumulating columns in a Matrix in R
I have the following situation : In a numeric type Matrix : Temp <- matrix(runif(25, 10, 100),nrow=5,ncol=5) V1 V2 V3 V4 V5 11 34 45 54 55 16 21 45 75 61 88 49 85 21 22 12 13 12 11 10 69 45 75 78…
-
4
votes2
answers305
viewsQ: Turn positive values into negative values in a data.frame based on one condition in another column (R)
I have the following date. :: df <- data.frame(Qtd=c(100,200,300,400,500), op=c('V','C','C','V','V'), stringsAsFactors=F) How I can turn the values in the Qtd column to negative if the op column…
-
16
votes2
answers7712
viewsQ: Search for values in one data.frame and add to another (R)
I have 2 data.frames, the first is a data.frame that contains stock data and a column with a unique identifier (column "ISIN"), as an example below: Teste=data.frame(matrix(runif(20), nrow=5,…
-
4
votes1
answer723
viewsQ: Apply a function using some columns of all rows of a Dataframe (r)
I have the following Dataframe : AVG_VOLUME AVG_RETURN VOL PRICE SPX Index 500000 0.01 0.08 2082 KR7000270009 6000 0.02 0.09 102 KR7005930003 7000 0.02 0.08 103 JP3266400005 8000 0.03 0.08 104…
-
3
votes0
answers380
views -
2
votes2
answers4561
viewsQ: Export data from an array to a table using VBA
In the Sheet1 i have a table only with the Header of each column but empty values, I run a VBA that creates an Array that has the same number of columns of the table. Is there any way to export all…
-
2
votes1
answer1606
viewsQ: Correlation Matrix in R (cov.wt)
In the cov.wt function in R it is possible to obtain as a result only the Correlation Matrix ? cov.wt = Returns a list containing estimates of the Weighted covariance Matrix and the Mean of the…
-
2
votes1
answer102
viewsQ: Return a Matrix that has all possible column multiplications of another Matrix (R)
Be a Matrix : bb=replicate(3, rnorm(3)) [,1] [,2] [,3] [1,] 0.5556358 1.6611142 0.2374830 [2,] -0.6672456 -0.5038430 0.9814712 [3,] -0.1391022 -1.2072500 -0.6219965 How can I return a second matrix…
-
1
votes3
answers517
viewsQ: Comparing matrices of different sizes in R
I have the following situation : all_sec = Matrix of all possible assets in a portfolio all_sec <- matrix(c("SEC1","SEC2","SEC3","SEC4","SEC5"),ncol=1) portfolio <- composition of a portfolio…
-
3
votes2
answers2857
viewsQ: Compare 2 Matrices and Return a Third (R)
The following matrices being Matrix(A) [,1] [,2] [,3] [,4] [,5] [1,] 0.228 0.285 0.285 0.285 0.380 [2,] 0.228 0.285 0.570 0.380 0.228 [3,] 0.380 0.285 0.228 0.380 0.285 [4,] 0.285 0.285 0.570 0.380…
-
2
votes1
answer250
viewsQ: Applying Loop to Elements of a Matrix (R)
Be the matrix below created from the Command simu_matrix <- matrix(runif(25,0,1),nrow=5,ncol=5) V1 V2 V3 V4 V5 1 0.07357303 0.45524021 0.9352829 0.60466424 0.4725541 2 0.51018615 0.46044203…
-
2
votes1
answer156
viewsA: EWMA volatility in a date.frame
Follow the code with the answer The second function variance.ewma receives a matrix with stock returns and the value of the EWMA decay factor, for each column of the matrix it calls the function…
-
3
votes1
answer3385
viewsQ: Replace specified column values in a matrix (R)
At the head office (ret_matriz) IBOV PETR4 VALE5 ITUB4 BBDC4 PETR3 [1,] -0.040630825 -0.027795652 -0.052643733 -0.053488685 -0.048455772 -0.061668282 [2,] -0.030463489 -0.031010237 0 -0.040229625…
-
1
votes3
answers304
viewsA: How to create a Standard Deviation Mobile Window (R)
Just to add to everyone’s knowledge, I posted the same question on the stack in English, follow some alternatives : apply in the above code is unnecessary, the below code already executes the same…
-
2
votes3
answers304
viewsQ: How to create a Standard Deviation Mobile Window (R)
A being the matrix below the return on shares (ret_matriz) for a given period. IBOV PETR4 VALE5 ITUB4 BBDC4 PETR3 [1,] -0.040630825 -0.027795652 -0.052643733 -0.053488685 -0.048455772 -0.061668282…
-
1
votes3
answers1031
viewsA: Replace Zero and Infinity values in a matrix (R)
Thanks for the answers, follows a form that was answered in the stack in English that worked too : infinite_na is the matrix with values of Ret == 0, infinity and -1 bancodados_ret is the matrix…
-
3
votes3
answers1031
viewsQ: Replace Zero and Infinity values in a matrix (R)
In the example matrix below (daily stock returns) : IBOV PETR4 VALE5 ITUB4 BBDC4 PETR3 [1,] -0.03981646 -0.027412907 -0.051282051 -0.05208333 -0.047300526 -0.059805285 [2,] -0.03000415 -0.030534351…
-
3
votes1
answer1401
viewsQ: Using function to make a subset and plot with only 1 command (R)
My dataframe calls EWMA_SD252 3561 Obs. of 102 variables (daily volatilities of 100 shares since 2000), follows a sample : Data IBOV ABEV3 AEDU3 ALLL3 3000 2012-02-09 16.88756 15.00696 33.46089…
-
5
votes1
answer156
viewsQ: EWMA volatility in a date.frame
I have a date.frame base_retorno_diario, of 3560 observations on 110 shares (daily returns), I want to create another data.frame from that with Volatility ewma with decay_factor = 0.97 Example of…
-
4
votes1
answer602
viewsQ: Minimum value of a row excluding zero (R)
TIMP3 TOTS3 UGPA3 USIM5 VALE3 VALE5 VIVT4 VLID3 WEGE3 1 0.7941716 0 0.00915221 0.2751215 0.3803796 0.5162442 1.505921 0 0.5559166 2 0.7710909 0 0.09351134 0.3925726 0.3687917 0.5158750 1.469548 0…