我正在尝试使用 pandas 在 python 中制作阿隆指示器。然而我得到了错误的价值观...任何人都可以帮助指出我错在哪里...
import pandas as pd
import Bitmex_OHLC
import numpy as np
import importlib
def aroon():
importlib.reload(Bitmex_OHLC)
df_aroon = Bitmex_OHLC.OHLC()
df_aroon['14L_min'] = df_aroon['low'].rolling(window=14,min_periods=0).min()
df_aroon['14H_max'] = df_aroon['high'].rolling(window=14,min_periods = 0).max()
df_aroon['ind'] = range(0,len(df_aroon))
# recent_high = df_aroon.iloc[-1]["25d High"]
df_aroon['high_ind'] = df_aroon['ind'].where(df_aroon["14H_max"]==df_aroon['high']).fillna(method = 'ffill')
df_aroon['low_ind'] = df_aroon['ind'].where(df_aroon["14L_min"] == df_aroon['low']).fillna(method = 'ffill')
df_aroon['since_high'] = df_aroon['ind']-df_aroon['high_ind']
df_aroon['since_low'] = df_aroon['ind'] - df_aroon['low_ind']
df_aroon['up'] = (((14 - df_aroon['since_high'])/14) *100)
df_aroon['down'] = (((14 - df_aroon['since_low']) / 14) * 100)
return (df_aroon)
print(aroon().tail())
Run Code Online (Sandbox Code Playgroud)
(down) 列的值应始终为正,并且 (since_low) …
我正在查看金融建模准备 API:https : //financialmodelingprep.com/developer/docs/
这个 API 真的很酷,因为它几乎提供了我正在寻找的一切。但是,有关不同定价计划的详细信息并没有那么详细。
对于免费计划,它表示 250 个请求,但没有提及任何速率限制。这些请求是每月、每年还是在 250 个请求之后,我无法再提出请求?
对于其他计划,它表示无限请求,但同样没有提到速率限制。
我也不知道在哪里可以查看我在财务建模准备方面提出了多少请求。
有没有人有任何想法?
先感谢您!
哦,顺便说一句,如果有人有更好的价格适合学生的库存API,请告诉我!
刚刚开始学习如何使用 Pandas,所以请原谅问题的简单性!
import pandas as pd
top100 = pd.read_html('https://robinhood.com/collections/100-most-popular')
Run Code Online (Sandbox Code Playgroud)
输出:
[ Name Symbol Price Today Market Cap Popularity Analyst Ratings
0 Ford Motor F $6.81 0.73% 27.04B 942282 21% Buy
1 GE GE $7.08 0.43% 61.84B 840895 62% Buy
2 American Airlines AAL $11.96 3.94% 6.05B 655044 20% Buy
3 Disney DIS $118.70 0.61% 214.31B 619926 50% Buy
4 Delta Air Lines DAL $27.17 0.33% 17.25B 582985 63% Buy
.. ... ... ... ... ... ... ...
95 Occidental Petroleum …
Run Code Online (Sandbox Code Playgroud) 我确定这很明显,但我是 R 的初学者,我花了一个下午的大部分时间试图解决这个问题......
我正在尝试创建一个循环,以五步为单位对我的时间序列中的观察进行总结。
例如 :
输入:
1 2 3 4 5 5 6 6 7 4 5 5 4 4 5 6 5 6 4 4
输出:15 28 23 25
我的时间序列只有一个变量,并且有 7825 次观察。
循环的最终目的是计算每周实现的波动率。我的观察是平方回报。一旦我有了我的循环,我将能够提取平方根并获得每周实现的波动率。
非常感谢您提供的任何帮助。
H。
我知道在这篇文章中已经提到过这个问题(xts error - order.by需要一个适当的基于时间的对象),但问题似乎仍然没有解决.
我正在使用与此处相同的代码:R:xts中的错误 - order.by,一切正常并且计算完美,直到我重新启动计算机并且我现在面临这个问题:
我没有生成代码,我在本书上找到了它:http://www.amazon.com/Data-Mining-Learning-Knowledge-Discovery/dp/1439810184/ref=sr_1_1?ie= UTF8& qid= 1344349381& sr=8 -1&关键字=数据+挖掘与+ R +
这是可重复的例子:
# Packages needed :
library(xts)
library(TTR)
library(randomForest)
library(DMwR)
# Time Series :
myTimeSeries <-
structure(c(2787, 2800, 2788, 2803, 2815, 2815, 2812, 2807, 2810,
2829, 2830, 2837, 2841, 2840, 2843, 2839, 2835, 2841, 2834, 2838,
2827, 2821, 2831, 2811, 2796, 2808, 2814, 2811, 2815, 2803, 2788,
2778, 2772, 2777, 2776, 2760, 2732, 2711, 2709, 2707, 2700, 2706,
2706, …
Run Code Online (Sandbox Code Playgroud) 我目前有OHLC日内数据,我需要转换为5分钟的数据.在R中有没有办法做到这一点?
给定一组5-6个参数,我很好奇该怎么做。在找到最大的价值增长时评估结果。
由于我拥有的参数数量,组合的数量似乎巨大。但是我的选择仅仅是使用for循环吗?
在此分配中,我一直在构建网格搜索策略(仅使用for循环),但还有更多变量。
http://nbviewer.ipython.org/github/cs109/content/blob/master/HW3.ipynb
我有一个数据框,其中包含一段时间内的各种股票收益。回报以收益或损失百分比表示(0.02 表示 2% 回报或前期值的 102%)。
我正在寻找一个函数或方法来累积显示每个时期的回报(以百分比表示)。例如,这将显示前 3 个周期的 stock1 的累积/复合收益为 0.02、0.0404、0.09242.... (1.02*1.02*1.05)。
mydf = data.frame(period = c('a','b','c','d','e','f'), stock1=c(.02, .02, .05,-.05,-.05,0), stock2=c(0, .01,0,.03,.05,.01))
mydf
#help mydf$stk1_percentgain =
Run Code Online (Sandbox Code Playgroud) 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.contents]
for y in soup.findAll('td', attrs={'class': 'yfnc_tabledata1','rtq_table': ''})
]
if not columns:
columns = [o[0] for o in optionsTable] #list(my_df.loc[0])
data.append(o[1] for o …
Run Code Online (Sandbox Code Playgroud) 我正在尝试获取 S&P500 中所有股票的当前价格和市值,而我目前的做法非常慢,所以我想知道是否有什么可以改进它的方法,或者任何其他方法。这是我当前的方法,只是打印名称、市值和当前价格:
import yfinance as yf
#I am using a csv file with a list of all the tickers which I use to create a pandas dataframe and form a space seperated string of all of the tickers called all_symbols
#I have simplified the pandas dataframe to a list for the purpose of this question
ticker_list = ["A", "AL", "AAP", "AAPL", ... "ZBRA", "ZION", "ZTS"]
all_symbols = " ".join(ticker_list)
tickers = yf.Tickers(all_symbols)
for ticker in ticker_list:
price = tickers.tickers[ticker].info["currentPrice"] …
Run Code Online (Sandbox Code Playgroud) 我使用PHP脚本将Yahoo财务报价转换为HTML网页.但是,经过一年的完美工作后,网页突然停止显示数据,并且根本没有代码更改.这是我的代码:
<table>
<tr>
<?php $fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=VIP&f=l1c1p2rj1&e=.csv","r");
$data = fgetcsv ($fp, 1000, ",") ?>
<td>Vimpel-Communications</td>
<td><?php echo $data[0] ?></td>
<td><?php echo $data[1] ?></td>
<td><?php echo $data[2] ?></td>
<td><?php echo $data[3] ?></td>
<td><?php echo $data[4] ?></td>
<td><?php echo $data[5] ?></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
这是一个实际网站的测试页面:http://bricadr.com/test.php 任何人都可以帮助或有人知道发生了什么,或者我如何解决这个问题?此外,如果有人有服务器,你能看到这个代码是否适用于您的服务器?也许我的托管公司关闭了一些功能,允许以前工作.
先感谢您!
布赖恩
finance ×11
python ×5
pandas ×4
r ×4
xts ×2
api ×1
csv ×1
dataframe ×1
datareader ×1
html ×1
indicator ×1
loops ×1
php ×1
python-3.x ×1
regression ×1
stock ×1
time-series ×1
trading ×1
yahoo ×1
yfinance ×1