An interpreted language for stochastic market simulation and algorithmic trading.
AuctoScript is a complete platform for simulating stochastic auction markets. It consists of a TCP-based multiplayer auction server (C), a custom scripting language interpreter for writing automated trading bots (C++), and a Python toolkit for orchestrating competitions, visualizing results, and developing strategies.
The project implements the stochastic auction model described in:
Model of stochastic auctions using level market index Nikonov M., Shishkin A., Konev D., Dolmatov A. Financial Statistical Journal, 2023 DOI link
- Custom scripting language — AuctoScript (
.as) is algorithmically complete with variables, arrays, loops, conditionals, and a built-in market API - Multiplayer TCP server — connects any number of bots (or human players via telnet) for head-to-head competition
- Two market modes — built-in stochastic model or replay from real FINAM/OHLCV data files
- Python Arena — orchestrate bot-vs-bot competitions with a single function call
- Live dashboard — real-time matplotlib charts for price, balance, and holdings
- Multi-language clients — connect from Python, Java, Julia, or Scala via TCP
|
AuctoScript is a domain-specific language designed for writing trading strategies. Programs run in a loop — once per market tick — and interact with the server through built-in functions prefixed with Variables use Full language reference: docs/LANGUAGE.md |
The built-in viewer provides real-time charts showing market price, player balances, and stock holdings during a simulation. Works with both live arenas and replayed protocol files.
git clone https://github.com/charonviz/AuctoScript.git
cd AuctoScript
make all
pip install -e .from auctoscript import Arena
arena = Arena(
strategies=[
"examples/strategies/smart_trader.as",
"examples/strategies/simple_buyer.as",
],
port=4000,
)
arena.run()
for entry in arena.leaderboard():
print(f"#{entry['rank']} {entry['strategy']} — ${entry['money']:,}")Start the server:
# Stochastic model (no data file)
./build/bin/auctoscript-server 3000 2
# Replay from FINAM data
./build/bin/auctoscript-server-finam 3000 2 examples/data/SBER_sample.csvConnect bots:
./build/bin/auctoscript-interpreter 0 3000 examples/strategies/smart_trader.as
./build/bin/auctoscript-interpreter 0 3000 examples/strategies/simple_buyer.asOr connect as a human player via telnet:
telnet localhost 3000from auctoscript import Viewer
viewer = Viewer(players=2)
viewer.show_dashboard()AuctoScript/
├── src/
│ ├── server/
│ │ ├── server.c # Stochastic model server
│ │ └── server_finam.c # FINAM data replay server
│ └── interpreter/
│ └── interpreter.cpp # AuctoScript language interpreter
├── auctoscript/ # Python package
│ ├── __init__.py
│ ├── server.py # Server process manager
│ ├── bot.py # Bot process manager
│ ├── arena.py # Multiplayer orchestrator
│ ├── viewer.py # Real-time visualization
│ └── data.py # Sample dataset management
├── examples/
│ ├── strategies/ # Example .as strategy scripts
│ │ ├── smart_trader.as
│ │ └── simple_buyer.as
│ └── data/ # Sample market data (OHLCV)
├── bindings/
│ ├── java/ # Java TCP client (planned)
│ ├── julia/ # Julia TCP client (planned)
│ └── scala/ # Scala TCP client (planned)
├── docs/
│ └── LANGUAGE.md # AuctoScript language reference
├── tests/
├── Makefile
├── pyproject.toml
└── LICENSE
from auctoscript import Server
# Context manager — auto-stops on exit
with Server(port=3000, players=2) as server:
# ... connect bots ...
server.wait()
# With real market data
server = Server(port=3000, players=2, data_file="data/SBER.csv")from auctoscript import Bot
bot = Bot("strategies/smart_trader.as", port=3000)
bot.start()
bot.wait()from auctoscript import Arena
arena = Arena(
strategies=["smart.as", "simple.as", "random.as"],
port=5000,
data_file="examples/data/EURUSD_sample.csv", # optional replay mode
)
arena.run(timeout=60) # optional timeout in seconds
print(arena.leaderboard())from auctoscript import Viewer
viewer = Viewer(players=3)
viewer.show_price() # price chart only
viewer.show_money() # all player balances
viewer.show_dashboard() # full 3-panel dashboard
viewer.snapshot("out.png") # save static imageThese commands are available to any TCP client (bots, telnet, or custom clients):
| Command | Description |
|---|---|
market |
Current market state (supply, demand, prices) |
player <id> |
Info about a specific player |
me |
Your own player info |
buy <count> <price> |
Place a buy order for raw materials |
sell <count> <price> |
Place a sell order for products |
prod <count> |
Convert raw materials into products |
build |
Build a new factory (costs money) |
turn |
End your turn |
help |
List available commands |
Create a .as file with your trading logic:
{
// Simple momentum strategy
$price = ?raw_price();
$my_money = ?money(?my_id());
if $price < $last_price {
?buy(3, $price);
};
if $price > $last_price {
?sell(?production(?my_id()), ?production_price());
};
?prod(?raw(?my_id()));
$last_price = $price;
}
end
Test it in an arena:
from auctoscript import Arena
arena = Arena(strategies=["my_strategy.as", "examples/strategies/smart_trader.as"])
arena.run()Requirements: GCC, G++, Python 3.9+, Make.
make all # build server + interpreter
make server # server only
make interpreter # interpreter only
make clean # remove build artifactsAuctoScript uses a plain TCP protocol — any language that can open a socket can play. See the bindings/ directory for client examples in Java, Julia, and Scala.
# Even a raw Python socket works
import socket
s = socket.socket()
s.connect(("localhost", 3000))
s.send(b"market\n")
print(s.recv(1024).decode())If you use AuctoScript in research, please cite:
@article{nikonov2023stochastic,
title={Model of stochastic auctions using level market index},
author={Nikonov, Maksim and Shishkin, Alexei and Konev, Dmitry and Dolmatov, Aleksandr},
journal={Financial Statistical Journal},
year={2023},
publisher={EnPress Publisher},
url={https://systems.enpress-publisher.com/index.php/FSJ/article/view/2931}
}MIT — Copyright (c) 2023-2025 Maksim Nikonov. See LICENSE.


