finance

How can i convert a dataframe with a factor column to a xts object?

廉价感情. 提交于 2019-12-22 17:55:05
问题 I have a csv file and when i use this command SOLK<-read.table('Book1.csv',header=TRUE,sep=';') I get this output > SOLK Time Close Volume 1 10:27:03,6 0,99 1000 2 10:32:58,4 0,98 100 3 10:34:16,9 0,98 600 4 10:35:46,0 0,97 500 5 10:35:50,6 0,96 50 6 10:35:50,6 0,96 1000 7 10:36:10,3 0,95 40 8 10:36:10,3 0,95 100 9 10:36:10,4 0,95 500 10 10:36:10,4 0,95 100 . . . . . . . . . . . . 285 17:09:44,0 0,96 404 Here is the result of dput(SOLK[1:10,]) : > dput(SOLK[1:10,]) structure(list(Time =

Pause URL request Downloads

谁说胖子不能爱 提交于 2019-12-22 00:27:55
问题 import urllib.request import re import csv import pandas as pd from bs4 import BeautifulSoup columns = [] data = [] f = open('companylist.csv') csv_f = csv.reader(f) for row in csv_f: stocklist = row print(stocklist) for s in stocklist: print('http://finance.yahoo.com/q?s='+s) optionsUrl = urllib.request.urlopen('http://finance.yahoo.com/q?s='+s).read() soup = BeautifulSoup(optionsUrl, "html.parser") stocksymbol = ['Symbol:', s] optionsTable = [stocksymbol]+[ [x.text for x in y.parent

downloading morningstar webpages for screenscraping

限于喜欢 提交于 2019-12-21 23:28:42
问题 I'd like to be able to screenscrape Morningstar webpages. Morningstar provides information about a mutual fund that I routinely look up but haven't been able to find elsewhere, ie total return compared against benchmark total return compared against peers percentile ranking Here's an example: morningstar example As a prelude to screenscraping, I need to be able to download the webpage with the desired content. Unfortunately, when I try using Java SE6 or wget to retrieve the above example link

Using QuantLib to compute cash flows for FloatingRateBond with Floor

旧街凉风 提交于 2019-12-21 20:53:33
问题 Very new to QuantLib so guessing this is a rookie mistake. Enjoyed getting to know this powerful library so thank you to the authors and contributors! I'm able to generate amounts for cashflows for a FloatingRateBond without a pricer if there isn't a floor argument, so I don't understand why including a floor argument would necessitate a pricer. I would think the addition of the floor would just provide a min for each of the fixing values. Wanted to see if anyone has gotten the

Turn list of company names into tickers

不打扰是莪最后的温柔 提交于 2019-12-21 17:47:02
问题 I have a list of company names that I would like to turn into tickers. Here is the reproducible code to create the list of names that I have: companynames=structure(list(V1 = structure(1:41, .Label = c("AETNA INC", "ANTHEM INC", "APPLE INC", "ASPEN INSURANCE HOLDINGS LTD", "BARRICK GOLD CORP", "BEST BUY CO INC", "CAREFUSION CORP", "CBS CORP-CLASS B NON VOTING", "CIGNA CORP", "COMPUTER SCIENCES CORP", "COMPUWARE CORP", "COVENTRY HEALTH CARE INC", "DELPHI AUTOMOTIVE PLC", "DST SYSTEMS INC",

Android - How to retrieve currency exchange rates [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-12-21 05:04:23
问题 This question already has answers here : How do I get currency exchange rates via an API such as Google Finance? [closed] (10 answers) Closed 4 years ago . I'm trying to develop a simple Forex app for Android. To start off, I need to get the currency exchange rates, say for the past year. Could anybody advice how I can go about this? I looked in Google financh API but couldn't find how to retrieve currency rates. Any advice is appreciated. Thank you. 回答1: You can parse the data from the

Open source or free financial analysis programs/libraries

戏子无情 提交于 2019-12-21 02:37:17
问题 I'm looking for something containing similar functions to Matlab’s financial and financial derivatives toolbox but don’t have the cash to spend on matlab. I would appreciate any info on free or open source libraries or programs that will let me easily calculate interest rates, risk etc. 回答1: How about JQuantLib or QuantLib? 回答2: How about the Octave financial functions? http://www.gnu.org/software/octave/doc/interpreter/Financial-Functions.html#Financial-Functions I'm not familiar with the

Pandas' EMA not matching the stock's EMA?

回眸只為那壹抹淺笑 提交于 2019-12-21 01:18:06
问题 I am trying to use Python (with Pandas) to calculate the 20-day Exponential Moving Averages (EMA) of daily stock data for Intel (INTC). Pandas has a number of ways of doing this, and I've also tried stockstats, which runs on Pandas, but they never return the same EMA as I get from stock/finance websites. I've double checked the close prices, and they match, but the EMA always comes out "wrong". This is the CSV I'm using: INTC Stock Data It contains the daily Date, Month Name, Open, High, Low,

Python rolling Sharpe ratio with Pandas or NumPy

丶灬走出姿态 提交于 2019-12-20 16:49:35
问题 I am trying to generate a plot of the 6-month rolling Sharpe ratio using Python with Pandas/NumPy. My input data is below: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns sns.set_style("whitegrid") # Generate sample data d = pd.date_range(start='1/1/2008', end='12/1/2015') df = pd.DataFrame(d, columns=['Date']) df['returns'] = np.random.rand(d.size, 1) df = df.set_index('Date') print(df.head(20)) returns Date 2008-01-01 0.232794 2008-01-02 0.957157

How do I store data from the Bloomberg API into a Pandas dataframe?

和自甴很熟 提交于 2019-12-20 08:13:20
问题 I recently started using Python so I could interact with the Bloomberg API, and I'm having some trouble storing the data into a Pandas dataframe (or a panel). I can get the output in the command prompt just fine, so that's not an issue. A very similar question was asked here: Pandas wrapper for Bloomberg api? The referenced code in the accepted answer for that question is for the old API, however, and it doesn't work for the new open API. Apparently the user who asked the question was able to