-
Notifications
You must be signed in to change notification settings - Fork 10
Concepts
The TradingEngine
actor is the main class for running Flashbot. Starting a new trading engine is as simple as:
// Start the Akka system
val system = ActorSystem("trading-system", FlashbotConfig.load.akka)
// Load the trading engine
val engine = system.actorOf(TradingEngine.props("my-engine"))
You can now send requests to the engine:
implicit val timeout = Timeout(5 seconds)
val pong = Await.result(engine ? Ping, timeout.duration) // = Pong(<timestamp>)
The typical use case is to send strategy backtest requests to the engine, as well as to manage running bots by configuring, starting, and stopping them in either "live" or "paper" mode.
Read the source for a full overview of the supported commands.
A TradingSession
is the container in which a strategy runs. It is used for both backtests and live/paper trading.
Read the source of the TradingSessionActor
to fully understand how a TradingSession
streams data to a Strategy
and how a Strategy
interacts with the session.
A DataServer
is an actor that responds to market data requests. There is always one data server that is local to a TradingEngine (one will be created by default if not supplied) and there may also be any number of remote DataServer
actors in the cluster that provide additional data sets.
Read the source for to get an idea of how it runs.
A Strategy
is a class that contains the logic of a trading algorithm. By definition, it does not know if it's running in backtest, paper trading, or live trading mode.
Read the source of an example strategy that is used in our unit tests. This is a strategy that sources itself with a randomly generated data stream of OHLC data and "cheats" by looking ahead by one time step to make a profitable trade. This is used in testing to ensure that a strategy with perfect information of the future never makes an unprofitable trade.