'Detecting stock prices that are easy to go up and down in a short period
I'm trying to use python to detect if the price of a stock is easy to go up and down in a short period.
The yellow line in the following pictures are the stock prices:
The above 2 stock prices are considered to be easy to go up and down for me.
The following stock prices are not.
I have all deal prices of the stocks.
I've tried normalize the stock price then calculate its standard deviation.
import pandas as pd
today = date.today().strftime('%Y-%m-%d')
ticks = api.ticks( # api is an object from shioaji API
contract=api.Contracts.Stocks[ticker_code],
date=today
)
# The type of ticks.close is "list"
pclose = pd.Series(ticks.close)
# normalized_std is used to decide if the stock price is easy to go up and down in a short period.
normalized_std = (pclose/pclose.mean()).std(ddof=0)
But the result is not good.
For example, pic1's normalized_std is 0.013441217877894908, pic2's normalized_std
is 0.011078299230201987. But pic3's normalized_std is 0.02169184908826346, and pic5's normalized_std is 0.0014295901932196125.
So it's hard to decide if the price is too easy to go and down by using normalized_std variable.
Anyone knows if there's a method to detect this kind of stock price patterns?
Can machine learning be applied to solve this problem?
Solution 1:[1]
Just an idea, but it looks like you want a lot of absolute movement, with little relative movement. For example down $1.10, up 1, down $0.90 up $1.10
Absolute movement would be the sum of the absolute value of the moves:
1.10 +1+0.9+1.10 =$4.10
Relative movement would be the sum of the moves:
-1.10 + 1 - 0.90 + 1.10 = 0.10
A fancier method, if you have access to real-time quotes, is to calculate the price of a short expiration straddle (the price of the at the money put and call), it is good indicator of expected movement.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tony BenBrahim |





