Skip to content

Commit

Permalink
Add price mixing
Browse files Browse the repository at this point in the history
  • Loading branch information
nitko12 committed Mar 1, 2024
1 parent 7660e1c commit 4058340
Show file tree
Hide file tree
Showing 9 changed files with 2,460 additions and 10,374 deletions.
1 change: 1 addition & 0 deletions backend/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bots:
max_price_change: 20
expiration_ticks: 5
price_change_coeff: 0.05
dataset_price_weight: 0.5

max_energy_per_player: 0.2

Expand Down
2,332 changes: 0 additions & 2,332 deletions backend/data/df_2331_2009-05-05 08:30:00_2009-08-10 10:30:00.csv

This file was deleted.

2,432 changes: 2,432 additions & 0 deletions backend/data/df_2431_2011-11-06 03:30:00_2012-02-15 09:30:00.csv

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion backend/db/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ async def run_migrations():
biomass INT NOT NULL,
gas INT NOT NULL,
oil INT NOT NULL,
coal_price INT NOT NULL,
uranium_price INT NOT NULL,
biomass_price INT NOT NULL,
gas_price INT NOT NULL,
oil_price INT NOT NULL,
geothermal INT NOT NULL,
wind INT NOT NULL,
solar INT NOT NULL,
Expand Down Expand Up @@ -230,7 +235,12 @@ async def run_migrations():
solar=row["SOLAR"],
hydro=row["HYDRO"],
energy_demand=row["ENERGY_DEMAND"],
max_energy_price=row["MAX_ENERGY_PRICE"]
max_energy_price=row["MAX_ENERGY_PRICE"],
coal_price=row["COAL_PRICE"],
uranium_price=row["URANIUM_PRICE"],
biomass_price=row["BIOMASS_PRICE"],
gas_price=row["GAS_PRICE"],
oil_price=row["OIL_PRICE"]
)
i += 1
logger.info(f"Added dataset {x}")
Expand Down
11 changes: 11 additions & 0 deletions backend/game/bots/resource_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ async def run(self, tick_data: TickData):
orders = await self.get_last_orders()

for resource in Resource:
if resource == Resource.energy:
continue

resource_orders = orders[resource]
resource_sum = resources_sum[resource]
buy_price = self.buy_prices[resource]
Expand Down Expand Up @@ -79,11 +82,19 @@ async def run(self, tick_data: TickData):
if buy_price == sell_price:
buy_price = sell_price - 1

buy_price = self.mix_dataset_price(
tick_data.dataset_row, buy_price, resource)
sell_price = self.mix_dataset_price(
tick_data.dataset_row, sell_price, resource)

await self.create_orders(tick_data.game.current_tick,
resource, buy_price, sell_price, buy_volume, sell_volume)
self.buy_prices[resource] = buy_price
self.sell_prices[resource] = sell_price

def mix_dataset_price(self, dataset_row, price, resource):
return config['bots']['dataset_price_weight'] * dataset_row[resource.name.lower() + "_price"] + (1 - config['bots']['dataset_price_weight']) * price

def get_filled_perc(self, orders: List[Order]):
size = {side: 0 for side in OrderSide}
filled_size = {side: 0 for side in OrderSide}
Expand Down
5 changes: 5 additions & 0 deletions backend/model/dataset_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class DatasetData(Table):
wind: int
solar: int
hydro: int
coal_price: int
uranium_price: int
biomass_price: int
gas_price: int
oil_price: int
energy_demand: int
max_energy_price: int

Expand Down
2,332 changes: 0 additions & 2,332 deletions dataset/chunks/df_2331_2009-05-05 08:30:00_2009-08-10 10:30:00.csv

This file was deleted.

2,438 changes: 0 additions & 2,438 deletions dataset/chunks/df_2437_2010-07-28 13:30:00_2010-11-07 01:30:00.csv

This file was deleted.

3,271 changes: 0 additions & 3,271 deletions dataset/chunks/df_3270_2010-03-14 04:30:00_2010-07-28 09:30:00.csv

This file was deleted.

0 comments on commit 4058340

Please sign in to comment.