From a7a9f68524536921dbff4e52d0ceb080e327bfbe Mon Sep 17 00:00:00 2001 From: bcicc Date: Mon, 16 Oct 2023 09:01:33 -0700 Subject: [PATCH] added back fee model type --- docs/src/api.md | 1 + src/SaguaroTrader.jl | 1 + src/fee_model/fee_model.jl | 2 ++ src/fee_model/percent_fee_model.jl | 2 +- src/fee_model/zero_fee_model.jl | 2 +- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index 8ac734a..7c5d76e 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -39,6 +39,7 @@ AlwaysOpenExchange # Fee Model ```@docs +FeeModel ZeroFeeModel PercentFeeModel calculate_fee diff --git a/src/SaguaroTrader.jl b/src/SaguaroTrader.jl index 5519d32..ae75467 100644 --- a/src/SaguaroTrader.jl +++ b/src/SaguaroTrader.jl @@ -55,6 +55,7 @@ export AlwaysOpenExchange, # fee model + FeeModel, ZeroFeeModel, PercentFeeModel, calculate_fee, diff --git a/src/fee_model/fee_model.jl b/src/fee_model/fee_model.jl index dff79ce..81bf4a6 100644 --- a/src/fee_model/fee_model.jl +++ b/src/fee_model/fee_model.jl @@ -4,6 +4,8 @@ Abstract type to handle the calculation of brokerage fee, fees and taxes. """ +abstract type FeeModel end + include("zero_fee_model.jl") include("percent_fee_model.jl") diff --git a/src/fee_model/percent_fee_model.jl b/src/fee_model/percent_fee_model.jl index c003b8c..6249c29 100644 --- a/src/fee_model/percent_fee_model.jl +++ b/src/fee_model/percent_fee_model.jl @@ -12,7 +12,7 @@ Fields - `fee_pct::Float64` = 0.0 - `tax_pct::Float64` = 0.0 """ -struct PercentFeeModel +struct PercentFeeModel <: FeeModel fee_pct::Float64 tax_pct::Float64 function PercentFeeModel(; fee_pct::Float64=0.0, tax_pct::Float64=0.0) diff --git a/src/fee_model/zero_fee_model.jl b/src/fee_model/zero_fee_model.jl index 2454b53..ea0bb17 100644 --- a/src/fee_model/zero_fee_model.jl +++ b/src/fee_model/zero_fee_model.jl @@ -4,7 +4,7 @@ A FeeModel that produces no fee/fees/taxes. total_fee = 0.0 """ -struct ZeroFeeModel end +struct ZeroFeeModel <: FeeModel end function _calc_tax(fee_model::ZeroFeeModel, quantity::Real, price::Float64) return 0.0