-
-
Save rahulmr/5ffee2a666df8c0cf71fad2bc7277ca1 to your computer and use it in GitHub Desktop.
Add row to pandas_ta dataframe and recompute
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import pandas_ta as ta | |
| from dateutil import parser | |
| df = pd.read_csv('AUD_CAD.csv', sep=',', names=[ | |
| 'datetime', 'bid_open', 'bid_high', 'bid_low', 'bid_close', 'ask_open', 'ask_high', 'ask_low', 'ask_close', 'mid_open', 'mid_high', 'mid_low', 'mid_close', 'volume'], error_bad_lines=False, parse_dates=['datetime']) | |
| df.ta.atr(append=True, high='bid_high', low='bid_low', close='bid_close') | |
| print(df) | |
| newdt = parser.isoparse('2020-08-11 21:00:00+00:00') | |
| newrow = {'datetime': newdt, 'bid_open': 0.94971, 'bid_low': 0.94955, 'bid_high': 0.94982, 'bid_close': 0.94969, 'ask_open': 0.94973, 'ask_high': 0.95532, | |
| 'ask_low': 0.94957, 'ask_close': 0.95031, 'mid_open': 0.95472, 'mid_high': 0.95738, 'mid_low': 0.94949, 'mid_close': 0.94998, 'volume': 112333} | |
| df = df.append(newrow, ignore_index=True) | |
| df.ta.atr(append=True, high='bid_high', low='bid_low', close='bid_close') | |
| print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment