quantitative-finance

How to calculate the trendline for stock price

偶尔善良 提交于 2020-12-27 08:06:28
问题 I am trying to calculate and draw the trendlines for stock prices. I did some searches and thought for a whole day, there is no a really good idea on how to do. I have daily price history and want to find the cross point between trendline and price line. Could you provide some ideas or guidances? Thank you so much!!! 回答1: import pandas as pd import quandl as qdl from scipy.stats import linregress # get AAPL 10 years data data = qdl.get("WIKI/AAPL", start_date="2007-01-01", end_date="2017-05

installing the ibapi package

情到浓时终转凉″ 提交于 2020-12-04 03:15:06
问题 Hi I am trying to install ibapi in python however the package seems to be unavailable because there is an error every time I try to install it is there another way I can install this package . Your help will be greatly appreciated. I have left the code I used. to try and install the package pip install ibapi 回答1: The official Interactive Brokers API is only offered through their Github site and not the Python Package Index (PyPI) because its distributed under a different license. You can

installing the ibapi package

泄露秘密 提交于 2020-12-04 03:13:46
问题 Hi I am trying to install ibapi in python however the package seems to be unavailable because there is an error every time I try to install it is there another way I can install this package . Your help will be greatly appreciated. I have left the code I used. to try and install the package pip install ibapi 回答1: The official Interactive Brokers API is only offered through their Github site and not the Python Package Index (PyPI) because its distributed under a different license. You can

installing the ibapi package

大城市里の小女人 提交于 2020-12-04 03:13:32
问题 Hi I am trying to install ibapi in python however the package seems to be unavailable because there is an error every time I try to install it is there another way I can install this package . Your help will be greatly appreciated. I have left the code I used. to try and install the package pip install ibapi 回答1: The official Interactive Brokers API is only offered through their Github site and not the Python Package Index (PyPI) because its distributed under a different license. You can

BatchGetSymbols - reshape output

不羁的心 提交于 2020-06-09 05:20:53
问题 I like to use the advanted of BatchgetSymbols. Any advice how I can best manipulate the output to receive the format below? symbols_RP <- c('VDNR.L','VEUD.L','VDEM.L','IDTL.L','IEMB.L','GLRE.L','IGLN.L') #Setting price download date range from_date <- as.Date('2019-01-01') to_date <- as.Date(Sys.Date()) get.symbol.adjclose <- function(ticker) { l.out <- BatchGetSymbols(symbols_RP, first.date = from_date, last.date = to_date, do.cache=TRUE, freq.data = "daily", do.complete.data = TRUE, do.fill

How to apply the Hurst Exponent in Python in a rolling window

坚强是说给别人听的谎言 提交于 2020-01-13 18:55:09
问题 I am trying to apply the Hurst Exponent on SPY closing prices on a rolling window. The below code (which I got from here: https://www.quantstart.com/articles/Basics-of-Statistical-Mean-Reversion-Testing) works well if I apply it on the closing prices column. However this gives me a static value. I would like to apply the Hurst Exponent on a rolling window considering the last 200 closing prices. My objective is to get a column in which the Hurst Exponent is updated in each row considering the

Apply sum product on columns of a dataframe in rolling windows

浪尽此生 提交于 2020-01-06 05:25:23
问题 I have a set of defined weights and I want to calculate the weighted sum of returns in rolling windows on a time series dataframe. I believe we would use rollapplyr here, but I am unsure how to perform rolling window function across each row of the dataframe. Find below dput output of a sample of the data: tempVar <- structure(c(NA, -0.0081833512947922, 0.00508150903899551, -0.0072202479734873, 0.00345258369231161, NA, 0, -0.00847462699097257, -0.00794638265247283, 0.00445091892889238, NA, NA

How to calculate Volume Weighted Average Price (VWAP) using a pandas dataframe with ask and bid price?

随声附和 提交于 2020-01-04 18:02:10
问题 How do i create another column called vwap which calculates the vwap if my table is as shown below? time bid_size bid ask ask_size trade trade_size phase 0 2019-01-07 07:45:01.064515 495 152.52 152.54 19 NaN NaN OPEN 1 2019-01-07 07:45:01.110072 31 152.53 152.54 19 NaN NaN OPEN 2 2019-01-07 07:45:01.116596 32 152.53 152.54 19 NaN NaN OPEN 3 2019-01-07 07:45:01.116860 32 152.53 152.54 21 NaN NaN OPEN 4 2019-01-07 07:45:01.116905 34 152.53 152.54 21 NaN NaN OPEN 5 2019-01-07 07:45:01.116982 34

Convert from R to quantstrat setup for trading strategy backtesting

丶灬走出姿态 提交于 2019-12-30 05:34:05
问题 I am trying to backtest a trading strategy with "quantstrat" package. My strategy is composed by 4 indicators, 3 different EMAs and 1 lagged EMA. I want to go long when: EMA1 > EMA2 & EMA1 > EMA3 & EMA1_lag < EMA1 I want to exit and go flat when: EMA1 < EMA3 It's pretty simple but I am not able to write it into quantstrat environment. Here's a data integrity check function used in both examples: # Data integrity check checkBlotterUpdate <- function(port.st,account.st,verbose=TRUE) { ok <-