使用R语言抓取A股股价数据

不出所料使用R抓取A股的股价又是一个非常轻松的事。上午刚刚说到咱们可以轻松拿到各证券的研报信息,那么咱们如果想分析一下,研报对于股价的影响,应该如何做呢?

一、还是安装包

install.packages("PerformanceAnalytics")
library(PerformanceAnalytics)
install.packages("quantmod")
library(quantmod)

二、下载对应的股股价信息
setSymbolLookup(QDSD=list(name='000826.sz',src='yahoo'));#000826.sz是启迪桑德的股票代码
getSymbols("QDSD",from="2018-11-01",to="2018-12-28");#抓取研报发出以后一个月的股价
chartSeries(QDSD)#画出k线图


profit=Delt(QDSD[,4])#形成收益数据

接下来我会继续研究如何批量下载研报对应股价的信息。

Problem Description Optiver sponsored problem. After years of hard work Optiver has developed a mathematical model that allows them to predict wether or not a company will be succesful. This obviously gives them a great advantage on the stock market. In the past, Optiver made a deal with a big company, which forces them to buy shares of the company according to a fixed schedule. Unfortunately, Optiver's model has determined that the company will go bankrupt after exactly n days, after which their shares will become worthless. Still, Optiver holds a large number of sell options that allows them to sell some of the shares before the company goes bankrupt. However, there is a limit on the number of shares Optiver can sell every day, and price Optiver receives for a share may vary from day to day. Therefore, it is not immediately clear when Optiver should sell their shares to maximize their profit, so they asked you to write a program to calculcate this. Input On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case: One line with an integer n (1 <= n <= 100 000): the number of days before the company goes bankrupt. n lines with three integers xi (0 <= xi <= 100), pi (0 <= pi <= 100) and mi (0 <= mi <= 10 000 000): the number of shares Optiver receives on day i, the (selling) price per share on day i, and the maximum number of shares Optiver can sell on day i, respectively. Output For each test case: One line with the maximum profit Optiver can achieve. Sample Input 1 6 4 4 2 2 9 3 2 6 3 2 5 9 2 2 2 2 3 3 Sample Output 76
Problem Description Optiver sponsored problem. After years of hard work Optiver has developed a mathematical model that allows them to predict wether or not a company will be succesful. This obviously gives them a great advantage on the stock market. In the past, Optiver made a deal with a big company, which forces them to buy shares of the company according to a fixed schedule. Unfortunately, Optiver's model has determined that the company will go bankrupt after exactly n days, after which their shares will become worthless. Still, Optiver holds a large number of sell options that allows them to sell some of the shares before the company goes bankrupt. However, there is a limit on the number of shares Optiver can sell every day, and price Optiver receives for a share may vary from day to day. Therefore, it is not immediately clear when Optiver should sell their shares to maximize their profit, so they asked you to write a program to calculcate this. Input On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case: One line with an integer n (1 <= n <= 100 000): the number of days before the company goes bankrupt. n lines with three integers xi (0 <= xi <= 100), pi (0 <= pi <= 100) and mi (0 <= mi <= 10 000 000): the number of shares Optiver receives on day i, the (selling) price per share on day i, and the maximum number of shares Optiver can sell on day i, respectively. Output For each test case: One line with the maximum profit Optiver can achieve. Sample Input 1 6 4 4 2 2 9 3 2 6 3 2 5 9 2 2 2 2 3 3 Sample Output 76
©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页
实付 9.90元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值