According to Forecasting of Jump Arrivals in Stock Prices: New Attention-based Network Architecture using Limit Order Book Data at page 9, I would be interested in derivating the the price and volume, but I am struggling how to do it. So far I tried nothing, because I just don't know where to start and how to do it.
How can I derive the price and the volume with python?
Related
I have a data frame and I want to write a function to optimize for profit. The data is organized by entry date. Here are the rules I want to use:
look at a trade by trade number
if there are no overlapping trades going on, complete the trade and take profit
if there is an overlapping trade do not take the trade
end result would be the same dataframe with a column for took trade or not, and if took trade, then the profit. I've attached a picture of the dataframe []
This is the base function I want to build off of but I'm having trouble getting started.
I am new to Backtrader and I can't figure out how to write the following strategy:
Every morning it places a limit buy order at 80% of Open price. If the order is executed during the day (i.e. Low price < the limit price for that day), then sell the stock at Close.
I am using Yahoo's OHLC daily data.
Can any one show me how to write the Strategy part of the code? I posted a similar question on BT's official forum but couldn't get an answer.
Thanks.
I'm interested pulling the hypothetical growth, including reinvested dividends, from the yahoo finance api. I wrote the following code that pulls the hypothetical growth in NOT including the dividends:
import yfinance as yf
data = yf.download("MSFT", '2015-01-01', '2021-09-10')['Adj Close']
ROI = (data[-1] - data[0]) / data[0]
print ("ROI:", ROI)
Is there data that factors in reinvested dividends available on their API somewhere, or do I need to go through the painstaking process of figuring out what the paid dividends were for each quarter, and factoring that in one quarter at a time inside a loop?
First, Your phrase "hypothetical growth" is confusing since your using "AdjClose" data. This is not hypothetical.
Second, You're mistaken. Your understanding of what "AdjClose" represents is wrong. This value exists so that it does include changes to the stock such as dividends and stock splits.
For details refer to yahoo's knowledge base
Yahoo's definition for Adj. Close
However, if you're interested in comparing the changes(GROWTH) between Closing prices and "AdjClose", there is an easy math solution.
simply divide all Closing Prices by the first Closing Price in the series. This will give you the relative change and the normalized growth rate.
perform the same method to the "AdjClose" series. Now you'll see that these ratios are larger, which of course include the changes due to dividends and stock splits. These two ratios can now be directly compared.
If you wish to see the total changes in value, these are also simple calculations. But there are several results to consider and compute: a. simple stock price changes, b. accumulated prices + dividends without reinvestment, c. reinvesting accumulated prices + dividends + stock splits.
However providing you with specific code would require that you narrow your question.
I've go dataset with more than 10 features - football skills describing players. There is also price value in each row. I would like to predict price by specifying features (skills). Initially I used linear regression, but it looks like it's not a good choice because:
price is high if only three skills are high (pace, goalkeeper, passing) for goalkeeper
price is high if defender, pace, playmaker and technique are high for defender
price is high if striker, technique and pace are high together for striker
etc... so it's not just linear dependency because not all skills should be considered for goalkeepers, defenders etc. Specific combination of skills makes the price high. I don't know how to tackle this and predict price by providing skills (all 10+). Do you maybe have ideas? Thanks!
I am looking to retrieve historical data like P/E ratio, earnings, book value etc as well as stock price. I'd like to go through a whole bunch of stocks programmatically or to possibly select historical stocks based on valuation rules.
I found a few python packages to download historical stock prices from Yahoo like yahoo-finance and also this guide to downloading historical prices with the browser. But I could not find anything to download historical valuation data.
I am aware of Survivorship Bias problem with the stocks that affects these free services but I can't afford a paid one right now.