I want to smooth the stock data. which ignore the day price gap in the openning, make the price curve smooth in the whole period
Let me list an example:
[5]: df = pd.DataFrame([['20190101',2], ['20190101', 3], ['20190102',5], ['20190102', 4], ['20190103', 3], ['20190103', 2]], columns=['date', 'pric ...: e']) In [6]: df Out[6]: date price 0 20190101 2 1 20190101 3 2 20190102 5 3 20190102 4 4 20190103 3 5 20190103 2
above is a stock price dataframe, what i want is to ignore the price gap during day open.
that means the price difference between last one in 20190101 (3) and first one in 20190102(5), 3-5 = -2 is what i want to ignore.
my ignore method is to minus the difference between today and yesterday, which means the expected data should be:
[8]: df Out[8]: date price 0 20190101 3 1 20190101 3 2 20190102 3 3 20190102 2 4 20190103 2 5 20190103 1
the data in 20190102 is original data(5, 4) - 2(the difference between today and yesterday), so it's 3, 2
is there any good methods can do this?
https://stackoverflow.com/questions/66072906/how-to-smooth-stock-data-by-pandas-elegantly February 06, 2021 at 10:03AM
没有评论:
发表评论