From e14f0488c586e07110fe687d993ca0135d3e59e0 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Thu, 21 Mar 2024 22:07:16 -0700 Subject: [PATCH] Add config defaults for more assets. * LTC * SOL * XRP * DOGE * ADA --- config/default.yaml | 85 +++++++++++++++++++++++++++++++++++++++++++++ moon/moon.go | 16 ++++----- 2 files changed, 93 insertions(+), 8 deletions(-) diff --git a/config/default.yaml b/config/default.yaml index 27f42a6..dc4417e 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -44,3 +44,88 @@ assets: value: 20000 - name: $25k value: 25000 + LTC: + goals: + - name: $100 + value: 100 + - name: $150 + value: 150 + - name: $200 + value: 200 + - name: $300 + value: 300 + - name: $500 + value: 500 + - name: $1k + value: 1000 + constantBases: + - name: 2021- + time: 2020-12-31T16:00:00-08:00 + SOL: + goals: + - name: $250 + value: 250 + - name: $375 + value: 375 + - name: $500 + value: 500 + - name: $750 + value: 750 + - name: $1k + value: 1000 + - name: $2k + value: 2000 + constantBases: + - name: 2022- + time: 2021-12-31T16:00:00-08:00 + XRP: + goals: + - name: $1 + value: 1 + - name: $1.5 + value: 1.5 + - name: $2 + value: 2 + - name: $3 + value: 3 + - name: $5 + value: 5 + - name: $10 + value: 10 + constantBases: + - name: 2022- + time: 2021-12-31T16:00:00-08:00 + DOGE: + goals: + - name: $1 + value: 1 + - name: $1.5 + value: 1.5 + - name: $2 + value: 2 + - name: $3 + value: 3 + - name: $5 + value: 5 + - name: $10 + value: 10 + constantBases: + - name: 2022- + time: 2021-12-31T16:00:00-08:00 + ADA: + goals: + - name: $1 + value: 1 + - name: $1.5 + value: 1.5 + - name: $2 + value: 2 + - name: $3 + value: 3 + - name: $5 + value: 5 + - name: $10 + value: 10 + constantBases: + - name: 2022- + time: 2021-12-31T16:00:00-08:00 diff --git a/moon/moon.go b/moon/moon.go index f3986e2..07a6f51 100644 --- a/moon/moon.go +++ b/moon/moon.go @@ -86,18 +86,18 @@ func (m *Math) Refresh(ctx context.Context) (err error) { if err != nil { return err } + if len(resp.Data.Entries) == 0 { + c.Projections.Dates = nil + return nil + } c.StartingPrice = resp.Data.Entries[0].Price c.Gain = float64(m.CurrentPrice) / float64(c.StartingPrice) days := now.Sub(c.StartingDate).Hours() / 24 c.CDPR = CDPR(days, c.Gain) - if c.CDPR > 1 { - c.Projections = ProjectDates( - now, float64(m.CurrentPrice), - c.CDPR, m.Goals, - ) - } else { - c.Projections.Dates = nil - } + c.Projections = ProjectDates( + now, float64(m.CurrentPrice), + c.CDPR, m.Goals, + ) return nil }) }