Fixed some issues, store dates in utc.
This commit is contained in:
@ -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)
|
||||
|
||||
|
@ -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)
|
Reference in New Issue
Block a user