@@ -5,9 +5,10 @@ module BfxSpec
5
5
)
6
6
where
7
7
8
- import qualified Bfx as Bitfinex
8
+ import qualified Bfx
9
9
import qualified Bfx.Data.Candles as Candles
10
10
import qualified Bfx.Data.GetOrders as GetOrders
11
+ import qualified Bfx.Data.MarketAveragePrice as MarketAveragePrice
11
12
import qualified Bfx.Data.SubmitOrder as SubmitOrder
12
13
import Bfx.Import
13
14
import Bfx.TestEnv
@@ -18,98 +19,136 @@ spec :: Spec
18
19
spec = before sysEnv $ do
19
20
let adabtc = either impureThrow id $ newCurrencyPair " ADABTC"
20
21
it " platformStatus succeeds" . const $ do
21
- ss <- Bitfinex . platformStatus
22
+ ss <- Bfx . platformStatus
22
23
ss `shouldBe` PltOperative
23
24
it " symbolsDetails succeeds" . const $ do
24
- ss <- Bitfinex . symbolsDetails
25
+ ss <- Bfx . symbolsDetails
25
26
Map. lookup adabtc ss
26
27
`shouldBe` Just
27
28
CurrencyPairConf
28
29
{ currencyPairPrecision = 5 ,
29
30
currencyPairInitMargin = 30 % 1 ,
30
31
currencyPairMinMargin = 15 ,
31
- currencyPairMaxOrderAmt = Tagged 250000 ,
32
- currencyPairMinOrderAmt = Tagged 4
32
+ currencyPairMaxOrderBaseAmt = MoneyAmount 250000 ,
33
+ currencyPairMinOrderBaseAmt = MoneyAmount 4
33
34
}
34
35
it " marketAveragePrice succeeds" . const $ do
35
- sym <- newCurrencyPair " ADABTC"
36
- buyRate <- Bitfinex. marketAveragePrice (testAmt @ 'Buy) sym
37
- sellRate <- Bitfinex. marketAveragePrice (testAmt @ 'Sell) sym
38
- unTagged buyRate `shouldSatisfy` (> unTagged sellRate)
36
+ buyRate <-
37
+ Bfx. marketAveragePrice
38
+ MarketAveragePrice. Request
39
+ { MarketAveragePrice. buyOrSell = Buy ,
40
+ MarketAveragePrice. baseAmount = testAdaAmt,
41
+ MarketAveragePrice. symbol = adabtc
42
+ }
43
+ sellRate <-
44
+ Bfx. marketAveragePrice
45
+ MarketAveragePrice. Request
46
+ { MarketAveragePrice. buyOrSell = Sell ,
47
+ MarketAveragePrice. baseAmount = testAdaAmt,
48
+ MarketAveragePrice. symbol = adabtc
49
+ }
50
+ buyRate `shouldSatisfy` (> sellRate)
39
51
it " marketAveragePrice fails" . const $ do
40
- let amt = testAmt @ 'Buy
41
52
sym <- newCurrencyPair " BTCADA"
42
- res <- tryAny $ Bitfinex. marketAveragePrice amt sym
53
+ res <-
54
+ tryAny
55
+ $ Bfx. marketAveragePrice
56
+ MarketAveragePrice. Request
57
+ { MarketAveragePrice. buyOrSell = Sell ,
58
+ MarketAveragePrice. baseAmount = testAdaAmt,
59
+ MarketAveragePrice. symbol = sym
60
+ }
43
61
res `shouldSatisfy` isLeft
44
62
it " feeSummary succeeds" $ \ env -> do
45
- res <- tryAny $ Bitfinex . feeSummary env
63
+ res <- tryAny $ Bfx . feeSummary env
46
64
res `shouldSatisfy` isRight
47
65
it " submitOrderMaker and cancelOrderById succeeds" $ \ env -> do
48
- let amt = testAmt @ 'Buy
49
- let opts = SubmitOrder. optsPostOnly
50
- sym <- newCurrencyPair " ADABTC"
51
- curRate <- Bitfinex. marketAveragePrice amt sym
52
- rate <- (* 0.5 ) <$> roundQuotePerBase curRate
53
- order <- Bitfinex. submitOrderMaker env amt sym rate opts
54
- res <- tryAny . Bitfinex. cancelOrderById env $ orderId order
66
+ curRate <-
67
+ Bfx. marketAveragePrice
68
+ MarketAveragePrice. Request
69
+ { MarketAveragePrice. buyOrSell = Buy ,
70
+ MarketAveragePrice. baseAmount = testAdaAmt,
71
+ MarketAveragePrice. symbol = adabtc
72
+ }
73
+ rate <-
74
+ roundQuotePerBase
75
+ . QuotePerBase
76
+ . (* 0.5 )
77
+ $ unQuotePerBase curRate
78
+ order <-
79
+ Bfx. submitOrderMaker
80
+ env
81
+ SubmitOrder. Request
82
+ { SubmitOrder. buyOrSell = Buy ,
83
+ SubmitOrder. baseAmount = testAdaAmt,
84
+ SubmitOrder. symbol = adabtc,
85
+ SubmitOrder. rate = rate,
86
+ SubmitOrder. options = SubmitOrder. optsPostOnly
87
+ }
88
+ res <-
89
+ tryAny
90
+ . Bfx. cancelOrderById env
91
+ $ orderId order
55
92
res `shouldSatisfy` isRight
56
93
it " retrieveOrders succeeds" $ \ env -> do
57
- res <- tryAny . Bitfinex . retrieveOrders env $ GetOrders. optsSym adabtc
94
+ res <- tryAny . Bfx . retrieveOrders env $ GetOrders. optsSym adabtc
58
95
res `shouldSatisfy` isRight
59
96
it " ordersHistory succeeds" $ \ env -> do
60
- res <- tryAny . Bitfinex . ordersHistory env $ GetOrders. optsSym adabtc
97
+ res <- tryAny . Bfx . ordersHistory env $ GetOrders. optsSym adabtc
61
98
res `shouldSatisfy` isRight
62
99
it " getOrders succeeds" $ \ env -> do
63
- res <- tryAny . Bitfinex . getOrders env $ GetOrders. optsSym adabtc
100
+ res <- tryAny . Bfx . getOrders env $ GetOrders. optsSym adabtc
64
101
res `shouldSatisfy` isRight
65
102
it " getOrder fails" $ \ env -> do
66
- res <- tryAny . Bitfinex . getOrder env $ OrderId 0
103
+ res <- tryAny . Bfx . getOrder env $ OrderId 0
67
104
res `shouldSatisfy` isLeft
68
105
it " submitCounterOrderMaker fails" $ \ env -> do
69
106
res <-
70
107
tryAny
71
- $ Bitfinex . submitCounterOrderMaker
108
+ $ Bfx . submitCounterOrderMaker
72
109
env
73
110
(OrderId 0 )
74
- (Tagged 0.001 )
75
- (Tagged 0.001 )
76
- (Tagged 0.001 )
111
+ CounterRates
112
+ { counterRatesEnterBaseFee = FeeRate 0 ,
113
+ counterRatesExitQuoteFee = FeeRate 0 ,
114
+ counterRatesExitQuoteProfit = ProfitRate 0
115
+ }
77
116
SubmitOrder. optsPostOnly
78
117
res `shouldSatisfy` isLeft
79
118
it " wallets succeeds" $ \ env -> do
80
- res <- tryAny $ Bitfinex . wallets env
119
+ res <- tryAny $ Bfx . wallets env
81
120
res `shouldSatisfy` isRight
82
121
it " netWorth succeeds" $ \ env -> do
83
- res <- tryAny . Bitfinex . netWorth env $ CurrencyCode " BTC"
122
+ res <- tryAny . Bfx . netWorth env $ CurrencyCode " BTC"
84
123
res `shouldSatisfy` isRight
85
124
it " candlesLast succeeds" . const $ do
86
- res <- tryAny $ Bitfinex . candlesLast Ctf1h adabtc Candles. optsDef
125
+ res <- tryAny $ Bfx . candlesLast Ctf1h adabtc Candles. optsDef
87
126
res `shouldSatisfy` isRight
88
127
it " candlesHist succeeds" . const $ do
89
- res <- tryAny $ Bitfinex . candlesHist Ctf1h adabtc Candles. optsDef
128
+ res <- tryAny $ Bfx . candlesHist Ctf1h adabtc Candles. optsDef
90
129
res `shouldSatisfy` isRight
91
130
92
131
-- describe "End2End" $ do
93
132
-- itRight "submitOrderMaker" $ \env -> do
94
133
-- let amt = from @(Ratio Natural) 2.002002 :: Money 'Base 'Buy
95
134
-- let sym = [currencyPair|ADABTC|]
96
135
-- let opts = SubmitOrder.optsPostOnly
97
- -- rate <- Bitfinex .marketAveragePrice amt sym
98
- -- Bitfinex .submitOrderMaker env amt sym rate opts
136
+ -- rate <- Bfx .marketAveragePrice amt sym
137
+ -- Bfx .submitOrderMaker env amt sym rate opts
99
138
-- itRight "submitCounterOrderMaker" $ \env ->
100
- -- Bitfinex .submitCounterOrderMaker
139
+ -- Bfx .submitCounterOrderMaker
101
140
-- env
102
141
-- (OrderId 0)
103
142
-- [feeRateMakerBase| 0.001 |]
104
143
-- [feeRateMakerQuote| 0.001 |]
105
144
-- [profitRate| 0.001 |]
106
145
-- SubmitOrder.optsPostOnly
107
146
-- focus . itRight "cancelOrderMulti" $ \env ->
108
- -- Bitfinex .cancelOrderMulti
147
+ -- Bfx .cancelOrderMulti
109
148
-- env
110
149
-- CancelOrderMulti.Everything
111
150
-- focus . itRight "dumpIntoQuoteMaker" $ \env ->
112
- -- Bitfinex .dumpIntoQuoteMaker
151
+ -- Bfx .dumpIntoQuoteMaker
113
152
-- env
114
153
-- [currencyPair|XLM:BTC|]
115
154
-- SubmitOrder.optsPostOnly
0 commit comments