Align China A-share costs with rqalpha rules
This commit is contained in:
@@ -6,6 +6,7 @@ use std::sync::OnceLock;
|
||||
|
||||
use chrono::{Datelike, Duration, NaiveDate, NaiveDateTime, NaiveTime};
|
||||
|
||||
use crate::cost::ChinaAShareCostModel;
|
||||
use crate::data::{DataSet, PriceField};
|
||||
use crate::engine::BacktestError;
|
||||
use crate::events::OrderSide;
|
||||
@@ -576,11 +577,12 @@ impl JqMicroCapStrategy {
|
||||
}
|
||||
|
||||
fn buy_commission(&self, gross_amount: f64) -> f64 {
|
||||
(gross_amount * 0.0003).max(5.0)
|
||||
ChinaAShareCostModel::default().commission_for(gross_amount)
|
||||
}
|
||||
|
||||
fn sell_cost(&self, gross_amount: f64) -> f64 {
|
||||
(gross_amount * 0.0003).max(5.0) + (gross_amount * 0.001)
|
||||
fn sell_cost(&self, date: NaiveDate, gross_amount: f64) -> f64 {
|
||||
let model = ChinaAShareCostModel::default();
|
||||
model.commission_for(gross_amount) + model.stamp_tax_for(date, OrderSide::Sell, gross_amount)
|
||||
}
|
||||
|
||||
fn round_lot_quantity(&self, quantity: u32, round_lot: u32) -> u32 {
|
||||
@@ -750,7 +752,7 @@ impl JqMicroCapStrategy {
|
||||
+ Duration::seconds(1),
|
||||
});
|
||||
let gross_amount = fill.price * fill.quantity as f64;
|
||||
let net_cash = gross_amount - self.sell_cost(gross_amount);
|
||||
let net_cash = gross_amount - self.sell_cost(date, gross_amount);
|
||||
projected
|
||||
.position_mut(symbol)
|
||||
.sell(fill.quantity, fill.price)
|
||||
|
||||
Reference in New Issue
Block a user