-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathDailyLiquidityForecast.py
More file actions
64 lines (50 loc) · 2.18 KB
/
DailyLiquidityForecast.py
File metadata and controls
64 lines (50 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright ©, 2022-present, Lightspark Group, Inc. - All Rights Reserved
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Mapping
from lightspark.requests.requester import Requester
from lightspark.utils.enums import parse_enum
from .CurrencyAmount import CurrencyAmount
from .CurrencyAmount import from_json as CurrencyAmount_from_json
from .LightningPaymentDirection import LightningPaymentDirection
@dataclass
class DailyLiquidityForecast:
requester: Requester
date: datetime
"""The date for which this forecast was generated."""
direction: LightningPaymentDirection
"""The direction for which this forecast was generated."""
amount: CurrencyAmount
"""The value of the forecast. It represents the amount of msats that we think will be moved for that specified direction, for that node, on that date."""
def to_json(self) -> Mapping[str, Any]:
return {
"daily_liquidity_forecast_date": self.date,
"daily_liquidity_forecast_direction": self.direction.value,
"daily_liquidity_forecast_amount": self.amount.to_json(),
}
FRAGMENT = """
fragment DailyLiquidityForecastFragment on DailyLiquidityForecast {
__typename
daily_liquidity_forecast_date: date
daily_liquidity_forecast_direction: direction
daily_liquidity_forecast_amount: amount {
__typename
currency_amount_original_value: original_value
currency_amount_original_unit: original_unit
currency_amount_preferred_currency_unit: preferred_currency_unit
currency_amount_preferred_currency_value_rounded: preferred_currency_value_rounded
currency_amount_preferred_currency_value_approx: preferred_currency_value_approx
}
}
"""
def from_json(requester: Requester, obj: Mapping[str, Any]) -> DailyLiquidityForecast:
return DailyLiquidityForecast(
requester=requester,
date=obj["daily_liquidity_forecast_date"],
direction=parse_enum(
LightningPaymentDirection, obj["daily_liquidity_forecast_direction"]
),
amount=CurrencyAmount_from_json(
requester, obj["daily_liquidity_forecast_amount"]
),
)