bfolkens / py-market-profile

A library to calculate Market Profile (aka Volume Profile) for financial data from a Pandas DataFrame.
Other
356 stars 122 forks source link

TypeError: write() argument must be str, not bytes #17

Closed Faustopheles closed 1 year ago

Faustopheles commented 1 year ago

Hello, hope the author is still active. I have use "pip install marketprofile", then download both the [example.ipynb] and [google_finance.py] to the same folder. When I run [example.ipynb], this error occurs :

TypeError Traceback (most recent call last) [c:\Users\Admin\Google](file:///C:/Users/Admin/\Market Profile test\example.ipynb Cell 3 line 2 [1](vscode-notebook-cell:/c%3A/Users/Admin//Market%20Profile%20test/example.ipynb#W2sZmlsZQ%3D%3D?line=0) if not os.path.exists('google.txt'): ----> 2 get_google_data('google.txt', 'GOOG', 60 * 30, 5) 4 df = read_google_data('google.txt')

File [c:\Users\Admin\Google](file:///C:/Users/Admin/***\Market Profile test\google_finance.py:18, in get_google_data(file_path, symbol, interval, days) 15 r = requests.get(url) 17 with open(file_path, 'w') as out: ---> 18 out.write(r.content)

TypeError: write() argument must be str, not bytes

I'm relatively new to python, so it can be some simple fix. Would be appreciated if there is a solution to this error

bfolkens commented 1 year ago

Hi @Faustopheles - this is an issue with Python 3 (it needs an explicit 'binary' option in the file open. If you experience other errors, you might want to try running it with Python 2.7 in the meantime...