Align China A-share costs with rqalpha rules

This commit is contained in:
boris
2026-04-22 21:57:24 -07:00
parent 650e2e8319
commit aca8292c72
5 changed files with 111 additions and 43 deletions

View File

@@ -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)