Data Providers
A Botmain strategy receives its data from data subscriptions from the
There are 4 types of data providers that your strategy can subscribe to.
: a low-frequency stream ofDailyBarsProvider
objects with daily periodicityBar
: a medium-frequency stream ofIntradayBarsProvider
objects with seconds, minutes, or hours periodicity.Bar
: a high-frequency stream ofTicksProvider
objects from raw market data supplied as bids, asks, and trades.Quote
: a taxonomy of non-pricing attributes with periodicities from seconds to annual.FundamentalsProvider
To subscribe to any of these providers, simply @Inject()
one or more of them into your strategy:
import { DailyBarsProvider , IntradayBarsProvider , TicksProvider , FundamentalsProvider , InstrumentProcessorBase } from "@botmain/common";
export class InstrumentProcessor extends InstrumentProcessorBase {
@Inject() override daily: DailyBarsProvider ;
@Inject() override bars: IntradayBarsProvider ;
@Inject() override quotes: TicksProvider ;
@Inject() override fundamentals: FundamentalsProvider ;
}
By injecting any of these providers, you will be required to configure some parameters when running your strategy in the GUI. Some common parameters include specifying the data stream from the stackSize
, which is the maximum number of historical data points available to the strategy via lookback.
Timeframes
The
provides your strategy with bars of daily periodicity. For medium and long-term strategies, daily bars are typically enough and allow your strategy to process less data, resulting in faster backtests.
In general, your strategy needs only to subscribe to one price provider for the lowest resolution that it needs for its logic. For example, if your strategy requires 30-minute bars, there is no need to include a
, since daily bars will be aggregated from 30-minute bars using the
(that you need anyways). Similarly, if your strategy includes a
, then it doesn't need an
, since any periodicity of bars can be aggregated from tick data. In both cases, your strategy will still have access to the
and
objects, even if you haven't configured a bars provider directly.
Warm-up
When a strategy is started in real-time mode, it may be configured to have a historical warm up.
During warm up, the strategy receives historical data for the given amount of time preceding the current time. It may be useful if the strategy needs historical data to prepare indicators or some statistics before trading. At the end of the warm up, but before actual real-time data will be sent to the strategy, it receives a special WarmUpEnd
event.
From the strategy point of view, working in warm up is very close to working with real time market data. Strategy receives all events and can work with most Botmain objects. However there are some key differences in warm up mode:
• Historical data is sent to the strategy in warm up mode faster than real-time speed. Consequently using Date.now()
and other properties related to local computer time may give undesired results. If possible, it is always better to use computer-independent Botmain time properties like
.
• During warm up, the strategy can't issue, cancel, cancel, replace, or modify an order. Any call to these methods will result in an exception.