parser: price fetch fixes

This commit is contained in:
k
2024-09-19 10:49:26 +02:00
parent 1acfcf088c
commit 7b296e4863
11 changed files with 80 additions and 79 deletions
+4 -3
View File
@@ -122,7 +122,7 @@ impl Binance {
// [timestamp, open, high, low, close, volume, ...]
let array = value.as_array().unwrap();
let timestamp = (array.first().unwrap().as_u64().unwrap() / 1000) as u32;
let timestamp = (array.first().unwrap().as_u64().unwrap() / 1_000) as u32;
let get_f32 = |index: usize| {
array
@@ -169,8 +169,9 @@ impl Binance {
// [timestamp, open, high, low, close, volume, ...]
let array = value.as_array().unwrap();
let date =
Date::from_timestamp(array.first().unwrap().as_u64().unwrap() as u32);
let date = Date::from_timestamp(
(array.first().unwrap().as_u64().unwrap() / 1_000) as u32,
);
let get_f32 = |index: usize| {
array
@@ -12,24 +12,24 @@ use crate::{
MapChunkId,
};
pub struct Satonomics;
pub struct Kibo;
const SATONOMICS_OFFICIAL_URL: &str = "https://api.satonomics.xyz";
const SATONOMICS_OFFICIAL_BACKUP_URL: &str = "https://api-bkp.satonomics.xyz";
const KIBO_OFFICIAL_URL: &str = "https://kibo.money/api";
const KIBO_OFFICIAL_BACKUP_URL: &str = "https://backup.kibo.money/api";
const RETRIES: usize = 10;
impl Satonomics {
impl Kibo {
fn get_base_url(try_index: usize) -> &'static str {
if try_index < RETRIES / 2 {
SATONOMICS_OFFICIAL_URL
KIBO_OFFICIAL_URL
} else {
SATONOMICS_OFFICIAL_BACKUP_URL
KIBO_OFFICIAL_BACKUP_URL
}
}
pub fn fetch_height_prices(chunk_id: HeightMapChunkId) -> color_eyre::Result<Vec<OHLC>> {
log("satonomics: fetch height prices");
log("kibo: fetch height prices");
retry(
|try_index| {
@@ -62,7 +62,7 @@ impl Satonomics {
}
pub fn fetch_date_prices(chunk_id: DateMapChunkId) -> color_eyre::Result<BTreeMap<Date, OHLC>> {
log("satonomics: date height prices");
log("kibo: fetch date prices");
retry(
|try_index| {
+2 -2
View File
@@ -1,7 +1,7 @@
mod binance;
mod kibo;
mod kraken;
mod satonomics;
pub use binance::*;
pub use kibo::*;
pub use kraken::*;
pub use satonomics::*;