Python and Statistics for Financial Analysis
Python and Statistics for Financial Analysis
Pandas Knowledge
-
What does shift() in
Pandasmean?shift(-1)means to move upwards by one row. -
List Comprehension:
fb['Direction']=[1 if fb[ei,'PriceDiff'] > 0 else -1 for ei in fb.index] -
fb['MovingAverage] = (fb + fb.shift(1) + fb.shift(2)) / 3Move downwards to get the previous data.
Financial Knowledge
PriceDiff = Close_Price_Of_Tomorrow - Close_Price_Of_Today
DailyReturn = PriceDiff / Close_Price_Of_Today
Direction :=
- PriceDiff Up 1
- PriceDiff Down -1
MovingAverage = (Close_Price_Of_The_Day_Before_Yesterday + Close_Price_Of_Yesterday + Close_Price_Of_Today) / 3