Skip to content

Commit c6bad6b

Browse files
committed
support bfx affiliate codes
1 parent 45fe150 commit c6bad6b

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

prv

Submodule prv updated from 31a734e to d19a813

pub/bfx/src/Bfx/Data/SubmitOrder.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data Options = Options
2929
{ stopLoss :: Maybe QuotePerBase,
3030
clientId :: Maybe OrderClientId,
3131
groupId :: Maybe OrderGroupId,
32+
affCode :: Maybe AffCode,
3233
flags :: Set OrderFlag
3334
}
3435
deriving stock (Eq, Ord, Show, Read, Data, Generic)
@@ -39,6 +40,7 @@ optsDef =
3940
{ stopLoss = Nothing,
4041
clientId = Nothing,
4142
groupId = Nothing,
43+
affCode = Nothing,
4244
flags = mempty
4345
}
4446

@@ -48,6 +50,7 @@ optsPostOnly =
4850
{ stopLoss = Nothing,
4951
clientId = Nothing,
5052
groupId = Nothing,
53+
affCode = Nothing,
5154
flags = [PostOnly]
5255
}
5356

@@ -57,6 +60,7 @@ optsPostOnlyStopLoss sl =
5760
{ stopLoss = Just sl,
5861
clientId = Nothing,
5962
groupId = Nothing,
63+
affCode = Nothing,
6064
flags = [PostOnly, Oco]
6165
}
6266

@@ -89,5 +93,9 @@ instance ToJSON Request where
8993
mempty
9094
(\x -> ["price_oco_stop" A..= toTextParam x])
9195
(stopLoss opts)
96+
<> maybe
97+
mempty
98+
(\x -> ["meta" A..= A.object ["aff_code" A..= unAffCode x]])
99+
(affCode opts)
92100
where
93101
opts = options req

pub/bfx/src/Bfx/Data/Type.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Bfx.Data.Type
1313
unOrderFlagSet,
1414
OrderStatus (..),
1515
newOrderStatus,
16+
AffCode (..),
1617

1718
-- * Trading
1819
-- $trading
@@ -242,6 +243,26 @@ newOrderStatus = \case
242243
"RSN_PAUSE" -> Right RsnPause
243244
x -> Left $ TryFromException x Nothing
244245

246+
newtype AffCode = AffCode
247+
{ unAffCode :: Text
248+
}
249+
deriving newtype
250+
( Eq,
251+
Ord,
252+
Show,
253+
Read,
254+
ToJSON,
255+
ToJSONKey,
256+
FromJSON,
257+
FromJSONKey,
258+
HasCodec,
259+
HasItemCodec
260+
)
261+
deriving stock
262+
( Data,
263+
Generic
264+
)
265+
245266
-- $trading
246267
-- Data related to trading and money.
247268

0 commit comments

Comments
 (0)