-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from geniusyield/facilitate-as-library-use
feat(#111): allow SOR codebase to be used as library
- Loading branch information
Showing
16 changed files
with
416 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Revision history for geniusyield-orderbot | ||
|
||
## 0.2.0 | ||
|
||
Uses revamped geniusyield-orderbot-framework, strategies is moved into a signature with corresponding implementation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
geniusyield-orderbot-framework/lib-orderbook/GeniusYield/OrderBot/OrderBook/Extra.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{-| | ||
Module : GeniusYield.OrderBot.OrderBook.Extra | ||
Synopsis : Extra utilities when working with order books. | ||
Copyright : (c) 2023 GYELD GMBH | ||
License : Apache 2.0 | ||
Maintainer : [email protected] | ||
Stability : develop | ||
-} | ||
module GeniusYield.OrderBot.OrderBook.Extra ( | ||
foldlMOrders', | ||
mapMOrders_, | ||
lookupBest, | ||
) where | ||
|
||
import Prelude (Maybe, Monad, (*>), pure) | ||
import GeniusYield.OrderBot.Types (OrderInfo, SOrderTypeI (..), SOrderType (..), OrderType) | ||
import GeniusYield.OrderBot.OrderBook | ||
|
||
-- | @foldlM'@ variant for 'Orders' which is strict in accumulator. | ||
foldlMOrders' :: forall a t m. Monad m => (a -> OrderInfo t -> m a) -> a -> Orders t -> m a | ||
foldlMOrders' f = foldlMOrders (\(!acc) -> f acc) | ||
|
||
-- | @mapM_@ variant for 'Orders'. | ||
mapMOrders_ :: forall a t m. Monad m => (OrderInfo t -> m a) -> Orders t -> m () | ||
mapMOrders_ f os = foldlMOrders' (\_ oi -> f oi *> pure ()) () os | ||
|
||
-- | In case we have buy orders, return the best buy order (highest price). And in case we have sell orders, return the best sell order (lowest price). | ||
lookupBest :: forall (t :: OrderType). SOrderTypeI t => Orders t -> Maybe (OrderInfo t) | ||
lookupBest os = case (sOrderType @t) of | ||
SBuyOrder -> highestBuyMaybe os | ||
SSellOrder -> lowestSellMaybe os |
Oops, something went wrong.