Market data is the data representing the current bid/ask for a financial instrument at an exchange. The market data can either be the top of book, best bid/ask for the particular instrument, or an aggregated book with several levels of depth. Normally, we just look at the best bid/ask prices, top of book called quotes. Market data can also be sent as OHLC bars or candles. Such bars are only useful for visualizing price information in charts or for trading at a longer horizon. It is a simple way of filtering the price information. The midpoint is defined as the average between the bid and ask.
Type Quote = { bid : float ask : float } member this.midpoint() = (this.bid + this.ask) / 2.0
Let's see how to use this type:
let q = {bid = 1.40; ask = 1.45} : Quote
We can calculate the midpoint as follows:
> q.midpoint();; val it : float = 1.425
We can extend the Quote
type to have a built-in function to calculate the spread for that quote:
type Quote = { bid...