Skip to content

Commit 59fcd18

Browse files
fix: lots with .CB suffix did not work
1 parent 085ba85 commit 59fcd18

File tree

5 files changed

+10
-115
lines changed

5 files changed

+10
-115
lines changed

internal/monitor/coinbase/monitor_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ var _ = Describe("Monitor Coinbase", func() {
155155
Expect(err).NotTo(HaveOccurred())
156156

157157
Expect(assetQuotes).To(HaveLen(2))
158-
Expect(assetQuotes[0].Symbol).To(Equal("BIT-31JAN25-CDE"))
158+
Expect(assetQuotes[0].Symbol).To(Equal("BIT-31JAN25-CDE.CB"))
159159
Expect(assetQuotes[0].Name).To(Equal("Bitcoin January 2025 Future"))
160160
Expect(assetQuotes[0].Class).To(Equal(c.AssetClassFuturesContract))
161-
Expect(assetQuotes[1].Symbol).To(Equal("ETH"))
161+
Expect(assetQuotes[1].Symbol).To(Equal("ETH.CB"))
162162
Expect(assetQuotes[1].Name).To(Equal("Ethereum"))
163163
Expect(assetQuotes[1].Class).To(Equal(c.AssetClassCryptocurrency))
164164
Expect(outputAssetQuotes).To(HaveLen(2))
165-
Expect(outputAssetQuotes[0].Symbol).To(Equal("BIT-31JAN25-CDE"))
165+
Expect(outputAssetQuotes[0].Symbol).To(Equal("BIT-31JAN25-CDE.CB"))
166166
Expect(outputAssetQuotes[0].Name).To(Equal("Bitcoin January 2025 Future"))
167167
Expect(outputAssetQuotes[0].Class).To(Equal(c.AssetClassFuturesContract))
168-
Expect(outputAssetQuotes[1].Symbol).To(Equal("ETH"))
168+
Expect(outputAssetQuotes[1].Symbol).To(Equal("ETH.CB"))
169169
Expect(outputAssetQuotes[1].Name).To(Equal("Ethereum"))
170170
Expect(outputAssetQuotes[1].Class).To(Equal(c.AssetClassCryptocurrency))
171171
})
@@ -655,7 +655,7 @@ var _ = Describe("Monitor Coinbase", func() {
655655
return outputCalled
656656
}, 2*time.Second).Should(BeTrue())
657657
Expect(outputAssetQuote.QuotePrice.Price).To(Equal(75000.00))
658-
Expect(outputAssetQuote.Symbol).To(Equal("BIT-31JAN25-CDE"))
658+
Expect(outputAssetQuote.Symbol).To(Equal("BIT-31JAN25-CDE.CB"))
659659

660660
monitor.Stop()
661661
})

internal/monitor/coinbase/unary/unary.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ func transformResponseQuote(responseQuote ResponseQuote) c.AssetQuote {
9393
change := price * (changePercent / 100)
9494

9595
name := responseQuote.ShortName
96-
symbol := responseQuote.Symbol
96+
symbol := responseQuote.Symbol + ".CB"
9797
isActive := responseQuote.MarketState == "online"
9898
class := c.AssetClassCryptocurrency
9999
quoteFutures := c.QuoteFutures{}
100100

101101
if responseQuote.ProductType == productTypeFuture {
102102

103103
name = responseQuote.FutureProductDetails.GroupDescription
104-
symbol = responseQuote.ProductID
104+
symbol = responseQuote.ProductID + ".CB"
105105
isActive = responseQuote.FcmTradingSessionDetails.IsSessionOpen
106106
class = c.AssetClassFuturesContract
107107
expirationTimezone, _ := time.LoadLocation(responseQuote.FutureProductDetails.ExpirationTimezone)

internal/monitor/coinbase/unary/unary_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var _ = Describe("Unary", func() {
5959

6060
Expect(err).NotTo(HaveOccurred())
6161
Expect(quotes).To(HaveLen(1))
62-
Expect(quotes[0].Symbol).To(Equal("BTC"))
62+
Expect(quotes[0].Symbol).To(Equal("BTC.CB"))
6363
Expect(quotes[0].QuotePrice.Price).To(Equal(50000.00))
6464
})
6565

@@ -107,7 +107,7 @@ var _ = Describe("Unary", func() {
107107

108108
Expect(err).NotTo(HaveOccurred())
109109
Expect(quotes).To(HaveLen(2))
110-
Expect(quotes[0].Symbol).To(Equal("BIT-31JAN25-CDE"))
110+
Expect(quotes[0].Symbol).To(Equal("BIT-31JAN25-CDE.CB"))
111111
Expect(quotes[0].QuotePrice.Price).To(Equal(60000.00))
112112
Expect(quotes[0].QuoteFutures.SymbolUnderlying).To(Equal("BTC-USD"))
113113
Expect(quotes[0].QuoteFutures.IndexPrice).To(Equal(0.00))
@@ -164,7 +164,7 @@ var _ = Describe("Unary", func() {
164164

165165
Expect(err).NotTo(HaveOccurred())
166166
Expect(quotes).To(HaveLen(2))
167-
Expect(quotes[0].Symbol).To(Equal(productId))
167+
Expect(quotes[0].Symbol).To(Equal(productId + ".CB"))
168168
Expect(quotes[0].QuoteFutures.Expiry).To(MatchRegexp(`-?\d+h`))
169169
Expect(quotes[0].QuoteFutures.Expiry).To(MatchRegexp(`-?\d+min`))
170170
Expect(quotes[0].QuoteFutures.Expiry).NotTo(MatchRegexp(`-?\d+d`))

internal/ui/component/watchlist/watchlist.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"strconv"
66
"strings"
7-
"time"
87

98
c "github.com/achannarasappa/ticker/v4/internal/common"
109
s "github.com/achannarasappa/ticker/v4/internal/sorter"
@@ -51,16 +50,6 @@ type cellWidthsContainer struct {
5150

5251
// Messages for updating assets
5352
type SetAssetsMsg []c.Asset
54-
type SetAssetMsg struct {
55-
Symbol string
56-
Asset c.Asset
57-
Time time.Time
58-
}
59-
type SetAssetQuotePriceMsg struct {
60-
Symbol string
61-
QuotePrice c.QuotePrice
62-
Time time.Time
63-
}
6453

6554
// NewModel returns a model with default values
6655
func NewModel(ctx c.Context) *Model {
@@ -99,16 +88,7 @@ func (m *Model) Update(msg tea.Msg) (*Model, tea.Cmd) {
9988
m.assetsBySymbol = assetsBySymbol
10089

10190
return m, nil
102-
case SetAssetMsg:
103-
if asset, ok := m.assetsBySymbol[msg.Symbol]; ok {
104-
asset.Holding = msg.Asset.Holding
105-
asset.QuotePrice = msg.Asset.QuotePrice
106-
asset.QuoteExtended = msg.Asset.QuoteExtended
107-
asset.QuoteFutures = msg.Asset.QuoteFutures
108-
asset.Meta.OrderIndex = msg.Asset.Meta.OrderIndex
109-
}
11091

111-
return m, nil
11292
}
11393

11494
return m, nil

internal/ui/component/watchlist/watchlist_test.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -134,91 +134,6 @@ var _ = Describe("Watchlist", func() {
134134
Expect("\n" + removeFormatting(m.View())).To(BeIdenticalTo("\n" + string(expected)))
135135
})
136136

137-
When("the prices changes for a single symbol", func() {
138-
139-
It("should update the price for the symbol", func() {
140-
m := NewModel(c.Context{
141-
Reference: c.Reference{Styles: stylesFixture},
142-
Config: c.Config{
143-
ShowHoldings: false,
144-
Sort: "alpha",
145-
},
146-
})
147-
148-
// Initial state
149-
initialAssets := []c.Asset{
150-
{
151-
Symbol: "AAPL",
152-
Name: "Apple Inc.",
153-
QuotePrice: c.QuotePrice{
154-
Price: 150.00,
155-
Change: 5.00,
156-
ChangePercent: 3.33,
157-
},
158-
Exchange: c.Exchange{IsActive: true, IsRegularTradingSession: true},
159-
},
160-
}
161-
m.Update(SetAssetsMsg(initialAssets))
162-
initialView := m.View()
163-
164-
// Update price using SetAssetQuotePriceMsg
165-
m.Update(SetAssetQuotePriceMsg{
166-
Symbol: "AAPL",
167-
QuotePrice: c.QuotePrice{
168-
Price: 160.00,
169-
Change: 10.00,
170-
ChangePercent: 6.67,
171-
},
172-
})
173-
174-
updatedView := m.View()
175-
Expect(removeFormatting(updatedView)).To(ContainSubstring("160.00"))
176-
Expect(removeFormatting(updatedView)).To(ContainSubstring("10.00"))
177-
Expect(removeFormatting(updatedView)).To(ContainSubstring("6.67%"))
178-
Expect(removeFormatting(updatedView)).ToNot(Equal(removeFormatting(initialView)))
179-
})
180-
181-
When("symbol is not already on the watchlist", func() {
182-
It("should ignore that symbol", func() {
183-
m := NewModel(c.Context{
184-
Reference: c.Reference{Styles: stylesFixture},
185-
Config: c.Config{
186-
ShowHoldings: false,
187-
Sort: "alpha",
188-
},
189-
})
190-
191-
// Initial state
192-
initialAssets := []c.Asset{
193-
{
194-
Symbol: "AAPL",
195-
Name: "Apple Inc.",
196-
QuotePrice: c.QuotePrice{
197-
Price: 150.00,
198-
Change: 5.00,
199-
ChangePercent: 3.33,
200-
},
201-
Exchange: c.Exchange{IsActive: true, IsRegularTradingSession: true},
202-
},
203-
}
204-
m.Update(SetAssetsMsg(initialAssets))
205-
initialView := m.View()
206-
207-
// Try to update non-existent symbol
208-
m.Update(SetAssetQuotePriceMsg{
209-
Symbol: "MSFT",
210-
QuotePrice: c.QuotePrice{
211-
Price: 300.00,
212-
Change: 10.00,
213-
ChangePercent: 3.33,
214-
},
215-
})
216-
217-
Expect(removeFormatting(m.View())).To(Equal(removeFormatting(initialView)))
218-
})
219-
})
220-
})
221-
222137
When("an unknown update message is received", func() {
223138
It("should ignore the message", func() {
224139
m := NewModel(c.Context{

0 commit comments

Comments
 (0)