但是我不想使用来自yahoo!finance的数据,我想用我自己的但无法弄清楚如何解析CSV,它的格式如下:
Timestamp Low Open Close High BTC_vol USD_vol [8] [9]
2013-11-23 00 800 860 847.666666 886.876543 853.833333 6195.334452 5248330 0
2013-11-24 00 745 847.5 815.01 860 831.255 10785.94131 8680720 0
Run Code Online (Sandbox Code Playgroud)
我想做的事情如下:
def main(plot):
instruments = ["AA", "AES", "AIG"]
feed = yahoofinance.build_feed(instruments, 2008, 2009, ".")
Run Code Online (Sandbox Code Playgroud)
然后yahoofinance.build_feed(instruments, 2008, 2009, ".")用我的替换CSV
我试过了:
import csv
with open( 'FinexBTCDaily.csv', 'rb' ) as csvfile:
data = csv.reader( csvfile )
def main( plot ): …Run Code Online (Sandbox Code Playgroud) csv algorithmic-trading quantitative-finance pyalgotrade back-testing
直到昨天,以下网址(Google财经API)
https://www.google.com/finance/getprices?q=TSLA&x=NASDAQ&i=3600&p=5d&f=d,o,h,l,c,v
将导致一个漂亮的逗号分隔数据表与TSLA股票数据.从昨天起,同一个电话被重定向到TSLA https://www.google.com/search?q=TSLA&tbm=fin的标准谷歌财经网站.有人可能知道新的API地址或有关于Google财经API状态的任何信息吗?将URL更改为
https://finance.google.com/finance/getprices?q=TSLA&x=NASDAQ&i=3600&p=5d&f=d,o,h,l,c,v
没有帮助,因为它也重定向到正常的网站.
I am trying to create my own function in R based on black scholes variables and solve "backwards" i suppose for sigma.
I have created a function to find the call price; however, now I have to find the sigma (implied volatility) estimates in R and then test my function to see if it works... I have tried different functions but I can not seem to figure out what I am doing wrong, part of me thinks I need to …
我正在 Pandas 数据框上对股票市场上的一些交易策略进行一些回溯测试,我想设置一个距离输入价格 1% 的追踪止损。如果股价上涨了 5%,那么追踪止损也会上涨 5%。如果股价下跌,追踪止损不会改变。( https://www.investopedia.com/terms/t/trailingstop.asp )
我有这张表,它显示了我的入场信号,如果价格低于追踪止损价格,则退出列将显示值 1,这意味着交易已退出。
这是我到目前为止的表:
date price entry_signal
30/06/2018 95 0
01/07/2018 100 1
02/07/2018 103 0
03/07/2018 105 0
04/07/2018 104.50 0
05/07/2018 101 0
Run Code Online (Sandbox Code Playgroud)
我想有一栏显示每个日期的追踪止损是什么。当 enter_signal = 1 时,追踪止损首先设置为 01/07/2018 价格的 99%,此时交易在该日期执行。
当价格上涨 y% 时,追踪止损也会上涨 y%。但是,如果价格下跌,追踪止损将不会从其最后一个值改变。
当价格 <= 追踪止损时,交易退出,exit_signal 为 1...
如果价格也下跌 y%,我目前无法让追踪止损下跌 y%....
期望的表结果:
date price trailing stop loss entry_signal exit_signal
30/06/2018 95 NULL 0 0
01/07/2018 100 99 1 0
02/07/2018 103 101.97 0 0
03/07/2018 105 103.95 0 …Run Code Online (Sandbox Code Playgroud) 我有一些基于每日收盘价的股票数据.我需要能够将这些值插入到python列表中并获得最后30个关闭的中位数.有没有这样做的python库?
通过使用http://finance.yahoo.com/d/quotes.csv?s=STOCKNAME&f=我可以下载 CSV 文件,有人知道 beta 的符号是什么吗?它应该跟在&f=例如股票名称的符号是之后n,它是这样输入的:http://finance.yahoo.com/d/quotes.csv?s=STOCKNAME&f=n
在此先感谢您的帮助!
要求是计算 C# 中滚动窗口的最大回撤,例如返回的时间序列。即在每次新观察时,我们重新计算新时间窗口的最大回撤。
我试图将收益转换为价格指数来模拟 ffn 库的收盘价,但没有成功。
import pandas as pd
times = pd.to_datetime(pd.Series(['2014-07-4',
'2014-07-15','2014-08-25','2014-08-25','2014-09-10','2014-09-15']))
strategypercentage = [0.01, 0.02, -0.03, 0.04,0.5,-0.3]
df = pd.DataFrame({'llt_return': strategypercentage}, index=times)
df['llt_close']=1
df['llt_close']=df['llt_close'].shift(1)*(1+df['llt_return'])
df.head(10)
llt_return llt_close
2014-07-04 0.01 NaN
2014-07-15 0.02 1.02
2014-08-25 -0.03 0.97
2014-08-25 0.04 1.04
2014-09-10 0.50 1.50
2014-09-15 -0.30 0.70
Run Code Online (Sandbox Code Playgroud)
我怎样才能使这个正确?
我试图在滚动窗口上对 SPY 收盘价应用赫斯特指数。如果我将以下代码(我从这里获得:https : //www.quantstart.com/articles/Basics-of-Statistical-Mean-Reversion-Testing)应用于收盘价列,则效果很好。然而,这给了我一个静态值。考虑到最近 200 个收盘价,我想在滚动窗口上应用赫斯特指数。我的目标是获得一列,其中考虑到最近 200 个收盘价,在每一行中更新 Hurst 指数。
from numpy import cumsum, log, polyfit, sqrt, std, subtract
from numpy.random import randn
import pandas_datareader as dr
from datetime import date
df = dr.data.get_data_yahoo('SPY',start='23-01-1991',end=date.today())
def hurst(ts):
"""Returns the Hurst Exponent of the time series vector ts"""
# Create the range of lag values
lags = range(2, 100)
# Calculate the array of the variances of the lagged differences
tau = [sqrt(std(subtract(ts[lag:], ts[:-lag]))) for lag in lags]
# …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试在 python 中安装 ibapi 但是该包似乎不可用,因为每次我尝试安装它时都会出现错误,还有另一种方法可以安装这个包。对你的帮助表示感谢。我留下了我使用的代码。尝试安装软件包
pip install ibapi
Run Code Online (Sandbox Code Playgroud) python algorithmic-trading quantitative-finance interactive-brokers ib-api
finance ×4
python ×4
pandas ×3
back-testing ×2
csv ×2
c# ×1
ib-api ×1
pyalgotrade ×1
python-3.x ×1
r ×1
statistics ×1
stockquotes ×1
trading ×1