some things work
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
from ..exchange import Exchange
|
||||
from ..commoditys import commoditys as cm
|
||||
from lightmatchingengine.lightmatchingengine import Side
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +24,12 @@ class Cell:
|
||||
exchange: None
|
||||
|
||||
def __init__(self,name,x,y,area,pop,demand,world) -> None:
|
||||
pop=pop*1000
|
||||
self.name=name
|
||||
self.loc_x=x
|
||||
self.loc_y=y
|
||||
self.area=area
|
||||
self.pop=pop*1000
|
||||
self.pop=pop
|
||||
self.demand_tags=demand
|
||||
self.demand={}
|
||||
self.world_tags=world
|
||||
@@ -55,6 +57,21 @@ class Cell:
|
||||
else:
|
||||
self.world[k]+=v*area
|
||||
|
||||
def setup_demand_for_step(self,episode_length):
|
||||
pop_per_step=self.pop/episode_length
|
||||
for demand_key,value in self.demand.items():
|
||||
qty=value/episode_length
|
||||
comm=cm.commoditys[demand_key]
|
||||
max_price=comm["max_world_price"]*qty
|
||||
self.exchange.add_to_account(self.name,"balance",max_price)
|
||||
self.exchange.submit_order(self.name,demand_key,qty,comm["max_world_price"],Side.BUY)
|
||||
def setup_supply_for_episode(self):
|
||||
self.exchange.reset()
|
||||
for supply_key,value in self.world.items():
|
||||
self.exchange.add_to_account(self.name,supply_key,value)
|
||||
self.exchange.submit_order(self.name,supply_key,value,0,Side.SELL)
|
||||
|
||||
|
||||
|
||||
def create_cells_from_world_cells(cells) -> list:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user