How CloudQuant Mariner Works
CloudQuant is a system that allows you to backtest your trading ideas against historical market data. CloudQuant is based around scripts, which are special Python files that quants create to represent their trading ideas. CQ scripts are not normal Python scripts in that they do not execute by themselves (they have no main function) - they only contain methods that are called by the backtesting system when a simulated event occurs. One could say that CloudQuant scripts react to market events rather than performing actions on their own. When you schedule a backtest through CloudQuant, the system goes through every trading event that happened on the requested testing day (including individual trades, NBBO price changes, exchange imbalances, etc.) related to the symbols your script deals with and calls appropriate methods in your script for each event.
CloudQuant scripts all have a main class that inherits from the Strategy class contained in the cloudquant.interfaces package. This class contains the methods that the backtesting system calls to react to market events. All of these methods take specific parameters including order, account, and event that represent market data and event information provided to your script by the backtesting system. Most of these methods have names of the form on_event, for example on_start and on_timer. The logic of your trading strategy is contained within these methods - for example, you may want to schedule something to happen at a certain time in the trading day - this would go in on_timer. Note that not all of these Strategy methods are available to CQ Lite users - they will be unlocked once you progress to CQ Elite status. Because CQ scripts are fully qualified Python classes, they can store state, and you are free to define instance variables, your own methods, and even your own classes if you so wish. We also have support in the backtesting system for many popular scientific Python libraries including numpy and pandas.