Source code for tensortrade.oms.services.slippage.random_slippage_model
# Copyright 2019 The TensorTrade Authors.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the Licenseimportnumpyasnpfromtensortrade.oms.services.slippage.slippage_modelimportSlippageModelfromtensortrade.oms.ordersimportTrade,TradeType,TradeSide
[docs]classRandomUniformSlippageModel(SlippageModel):"""A uniform random slippage model. Parameters ---------- max_slippage_percent : float, default 3.0 The maximum random slippage to be applied to the fill price. """def__init__(self,max_slippage_percent:float=3.0):super().__init__()self.max_slippage_percent=self.default('max_slippage_percent',max_slippage_percent)