Fixed Google Colab link in week 3 day 4, and latest week 8 updates
This commit is contained in:
24
week8_wip/agents/planning_agent.py
Normal file
24
week8_wip/agents/planning_agent.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from agents.deals import Deal, QualityDealSelection, Opportunity
|
||||
|
||||
from agents.scanner_agent import ScannerAgent
|
||||
from agents.ensemble_agent import EnsembleAgent
|
||||
from agents.messaging_agent import MessagingAgent
|
||||
|
||||
|
||||
class PlanningAgent:
|
||||
|
||||
def __init__(self, collection):
|
||||
self.scanner = ScannerAgent()
|
||||
self.ensemble = EnsembleAgent(collection)
|
||||
self.messenger = MessagingAgent()
|
||||
|
||||
def plan(self):
|
||||
opportunities = []
|
||||
deal_selection = self.scanner.scan()
|
||||
for deal in deal_selection.quality_deals[:5]:
|
||||
estimate = self.ensemble.price(deal.product_description)
|
||||
opportunities.append(Opportunity(deal, estimate, estimate - deal.price))
|
||||
opportunities.sort(key=lambda opp: opp.discount, reverse=True)
|
||||
print(opportunities)
|
||||
if opportunities[0].discount > 50:
|
||||
self.messenger.alert(opportunities[0])
|
||||
Reference in New Issue
Block a user