mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-09 05:39:09 -07:00
global: snapshot
This commit is contained in:
@@ -39,8 +39,23 @@ where
|
||||
let name = path.file_name().unwrap().to_str().unwrap().to_string();
|
||||
let key = I::to_string().split("::").last().unwrap().to_lowercase();
|
||||
|
||||
let prefix = |s: &str| path.with_file_name(format!("{key}_to_{s}_{name}"));
|
||||
let suffix = |s: &str| path.with_file_name(format!("{key}_to_{name}_{s}"));
|
||||
let only_one_active = options.is_only_one_active();
|
||||
|
||||
let prefix = |s: &str| {
|
||||
if only_one_active {
|
||||
path.with_file_name(format!("{key}_to_{name}"))
|
||||
} else {
|
||||
path.with_file_name(format!("{key}_to_{s}_{name}"))
|
||||
}
|
||||
};
|
||||
|
||||
let suffix = |s: &str| {
|
||||
if only_one_active {
|
||||
path.with_file_name(format!("{key}_to_{name}"))
|
||||
} else {
|
||||
path.with_file_name(format!("{key}_to_{name}_{s}"))
|
||||
}
|
||||
};
|
||||
|
||||
let s = Self {
|
||||
first: options.first.then(|| {
|
||||
@@ -563,4 +578,24 @@ impl StorableVecGeneatorOptions {
|
||||
self._10p = false;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn is_only_one_active(&self) -> bool {
|
||||
[
|
||||
self.average,
|
||||
self.sum,
|
||||
self.max,
|
||||
self._90p,
|
||||
self._75p,
|
||||
self.median,
|
||||
self._25p,
|
||||
self._10p,
|
||||
self.min,
|
||||
self.first,
|
||||
self.last,
|
||||
]
|
||||
.iter()
|
||||
.filter(|b| **b)
|
||||
.count()
|
||||
== 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ impl Binance {
|
||||
}
|
||||
|
||||
pub fn get_from_1d(&mut self, date: &Date) -> color_eyre::Result<OHLCCents> {
|
||||
if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 < date {
|
||||
if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 <= date {
|
||||
self._1d.replace(Self::fetch_1d()?);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ impl Kibo {
|
||||
.last_key_value()
|
||||
.unwrap()
|
||||
.0
|
||||
< date
|
||||
<= date
|
||||
{
|
||||
self.year_to_date_to_ohlc
|
||||
.insert(year, Self::fetch_date_prices(year)?);
|
||||
|
||||
@@ -43,7 +43,7 @@ impl Kraken {
|
||||
}
|
||||
|
||||
pub fn get_from_1d(&mut self, date: &Date) -> color_eyre::Result<OHLCCents> {
|
||||
if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 < date {
|
||||
if self._1d.is_none() || self._1d.as_ref().unwrap().last_key_value().unwrap().0 <= date {
|
||||
self._1d.replace(Kraken::fetch_1d()?);
|
||||
}
|
||||
self._1d
|
||||
|
||||
@@ -31,7 +31,12 @@ impl DTS for Query<'static> {
|
||||
|
||||
let indexes = Index::all();
|
||||
|
||||
let mut contents = indexes
|
||||
let mut contents = "//
|
||||
// File auto-generated, any modification will be overwritten
|
||||
//\n\n"
|
||||
.to_string();
|
||||
|
||||
contents += &indexes
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i_of_i, i)| {
|
||||
|
||||
Reference in New Issue
Block a user