finance

Where and how to get the equity historical data (at least covers 2008)?

混江龙づ霸主 提交于 2019-12-11 01:02:49
问题 I can use the following code to get historical data from Google Finance. But the oldest is from 2016-09-20. This is too short for back testing. I need historical data which covers the year of 2008. import pandas_datareader.data as web start = datetime.datetime(2002, 1, 1) end = datetime.datetime(2017, 1, 27) aapl = DataReader("AAPL", "google", start, end) print(len(aapl)) print(aapl.head()) The outputs are as follow: Open High Low Close Volume Date 2016-09-20 35.02 35.06 33.91 34.44 21192908

Rolling idxmax() in python?

回眸只為那壹抹淺笑 提交于 2019-12-10 22:36:20
问题 I have a python DataFrame containing some financial data that I am trying to create some technical indicators for. I am trying to figure out how to use a moving window function to speed up the process rather than going element by element. For each index I would like to return the maximum index for the last 30 days. I had implemented an element by element solution but as you can imagine it is dreadfully slow. for s_sym in ls_symbols: for i in range(refresh, len(ldt_timestamps)): #Aroon-Up = (

How to handle meta data associated with a pandas dataframe?

荒凉一梦 提交于 2019-12-10 17:49:25
问题 What is the best practice for saving meta information to a dataframe? I know of the following coding practice import pandas as pd df = pd.DataFrame([]) df.currency = 'USD' df.measure = 'Price' df.frequency = 'daily' But as stated in this post Adding meta-information/metadata to pandas DataFrame this is associated with the risk of losing the information by appling functions such as "groupby, pivot, join or loc" as they may return "a new DataFrame without the metadata attached". Is this still

getSymbols (quantmod) giving wrong dates

孤街醉人 提交于 2019-12-10 16:17:30
问题 I'm using the quantmod package to fetch stock data. The code Data = getSymbols('LON:ADN',src="google",auto.assign=FALSE, from = '2011-08-10') Results in an xts as expected, however on closer examination it shows a volume of trades for 2012-10-21 (October 21st) which was a sunday, and is therefore clearly erroneous. Several other sundays are also included. Unfortunately the errors surrounding the weekends seem to have moved the rest of the data out of alignment. Has anyone experienced similar

How can I consistently convert strings like “3.71B” and “4M” to numbers in Python?

点点圈 提交于 2019-12-10 14:27:43
问题 I have some rather mangled code that almost produces the tangible price/book from Yahoo Finance for companies (a nice module called ystockquote gets the intangible price/book value already). My problem is this: For one of the variables in the calculation, shares outstanding I'm getting strings like 10.89B and 4.9M , where B and M stand respectively for billion and million . I'm having trouble converting them to numbers, here's where I'm at: shares=''.join(node.findAll(text=True)).strip()

Loan payment calculation

元气小坏坏 提交于 2019-12-10 12:26:06
问题 I am learning Python and am stuck. I am trying to find the loan payment amount. I currently have: def myMonthlyPayment(Principal, annual_r, n): years = n r = ( annual_r / 100 ) / 12 MonthlyPayment = (Principal * (r * ( 1 + r ) ** years / (( 1 + r ) ** (years - 1)))) return MonthlyPayment n=(input('Please enter number of years of loan')) annual_r=(input('Please enter the interest rate')) Principal=(input('Please enter the amount of loan')) However, when I run, I am off by small amount. If

OpenGL or Flash for 3d visualization in the browser

隐身守侯 提交于 2019-12-10 10:37:56
问题 I am planning create a site that lets users in finance visualize the price of a foreign exchange option in 3d. x = price of underlying, y = price of option, z = days left to maturity. In other words, rather than a simple option payout diagram, this would allow you, on the Z axis, to view what the P&L scenarios would be if you sold before expiry of the option. In short, I want a visualizaion tool. But given that the surface of the P&L might be quite "curvy", it's going to be good for users to

Fast loan rate calculation for a big number of loans

旧巷老猫 提交于 2019-12-10 09:47:29
问题 I have a big data set (around 200k rows) where each row is a loan. I have the loan amount, the number of payments, and the loan payment. I'm trying to get the loan rate. R doesn't have a function for calculating this (at least base R doesn't have it, and I couldn't find it). It isn't that hard to write both a npv and irr functions Npv <- function(i, cf, t=seq(from=0,by=1,along.with=cf)) sum(cf/(1+i)^t) Irr <- function(cf) { uniroot(npv, c(0,100000), cf=cf)$root } And you can just do rate =

In Delphi, how can you have currency data types shown in different currencies in different forms?

ぃ、小莉子 提交于 2019-12-08 17:38:15
问题 I need to write a Delphi application that pulls entries up from various tables in a database, and different entries will be in different currencies. Thus, I need to show a different number of decimal places and a different currency character for every Currency data type ($, Pounds, Euros, etc) depending on the currency of the item I've loaded. Is there a way to change the currency almost-globally, that is, for all Currency data shown in a form? 回答1: Even with the same currency, you may have

Importing nested JSON documents into Elasticsearch and making them searchable

牧云@^-^@ 提交于 2019-12-08 12:04:27
问题 We have MongoDB-collection which we want to import to Elasticsearch (for now as a one-off effort). For this end, we have exported the collection with monogexport . It is a huge JSON file with entries like the following: { "RefData" : { "DebtInstrmAttrbts" : { "NmnlValPerUnit" : "2000", "IntrstRate" : { "Fxd" : "3.1415" }, "MtrtyDt" : "2020-01-01", "TtlIssdNmnlAmt" : "200000000", "DebtSnrty" : "SNDB" }, "TradgVnRltdAttrbts" : { "IssrReq" : "false", "Id" : "BMTF", "FrstTradDt" : "2019-04-01T12