Connect a data source
MindsDB can connect to any source of data - a database, warehouse, stream or app. Here, we’ll connect to Binance API to get a feed of real-time price information.Deploy a time-series model
The Binance trade data is updated every minute. As a trader, you might want to predict the open prices for the next 10 minutes - so let’s set it up. We’ll use a forecasting engine called Lightwood for ease and speed but you’re also able to train your own model if you like.CREATE MODEL
statement:
-
CREATE MODEL
: It is used to create, train, and deploy an ML model. By default, MindsDB’s AutoML will automatically choose the best model for your data but this can be overridden (docs). -
FROM
: Here, we specify which of our integrations to use. Anything that is between the parentheses is the data that will be used to train the model - here, the latest Binance data from the connection we’ve already made to Binance is used. -
PREDICT
: It specifies the target column - here, the open price of the BTC/USDT trading pair is to be forecasted.
- As it is a forecasting model, you should use ORDER BY to order the data by a date column - here, it is the open time when the open price takes effect.
-
The
WINDOW
clause defines the window the model looks back at while making forecasts - here, the model looks back at sets of 100 rows (intervals of 100 minutes). -
The
HORIZON
clause defines how many rows into the future the model will forecast - here, it forecasts the next 10 rows (the next 10 minutes).
CREATE MODEL
statement as above, you can check the progress status using this query:
Make forecasts
First, we’ll save the Binance data into a view, which will be the input data for making forecasts.HORIZON
clause).
The next thing we can do is automate price alerts. Here we’ll choose Slack as our preferred place to receive the alerts but this could be any other system that MindsDB integrates with.