在MySQL中,你可以这样做(从SO上的另一篇文章中获取)从市场数据中获得五分钟的距离:
select
date_format(
date_sub(
tick_time,
INTERVAL (extract(MINUTE from tick_time) % 5) MINUTE
),
"%m-%d%Y %H:%i"
) as bar_time,
MAX(bid) AS high,
MIN(bid) AS low
from ticks
group by bar_time
根据下表,Cassandra在每个id / strike中获得五(n分钟)callbid,callask,putbid,putask open / high / low / close的等价物是什么? (成熟度和身份证是多余的,但不是后果性的。)
cqlsh:时间序列>描述表option_data;
CREATE TABLE option_data (
ts bigint,
id text,
strike decimal,
callask decimal,
callbid decimal,
maturity timestamp,
putask decimal,
putbid decimal,
PRIMARY KEY ((ts), id, strike)
) WITH
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
index_interval=128 AND
read_repair_chance=0.000000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
default_time_to_live=0 AND
speculative_retry='99.0PERCENTILE' AND
memtable_flush_period_in_ms=0 AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'LZ4Compressor'};
cqlsh:timeseries>
ts在C#中编码如下:
static long ninetySeventyTicks = new DateTime(1970, 1, 1).Ticks;
public static long ToUnixTimestampMicro(DateTime dateTime)
{
return (dateTime.Ticks - ninetySeventyTicks) / 10;
}
public static DateTime ConvertFromUnixTimestampMicro(double timestamp)
{
return new DateTime((long)timestamp * 10).AddYears(1969);
}