1

I am trying to display dividends with yfinance inside a notion table row with notion-py

here is the code I am using

from notion.client import NotionClient
from datetime import datetime
import pandas as pd

client = NotionClient(token_v2="mytoken")

cv = client.get_collection_view("tablepageurl")

data = pd.DataFrame()
stock_list = ['XSH.TO', 'ZFL.TO','EEMV', 'ACWV', 'XEF.TO', 'XIC.TO', 'VTI']

start = '2019-10-1'
end = '2020-10-30'

for i in stock_list:
 series = yf.Ticker(i).dividends.loc[start:end]
 data = pd.concat([data, series], axis=1)
 row = cv.collection.add_row()

 row.shmoney = stock_list

tickers = ('XSH.TO', 'ZFL.TO','EEMV', 'ACWV', 'XEF.TO', 'XIC.TO', 'VTI')
for ticker in tickers:
 price = yf.Ticker(ticker)
 row = cv.collection.add_row()
 
 

 hist = price.history(period="1d")
 row.SYMBL = ticker
 row.DayReturn = float(round(((hist.Close[0]) - (hist.Open[0]) ) / (hist.Open[0])*100,2))  

I get prompted with this error

File "/Users/ajj/Documents/NotionStockAPI/notionapi_env/lib/python3.9/site-packages/notion/collection.py", line 583, in _convert_python_to_notion
    raise TypeError(
TypeError: Value passed to property 'shmoney' must be an int or float.

"shmoney" is the name of the table row in Notion, I was playing around with the names because I thought the names were conflicted with the code (I am really lost)

when I take out

from notion.client import NotionClient
from datetime import datetime
import pandas as pd

client = NotionClient(token_v2="mytoken")

cv = client.get_collection_view("tablepageurl")

data = pd.DataFrame()
stock_list = ['XSH.TO', 'ZFL.TO','EEMV', 'ACWV', 'XEF.TO', 'XIC.TO', 'VTI']

start = '2019-10-1'
end = '2020-10-30'

for i in stock_list:
 series = yf.Ticker(i).dividends.loc[start:end]
 data = pd.concat([data, series], axis=1)
 row = cv.collection.add_row()

 row.shmoney = stock_list

Everything Lists itself fine.

AJJ
  • 11
  • 1

0 Answers0