Fixed some issues, store dates in utc.

This commit is contained in:
2020-04-18 23:52:27 +03:00
parent 6230d8392c
commit 4c010f2174
11 changed files with 48 additions and 54 deletions

View File

@ -11,7 +11,7 @@ from plugins.plugin import Plugin
class Robor(BaseModel):
date = DateField(index=True, default=datetime.date.today(), null=False)
date = DateField(index=True, default=datetime.date.today, null=False)
field = TextField(null=False)
value = FloatField(null=False)

View File

@ -10,7 +10,7 @@ import yfinance as yf
class Stocks(BaseModel):
date = DateTimeField(index=True, default=datetime.datetime.now(), null=False)
date = DateTimeField(index=True, default=datetime.datetime.utcnow, null=False)
ticker = TextField(null=False)
label = TextField(null=False)
value_open = FloatField(null=False)
@ -29,6 +29,7 @@ class StocksPlugin(Plugin):
for ticker, label in config.STOCKS_TICKERS.items():
# Get last existing date
latest_date = Stocks.select(Stocks.date) \
.where(Stocks.ticker == ticker) \
.order_by(Stocks.date.desc()) \
.limit(1) \
.scalar()
@ -51,6 +52,6 @@ class StocksPlugin(Plugin):
entry.value_high = row.High
entry.value_low = row.Low
entry.save()
print(model_to_dict(entry))
except BaseException as e:
print(e)