finance

Adding a weight constraint to Max Sharpe Ratio function in python

*爱你&永不变心* 提交于 2021-01-29 07:33:10
问题 I have the following formula to calculate Max Sharpe Ratio for a given set of returns: def msr(riskfree_rate, er, cov): """ Returns the weights of the portfolio that gives you the maximum sharpe ratio given the riskfree rate and expected returns and a covariance matrix """ n = er.shape[0] init_guess = np.repeat(1/n, n) bounds = ((0.0, 1.0),) * n # an N-tuple of 2-tuples! # construct the constraints weights_sum_to_1 = {'type': 'eq', 'fun': lambda weights: np.sum(weights) - 1 } def neg_sharpe

Return only the last day of the year with pandas?

两盒软妹~` 提交于 2021-01-29 06:44:40
问题 Made an api get request for the historical close prices of a stock for a specified company from the financialmodelingprep api. It returns every recorded date for the stock. The problem is that i need only the last date of the last 5 years, in order to compare it to the financial statements. Does anyone know how to filter the dataset to get the last date of the year, without specifying the exact date? The goal is to export the table to csv format and further combine it with other companies. Is

Use Excel VBA to fill database with payments split in months

半腔热情 提交于 2021-01-29 06:08:55
问题 I'm making a spreadsheet to control my finances. I made a VBA code where I enter 4 different data: i) Client's name; ii) Total value of the contract; iii) Number of months that the contract will be paid; iv) Date of the first payment. I've been able to complete and use the code, that fills a database with these information in 4 different columns. The thing is, I want it to (when I click the insert button) automatically split the value and fill the dates according to the number of months that

Trying to write a code which gives the strategy a buffer time before it takes the next trades

﹥>﹥吖頭↗ 提交于 2021-01-28 07:09:36
问题 What I'm trying to achieve is a "gap" of a few candles, say 4 in this case before the next trade happens Here nexT is the number of bars, before which the next trade should not take place But the value of nextT always resets to 0, everytime the code runs. What can be a possible modification to the code that the value of nexT does not reset automatically. //@version=4 strategy("RSI Strategy", overlay=true) //timeframe //timframe FromMonth = input(defval = 9, title = "From Month", minval = 1)

Getting Open, High, Low, Close for 5 min stock data python

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-24 11:25:50
问题 I have a DataFrame that contains stock data with the following columns: time ticker price 0 2020-04-02 09:30:35 EV 33.860 1 2020-04-02 09:00:00 AMG 60.430 2 2020-04-02 09:30:35 AMG 60.750 3 2020-04-02 09:00:00 BLK 455.350 4 2020-04-02 09:30:35 BLK 451.514 ... ... ... ... 502596 2020-04-02 13:00:56 TLT 166.450 502597 2020-04-02 13:00:56 VXX 47.150 502598 2020-04-02 13:00:56 TSLA 529.800 502599 2020-04-02 13:00:56 BIDU 103.500 502600 2020-04-02 13:00:56 ON 12.700 Its stock price data for every

Getting Open, High, Low, Close for 5 min stock data python

亡梦爱人 提交于 2021-01-24 11:23:34
问题 I have a DataFrame that contains stock data with the following columns: time ticker price 0 2020-04-02 09:30:35 EV 33.860 1 2020-04-02 09:00:00 AMG 60.430 2 2020-04-02 09:30:35 AMG 60.750 3 2020-04-02 09:00:00 BLK 455.350 4 2020-04-02 09:30:35 BLK 451.514 ... ... ... ... 502596 2020-04-02 13:00:56 TLT 166.450 502597 2020-04-02 13:00:56 VXX 47.150 502598 2020-04-02 13:00:56 TSLA 529.800 502599 2020-04-02 13:00:56 BIDU 103.500 502600 2020-04-02 13:00:56 ON 12.700 Its stock price data for every

How to use ARIMA in GARCH model

让人想犯罪 __ 提交于 2021-01-01 10:04:40
问题 I have financial data and my goal is to be able to forecast. I ran an arima model and found that the best fit was arima(1,1,1) w/ drift. I want to use GARCH on the data set because it is the better model to use due to volatility and when I squared my residuals it did have the arch effect. But I know that GARCH takes in a 2 parameter arima and I am not sure how that translates from the 3 parameter arima I currently have. library(dplyr) library(tidyr) library(lubridate) library(ggplot2) library

How to use ARIMA in GARCH model

旧街凉风 提交于 2021-01-01 10:04:22
问题 I have financial data and my goal is to be able to forecast. I ran an arima model and found that the best fit was arima(1,1,1) w/ drift. I want to use GARCH on the data set because it is the better model to use due to volatility and when I squared my residuals it did have the arch effect. But I know that GARCH takes in a 2 parameter arima and I am not sure how that translates from the 3 parameter arima I currently have. library(dplyr) library(tidyr) library(lubridate) library(ggplot2) library

Hierarchical roll-up in SQL accounting system

▼魔方 西西 提交于 2020-05-17 04:50:05
问题 I'm trying to make annual reports (Balance Sheet and Profit & Loss) from general journal entries in an accounting system. The general journal table (simplified) includes: CREATE TABLE `sa_general_journal` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Date` timestamp NOT NULL DEFAULT current_timestamp(), `Item` varchar(1024) NOT NULL DEFAULT '', `Amount` decimal(9,2) NOT NULL DEFAULT 0.00, `Source` int(10) unsigned NOT NULL, `Destination` int(10) unsigned NOT NULL, PRIMARY KEY (`ID`), KEY