|
|
@@ -33,6 +33,7 @@ pub struct AvellanedaStoikov {
|
|
|
pub optimal_bid_price: Decimal, // 买入挂单价
|
|
|
|
|
|
pub inventory: Decimal, // 库存,也就是q
|
|
|
+ pub pos_amount: Decimal, // 原始持仓量
|
|
|
pub level: Decimal, // martin
|
|
|
pub sigma_square: Decimal, // σ^2,波动性的平方
|
|
|
pub gamma: Decimal, // γ,库存风险厌恶参数
|
|
|
@@ -107,6 +108,7 @@ impl AvellanedaStoikov {
|
|
|
level: Default::default(),
|
|
|
flow_ratio: Default::default(),
|
|
|
money_flow_index: Default::default(),
|
|
|
+ pos_amount: Default::default(),
|
|
|
};
|
|
|
|
|
|
avellaneda_stoikov
|
|
|
@@ -273,9 +275,10 @@ impl AvellanedaStoikov {
|
|
|
self.update_flow_ratio();
|
|
|
}
|
|
|
|
|
|
- pub async fn update_inventory(&mut self, inventory: &Decimal, min_amount_value: &Decimal) {
|
|
|
+ pub async fn update_inventory(&mut self, pos_amount: &Decimal, min_amount_value: &Decimal) {
|
|
|
let prev_inventory = self.inventory;
|
|
|
- self.inventory = (inventory / (min_amount_value / self.mid_price)).round();
|
|
|
+ self.pos_amount = pos_amount.clone();
|
|
|
+ self.inventory = (pos_amount / (min_amount_value / self.mid_price)).round();
|
|
|
if prev_inventory != self.inventory {
|
|
|
self.prev_trade_time = Utc::now().timestamp_micros();
|
|
|
}
|