Skip to content

Commit

Permalink
add PushQuote.current_volume, PushQuote.current_turnover
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Jan 3, 2025
1 parent 11d86a4 commit 2c5108c
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 4 deletions.
8 changes: 8 additions & 0 deletions c/csrc/include/longport.h
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,14 @@ typedef struct lb_push_quote_t {
* Trade session
*/
enum lb_trade_session_t trade_session;
/**
* Increase volume between pushes
*/
int64_t current_volume;
/**
* Increase turnover between pushes
*/
const struct lb_decimal_t *current_turnover;
} lb_push_quote_t;

typedef void (*lb_quote_callback_t)(const struct lb_quote_context_t*,
Expand Down
14 changes: 14 additions & 0 deletions c/src/quote_context/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub struct CPushQuote {
pub trade_status: CTradeStatus,
/// Trade session
pub trade_session: CTradeSession,
/// Increase volume between pushes
pub current_volume: i64,
/// Increase turnover between pushes
pub current_turnover: *const CDecimal,
}

#[derive(Debug)]
Expand All @@ -55,6 +59,8 @@ pub(crate) struct CPushQuoteOwned {
turnover: CDecimal,
trade_status: TradeStatus,
trade_session: TradeSession,
current_volume: i64,
current_turnover: CDecimal,
}

impl From<(String, PushQuote)> for CPushQuoteOwned {
Expand All @@ -69,6 +75,8 @@ impl From<(String, PushQuote)> for CPushQuoteOwned {
turnover,
trade_status,
trade_session,
current_volume,
current_turnover,
} = quote;
CPushQuoteOwned {
symbol: symbol.into(),
Expand All @@ -81,6 +89,8 @@ impl From<(String, PushQuote)> for CPushQuoteOwned {
turnover: turnover.into(),
trade_status,
trade_session,
current_volume,
current_turnover: current_turnover.into(),
}
}
}
Expand All @@ -100,6 +110,8 @@ impl ToFFI for CPushQuoteOwned {
turnover,
trade_status,
trade_session,
current_volume,
current_turnover,
} = self;
CPushQuote {
symbol: symbol.to_ffi_type(),
Expand All @@ -112,6 +124,8 @@ impl ToFFI for CPushQuoteOwned {
turnover,
trade_status: (*trade_status).into(),
trade_session: (*trade_session).into(),
current_volume: *current_volume,
current_turnover,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cpp/include/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ struct PushQuote
TradeStatus trade_status;
/// Trade session
TradeSession trade_session;
/// Increase volume between pushes
int64_t current_volume;
/// Increase turnover between pushes
Decimal urrent_turnover;
};

struct Depth
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,8 @@ convert(const lb_push_quote_t* info)
Decimal(info->turnover),
convert(info->trade_status),
convert(info->trade_session),
info->current_volume,
Decimal(info->current_turnover),
};
}

Expand Down
17 changes: 14 additions & 3 deletions java/javasrc/src/main/java/com/longport/quote/PushQuote.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class PushQuote {
private BigDecimal turnover;
private TradeStatus tradeStatus;
private TradeSession tradeSession;
private long currentVolume;
private BigDecimal currentTurnover;

public BigDecimal getLastDone() {
return lastDone;
Expand Down Expand Up @@ -50,11 +52,20 @@ public TradeSession getTradeSession() {
return tradeSession;
}

public long getCurrentVolume() {
return currentVolume;
}

public BigDecimal getCurrentTurnover() {
return currentTurnover;
}

@Override
public String toString() {
return "PushQuote [high=" + high + ", lastDone=" + lastDone + ", low=" + low + ", open=" + open + ", timestamp="
+ timestamp + ", tradeSession=" + tradeSession + ", tradeStatus=" + tradeStatus + ", turnover="
+ turnover + ", volume=" + volume + "]";
return "PushQuote [lastDone=" + lastDone + ", open=" + open + ", high=" + high + ", low=" + low + ", timestamp="
+ timestamp + ", volume=" + volume + ", turnover=" + turnover + ", tradeStatus=" + tradeStatus
+ ", tradeSession=" + tradeSession + ", currentVolume=" + currentVolume + ", currentTurnover="
+ currentTurnover + "]";
}

}
4 changes: 3 additions & 1 deletion java/src/types/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl_java_class!(
volume,
turnover,
trade_status,
trade_session
trade_session,
current_volume,
current_turnover
]
);

Expand Down
4 changes: 4 additions & 0 deletions nodejs/src/quote/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,10 @@ pub struct PushQuote {
trade_status: TradeStatus,
/// Trade session
trade_session: TradeSession,
/// Increase volume between pushes
current_volume: i64,
/// Increase turnover between pushes
current_turnover: Decimal,
}

/// Push real-time depth
Expand Down
10 changes: 10 additions & 0 deletions python/pysrc/longport/openapi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ class PushQuote:
Trade session
"""

current_volume: int
"""
Increase volume between pushes
"""

current_turnover: Decimal
"""
Increase turnover between pushes
"""


class PushDepth:
"""
Expand Down
4 changes: 4 additions & 0 deletions python/src/quote/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,10 @@ pub struct PushQuote {
trade_status: TradeStatus,
/// Trade session,
trade_session: TradeSession,
/// Increase volume between pushes
current_volume: i64,
/// Increase turnover between pushes
current_turnover: PyDecimal,
}

/// Push real-time depth
Expand Down
8 changes: 8 additions & 0 deletions rust/src/quote/push_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ pub struct PushQuote {
pub trade_status: TradeStatus,
/// Trade session
pub trade_session: TradeSession,
/// Increase volume between pushes
pub current_volume: i64,
/// Increase turnover between pushes
pub current_turnover: Decimal,
}

impl Default for PushQuote {
Expand All @@ -43,6 +47,8 @@ impl Default for PushQuote {
turnover: Default::default(),
trade_status: Default::default(),
trade_session: Default::default(),
current_volume: Default::default(),
current_turnover: Default::default(),
}
}
}
Expand Down Expand Up @@ -143,6 +149,8 @@ fn parse_push_quote(data: &[u8]) -> Result<(PushEvent, PushQuoteTag)> {
turnover: push_quote.turnover.parse().unwrap_or_default(),
trade_status: TradeStatus::try_from(push_quote.trade_status).unwrap_or_default(),
trade_session: TradeSession::try_from(push_quote.trade_session).unwrap_or_default(),
current_volume: push_quote.current_volume,
current_turnover: push_quote.current_turnover.parse().unwrap_or_default(),
}),
},
PushQuoteTag::try_from(push_quote.tag).unwrap_or_default(),
Expand Down
2 changes: 2 additions & 0 deletions rust/src/quote/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ fn merge_quote(data: &mut SecuritiesData, quote: &mut PushQuote) {
turnover: merge_decimal!(prev_quote, quote, turnover),
trade_status: quote.trade_status,
trade_session: quote.trade_session,
current_volume: quote.current_volume,
current_turnover: quote.current_turnover,
};
data.quote = new_quote.clone();
*quote = new_quote;
Expand Down

0 comments on commit 2c5108c

Please sign in to comment.