Tradind data candle data and manipulation.
For more information about candles see candle.
- class tradingstrategy.candle.Candle¶
Data structure that presents one candle in Capitalgram.
Based on the open-high-low-close-volume concept.
Capitalgram candles come with additional information available on the top of core OHLCV. This is because our chain analysis has deeper visibility than one would get on traditional exchanges.
- pair_id: tradingstrategy.types.PrimaryKey¶
Primary key to identity the trading pair Use pair universe to map this to chain id and a smart contract address
- timestamp: tradingstrategy.types.UNIXTimestamp¶
Open timestamp for this candle. Note that the close timestamp you need to supply yourself based on the context.
- exchange_rate: float¶
USD exchange rate of the quote token used to convert to dollar amounts in this candle.
Note that currently any USD stablecoin (USDC, DAI) is assumed to be 1:1 and the candle server cannot handle exchange rate difference among stablecoins.
The rate is taken at the beginning of the 1 minute time bucket. For other time buckets, the exchange rate is the simple average for the duration of the bucket.
- property volume: tradingstrategy.types.USDollarAmount¶
Total volume during the candle period.
Unline in traditional CEX trading, we can separate buy volume and sell volume from each other, becauase liquidity provider is a special role.
- classmethod to_dataframe() pandas.core.frame.DataFrame ¶
Return emptry Pandas dataframe presenting candle data.
- classmethod to_pyarrow_schema(small_candles=False) pyarrow.lib.Schema ¶
Construct schema for writing Parquet filess for these candles.
small_candles – Use even smaller word sizes for frequent (1m) candles.
- __init__(pair_id: tradingstrategy.types.PrimaryKey, timestamp: tradingstrategy.types.UNIXTimestamp, exchange_rate: float, open: tradingstrategy.types.USDollarAmount, close: tradingstrategy.types.USDollarAmount, high: tradingstrategy.types.USDollarAmount, low: tradingstrategy.types.USDollarAmount, buys: int, sells: int, buy_volume: tradingstrategy.types.USDollarAmount, sell_volume: tradingstrategy.types.USDollarAmount, avg: tradingstrategy.types.USDollarAmount, start_block: tradingstrategy.types.BlockNumber, end_block: tradingstrategy.types.BlockNumber) None ¶
- class tradingstrategy.candle.CandleResult¶
Server-reply for live queried candle data.
- candles: List[tradingstrategy.candle.Candle]¶
A bunch of candles. Candles are unordered and subject to client side sorting. Multiple pairs and chains may be present in candles.
In-place sorting of candles by their timestamp.
- class tradingstrategy.candle.GroupedCandleUniverse¶
A candle universe where each trading pair has its own candles.
This is helper class to create foundation for multi pair strategies.
For the data logistics purposes, all candles are lumped together in single columnar data blobs. However, it rarely makes sense to execute operations over different trading pairs. :py:class`GroupedCandleUniverse` creates trading pair id -> candle data grouping out from raw candle data.