-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
|
||
from poptimizer.domain import domain | ||
from poptimizer.domain.dl.features import EmbeddingSeqFeatDesc, EmbSeqFeat, Features | ||
from poptimizer.domain.portfolio import portfolio | ||
from poptimizer.use_cases import handler | ||
|
||
|
||
class YearDayFeatHandler: | ||
async def __call__(self, ctx: handler.Ctx, msg: handler.IndexFeatUpdated) -> handler.YearDayFeatUpdated: | ||
async with asyncio.TaskGroup() as tg: | ||
port = await ctx.get(portfolio.Portfolio) | ||
|
||
for pos in port.positions: | ||
tg.create_task(_create_year_day_feat(ctx, domain.UID(pos.ticker), msg.trading_days)) | ||
|
||
return handler.YearDayFeatUpdated(day=msg.day) | ||
|
||
|
||
async def _create_year_day_feat(ctx: handler.Ctx, ticker: domain.UID, trading_days: domain.TradingDays) -> None: | ||
feat = await ctx.get_for_update(Features, ticker) | ||
|
||
feat.embedding_seq[EmbSeqFeat.year_day] = EmbeddingSeqFeatDesc( | ||
sequence=[trading_days[-n].timetuple().tm_yday for n in reversed(range(1, len(feat.numerical) + 1))], | ||
size=366, | ||
) |
This file contains 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