class MyStrategy : Strategy { (1)
override fun createSignals(event: Event): List<Signal> {
TODO() // Your code goes here
}
}
val strategy = MyStrategy() (2)
val feed = CSVFeed("./data/stocks") (3)
val account = run(feed, strategy) (4)
println(account.equity()) (5)
Tutorial
Why use roboquant
Developing and running algo-trading software is not an easy task at all. You already need additional skills, and on top of that, there is a lot of complexity involved that isn’t perhaps clear from the beginning.
So it makes sense to separate the logic that is common to all automated trading strategies from the logic that is specific to your strategy.
Roboquant supports all 4 stages of developing a trading strategy with minimal changes to your code.
Main components
Perhaps the most important part of using roboquant is to understand the sequence of steps and the responsibility each component has in this flow. The following provides a logical overview of the main parts and the data they produce and consume.
Feed ==event⇒ Strategy ==signal⇒ Trader ==order⇒ Broker ==account⇒
The role and responsibilities of the components are as follows:
-
FeedProvides the data needed for testing and trading. The data is provided as series of events that are published. A feed can represent both historic and live data and is not restricted to pricing data only.
-
StrategyReceives the
eventand generates zero or more s. An instruction can be a new order, but also the cancellation/update of an existing order. -
BrokerReceives the newly created orders and processes them. Any open orders received in previous steps will also be processed until they are closed. After the processing of the orders, it will return an updated account that reflects the latest state.
-
JournalReceives the latest state of the account and log metrics that are of interest. This provides additional insights into what is happening during a run.
Development
Developing a new strategy and validating it with a back-test is a straightforward process. The code snippet below shows the different steps that you have to take to develop and run your strategy.
| 1 | Develop a new strategy based on some ideas you have. This can be done either from scratch or by assembling existing building blocks. In many cases, this is the only real software development required. See also Strategy for more details. |
| 2 | Create an instance of your strategy. |
| 3 | Pick the data feed you want to use to test your strategy. |
| 4 | Run the back test using the data feed you just created. |
| 5 | Print how much equity we have at the end of the run (we start by default with $1.000.000) |
The roboquant platform is flexible and provides many more options than the above example shows. You can change almost any aspect of the platform if the default behavior doesn’t suit your needs.
This might mean that the learning curve is steeper than a simpler platform. But in our experience, this is required to be able to develop robust automated trading solutions.