@@ -42,9 +42,10 @@ use crate::{
42
42
FastHashMap ,
43
43
} ;
44
44
45
- pub enum SecuritiesClass {
45
+ pub enum CommodityClass {
46
46
Spot ,
47
- Derivative ,
47
+ Futures ,
48
+ Options
48
49
}
49
50
50
51
/// Centralized exchange price map organized by exchange.
@@ -334,7 +335,7 @@ impl CexPriceMap {
334
335
let volume_weighted_bid = volume_price. 0 / & cumulative_bbo. 0 ;
335
336
let volume_weighted_ask = volume_price. 1 / & cumulative_bbo. 1 ;
336
337
337
- let fees = exchange. fees ( & pair, & SecuritiesClass :: Spot ) ;
338
+ let fees = exchange. fees ( & pair, & CommodityClass :: Spot ) ;
338
339
339
340
let fee_adjusted_maker = (
340
341
& volume_weighted_bid * ( Rational :: ONE - & fees. 0 ) ,
@@ -1021,34 +1022,32 @@ impl CexExchange {
1021
1022
///
1022
1023
/// TODO: Account for special fee pairs & stableswap rates
1023
1024
/// TODO: Account for futures & spot fee deltas
1024
- pub fn fees ( & self , pair : & Pair , trade_type : & SecuritiesClass ) -> ( Rational , Rational ) {
1025
+ pub fn fees ( & self , pair : & Pair , trade_type : & CommodityClass ) -> ( Rational , Rational ) {
1025
1026
let ( maker, taker) = match self {
1026
1027
CexExchange :: Binance => {
1027
1028
match trade_type {
1028
- SecuritiesClass :: Spot =>
1029
+ CommodityClass :: Spot =>
1029
1030
if Self :: BINANCE_SPOT_PROMO_FEE_TYPE1_PAIRS . iter ( ) . any ( |p| p. eq_ordered ( pair) ) {
1030
1031
( "0.0" , "0.0" ) // https://www.binance.com/en/fee/tradingPromote
1031
1032
} else if Self :: BINANCE_SPOT_PROMO_FEE_TYPE2_PAIRS . iter ( ) . any ( |p| p. eq_ordered ( pair) ) {
1032
1033
( "0.0" , "0.00024" ) // https://www.binance.com/en/fee/tradingPromote
1033
-
1034
1034
} else if pair. 0 == USDC_ADDRESS || pair. 1 == USDC_ADDRESS {
1035
1035
( "0.00012" , "0.0001425" ) // https://www.binance.com/en/fee/trading
1036
1036
} else {
1037
1037
( "0.00012" , "0.00024" ) // https://www.binance.com/en/fee/trading
1038
1038
} ,
1039
- SecuritiesClass :: Derivative => ( "0.0003" , "0.0003" ) , // https://www.binance.com/en/fee/optionsTrading
1039
+ CommodityClass :: Derivative => ( "0.0003" , "0.0003" ) , // https://www.binance.com/en/fee/optionsTrading
1040
1040
}
1041
1041
} ,
1042
1042
CexExchange :: Bitmex =>
1043
1043
match trade_type {
1044
- SecuritiesClass :: Spot => ( "0.001" , "0.001" ) , // https://www.bitmex.com/wallet/fees/spot
1045
- SecuritiesClass :: Derivative => ( "-0.000125" , "0.000175" ) , // https://www.bitmex.com/wallet/fees/derivatives
1046
-
1044
+ CommodityClass :: Spot => ( "0.001" , "0.001" ) , // https://www.bitmex.com/wallet/fees/spot
1045
+ CommodityClass :: Derivative => ( "-0.000125" , "0.000175" ) , // https://www.bitmex.com/wallet/fees/derivatives
1047
1046
}
1048
1047
CexExchange :: Deribit =>
1049
1048
match trade_type {
1050
- SecuritiesClass :: Spot => ( "0.0" , "0.0" ) , // https://www.deribit.com/kb/fees
1051
- SecuritiesClass :: Derivative => ( "-0.0001" , "0.0005" ) , // https://www.deribit.com/kb/fees
1049
+ CommodityClass :: Spot => ( "0.0" , "0.0" ) , // https://www.deribit.com/kb/fees
1050
+ CommodityClass :: Derivative => ( "-0.0001" , "0.0005" ) , // https://www.deribit.com/kb/fees
1052
1051
}
1053
1052
CexExchange :: Okex => ( "-0.0001" , "0.00015" ) , // https://tr.okx.com/fees
1054
1053
CexExchange :: Coinbase =>
@@ -1061,14 +1060,14 @@ impl CexExchange {
1061
1060
} ,
1062
1061
CexExchange :: Kraken =>
1063
1062
match trade_type {
1064
- SecuritiesClass :: Spot => ( "0.0" , "0.001" ) , // https://www.kraken.com/features/fee-schedule#spot-crypto
1065
- SecuritiesClass :: Derivative => ( "0.0" , "0.0001" ) , // https://www.kraken.com/features/fee-schedule#futures
1063
+ CommodityClass :: Spot => ( "0.0" , "0.001" ) , // https://www.kraken.com/features/fee-schedule#spot-crypto
1064
+ CommodityClass :: Derivative => ( "0.0" , "0.0001" ) , // https://www.kraken.com/features/fee-schedule#futures
1066
1065
} ,
1067
1066
CexExchange :: BybitSpot =>
1068
1067
// https://www.bybit.com/en/help-center/article/Trading-Fee-Structure
1069
1068
match trade_type {
1070
- SecuritiesClass :: Spot => ( "0.00005" , "0.00015" ) ,
1071
- SecuritiesClass :: Derivative => if USDC_ADDRESS == pair. 0 || USDC_ADDRESS == pair. 1 {
1069
+ CommodityClass :: Spot => ( "0.00005" , "0.00015" ) ,
1070
+ CommodityClass :: Derivative => if USDC_ADDRESS == pair. 0 || USDC_ADDRESS == pair. 1 {
1072
1071
( "0.0" , "0.0001" )
1073
1072
} else {
1074
1073
( "0.0" , "0.00025" )
@@ -1077,7 +1076,7 @@ impl CexExchange {
1077
1076
CexExchange :: Kucoin =>
1078
1077
// https://www.kucoin.com/vip/privilege
1079
1078
match trade_type {
1080
- SecuritiesClass :: Spot =>
1079
+ CommodityClass :: Spot =>
1081
1080
if Self :: KUCOIN_CLASS_C_BASE_COINS . iter ( ) . any ( |a| pair. 0 == * a) {
1082
1081
( "-0.00005" , "0.00075" )
1083
1082
} else if Self :: KUCOIN_CLASS_B_BASE_COINS . iter ( ) . any ( |a| pair. 0 == * a) {
@@ -1089,13 +1088,13 @@ impl CexExchange {
1089
1088
} else {
1090
1089
( "-0.00005" , "0.00025" )
1091
1090
} ,
1092
- SecuritiesClass :: Derivative => ( "-0.00008" , "0.00025" ) ,
1091
+ CommodityClass :: Derivative => ( "-0.00008" , "0.00025" ) ,
1093
1092
} ,
1094
1093
CexExchange :: Upbit => ( "0.0002" , "0.0002" ) , // https://sg.upbit.com/service_center/guide
1095
1094
CexExchange :: Huobi =>
1096
1095
match trade_type {
1097
- SecuritiesClass :: Spot => ( "0.000097" , "0.000193" ) , // https://www.htx.com/zh-cn/support/360000312282
1098
- SecuritiesClass :: Derivative => ( "-0.00005" , "0.0002" ) , // https://www.htx.com/zh-cn/support/360000113122
1096
+ CommodityClass :: Spot => ( "0.000097" , "0.000193" ) , // https://www.htx.com/zh-cn/support/360000312282
1097
+ CommodityClass :: Derivative => ( "-0.00005" , "0.0002" ) , // https://www.htx.com/zh-cn/support/360000113122
1099
1098
}
1100
1099
CexExchange :: GateIo => ( "0.0" , "0.0002" ) , // https://www.gate.io/fee (curl, search for spot_feelist)
1101
1100
CexExchange :: Bitstamp => ( "0" , "0.0003" ) , // https://www.bitstamp.net/fee-schedule/
0 commit comments