r"""Calculate the gap percentage between the current open and the previous close. Parameters ---------- f : pandas.DataFrame Dataframe with columns ``open`` and ``close``. Returns ------- new_column : pandas.Series (float) The array containing the new fe
(f)
| 554 | # |
| 555 | |
| 556 | def gap(f): |
| 557 | r"""Calculate the gap percentage between the current open and |
| 558 | the previous close. |
| 559 | |
| 560 | Parameters |
| 561 | ---------- |
| 562 | f : pandas.DataFrame |
| 563 | Dataframe with columns ``open`` and ``close``. |
| 564 | |
| 565 | Returns |
| 566 | ------- |
| 567 | new_column : pandas.Series (float) |
| 568 | The array containing the new feature. |
| 569 | |
| 570 | References |
| 571 | ---------- |
| 572 | *A gap is a break between prices on a chart that occurs when the |
| 573 | price of a stock makes a sharp move up or down with no trading |
| 574 | occurring in between* [IP_GAP]_. |
| 575 | |
| 576 | .. [IP_GAP] http://www.investopedia.com/terms/g/gap.asp |
| 577 | |
| 578 | """ |
| 579 | c1 = 'open' |
| 580 | c2 = 'close[1]' |
| 581 | vexec(f, c2) |
| 582 | new_column = 100 * pchange2(f, c1, c2) |
| 583 | return new_column |
| 584 | |
| 585 | |
| 586 | # |