finance

Download history stock prices automatically from yahoo finance in python

痴心易碎 提交于 2019-12-28 07:17:48
问题 Is there a way to automatically download historical prices of stocks from yahoo finance or google finance (csv format)? Preferably in Python. 回答1: Short answer: Yes. Use Python's urllib to pull the historical data pages for the stocks you want. Go with Yahoo! Finance; Google is both less reliable, has less data coverage, and is more restrictive in how you can use it once you have it. Also, I believe Google specifically prohibits you from scraping the data in their ToS. Longer answer: This is

Yahoo Finance Historical data downloader url is not working

陌路散爱 提交于 2019-12-28 02:53:13
问题 I have used the following url to fetch the historical data from yahoo finance. From last 16th May, 2017 the url is not working. http://real-chart.finance.yahoo.com/table.csv?s=AAL&a=04&b=01&c=2017&d=04&e=02&f=2017&g=d&ignore=.csv Seems like they have changed the url and the new url is: https://query1.finance.yahoo.com/v7/finance/download/AAL?period1=1494873000&period2=1494959400&interval=1d&events=history&crumb=l0aEtuOKocj In the above changed URL has a session cookie which is crumb. Is there

Non-consecutive intraday index

ⅰ亾dé卋堺 提交于 2019-12-25 09:56:49
问题 This question is related to : Python pandas, how to only plot a DataFrame that actually have the datapoint and leave the gap out I'd like to know the easiest way to produce non-consecutive DateTimeIndex at intra-day resolution, that only maintains samples between certain [stock exchange] times e.g. 08:00-16:30, and has only given weekdays e.g. Mon-Fri. A bonus would be to be allow provision of a calendar of valid dates. At the day range, it's easy to do with pandas.bdate_range() for Mon-Fri.

error message using RBloomberg

半腔热情 提交于 2019-12-25 03:11:51
问题 I am testing RBloomberg to access the Bloomberg API. Upon creating a connection using > conn <- blpConnect() I receive a pop-up error message stating that "The program can't start because XLCall32.dll is missing from your computer." However, XLCall32 is in the proper Office subdirectory. The error is actually generated by the assignment within the function conn <- COMCreate("Bloomberg.Data.1") This is a warning message: if one clicks OK, the API seems to work fine. Has anyone encountered this

Cannot download Brent Crude oil data from yahoo finance R

本小妞迷上赌 提交于 2019-12-24 12:25:04
问题 I am very new to R, so this question might seem very easy for most of you. I am trying to download brent oil price from yahoo finance, but R is giving me an error. So here's what I did: getSymbols(Symbols = "BZK16.NYM",from="2015-11-02",to="2016-03-10",src="yahoo") and R gives me this: Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, : cannot open URL 'http://ichart.finance.yahoo.com/table.csv?s=BZK16.NYM&a=10&b=02&c=2015&d=2&e=10&f=2016&g=d&q=q&y=0&z=BZK16.NYM&x=

Issue installing QuantLib Python

冷暖自知 提交于 2019-12-24 11:15:29
问题 I am trying to install QuantLib Python. So, I followed through and installed: 1) Anaconda3, boost_1_64_0, QuantLib-1.10, QuantLib-SWIG-1.10,swigwin-3.0.12. 2) I installed using Visual Studio 2017, QuantLib. I followed a youtube video and managed to install it correctly and run an example. 3) Then I switched back to the indications in http://quantlib.org/install/windows-python.shtml, I execute the commands: cd C:\local\QuantLib-SWIG-1.10\Python set QL_DIR=C:\local\QuantLib-1.10 set INCLUDE=C:

Running cumulative return in sql

烂漫一生 提交于 2019-12-24 10:40:37
问题 Looking to have a running cumulative return for a series of daily returns? I know this can be solved using exp and sum, but my return series is not calculated using LN. Hoping to solve this without using loops, as they are very inefficient in sql. Its important to make this run fast. Dataset: desired result 回答1: Is this what you want? select t.*, (select exp(sum(log(1 + return))) - 1 from table t2 where t2.date <= t.date ) as cumereturn from table t; The functions for exp() and log() may be

Sort Datetime data by day, but from 4PM to 4PM

南笙酒味 提交于 2019-12-24 07:39:46
问题 I have Tweets from various times a day about companies, and I want to group them all by day. I have already done this. However, I want to sort them not from 00:00 until 23:59, but instead from 16:00 until 15:59 (because of the NYSE open hours). Tweets (Negative, Neutral and Positive is for the sentiment): Company,Datetime_UTC,Negative,Neutral,Positive,Volume AXP,2013-06-01 16:00:00+00:00,0,2,0,2 AXP,2013-06-01 17:00:00+00:00,0,2,0,2 AXP,2013-06-02 05:00:00+00:00,0,1,0,1 AXP,2013-06-02 16:00

How to calculate pivot value from OHLC data

限于喜欢 提交于 2019-12-24 03:49:05
问题 I've a pandas dataset with open, high, low, close and key column. Now I want to group the dataset by key and calculate pivot with the formula - (high + low + close) / 3. Upto this I'm able to do. But the requirement is to shift the calculated data to next group which I'm unable to code. I'm able to group the dataset by key column and able to calculate pivot data. import pandas as pd data = pd.DataFrame([[110, 115, 105, 111, 1],[11, 16, 6, 12, 1],[12, 17, 7, 13, 1],[12, 16, 6, 11, 2],[9, 13, 4

how to plot candlesticks in python

北城以北 提交于 2019-12-24 00:39:33
问题 I´m trying to create a simple plot with candlesticks. For that I get the data from Yahoo and plot it using the function candlestick2_ohlc. The goal is to export the image in a jpg file using. This is the code what I´m using: from pandas_datareader import data import matplotlib.pyplot as plt from mpl_finance import candlestick2_ohlc import matplotlib.dates as mdates import fix_yahoo_finance as yf import datetime start = datetime.date(2018, 1, 1) end = datetime.date.today() aapl = yf.download(