From f7a9f7c37d82f41a32339b3cbf2d637260f37730 Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 4 Oct 2024 18:57:27 +0800 Subject: [PATCH] document price solver --- doc/topics/price-solver.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 doc/topics/price-solver.md diff --git a/doc/topics/price-solver.md b/doc/topics/price-solver.md new file mode 100644 index 000000000..0a7c2d5d1 --- /dev/null +++ b/doc/topics/price-solver.md @@ -0,0 +1,22 @@ +# Using Price Solver + +Price solver is a tool to calculate the price of a market based on the prices of other markets. It is useful when you +want to calculate the price of a market that is not directly available on the exchange. + +## Simple Price Solver + +Simple price solver is a price solver that calculates the price of a market based on the prices of other markets. + +You may add a field to the struct to store the price solver: + + priceSolver *pricesolver.SimplePriceSolver + +To use the simple price solver, you need to create an instance of `SimplePriceSolver` and bind the market data stream of +the source markets to it. + + s.priceSolver = pricesolver.NewSimplePriceResolver(sourceMarkets) + s.priceSolver.BindStream(s.sourceSession.MarketDataStream) + +To update the price of the target market, you may call the `UpdatePrice` method of the price solver. + + s.priceSolver.Update(symbol, price)