|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/gaarutyunov/guix/pkg/runtime/chart" |
| 5 | +) |
| 6 | + |
| 7 | +// BitcoinChart creates a Bitcoin OHLCV candlestick chart |
| 8 | +func BitcoinChart() (Chart) { |
| 9 | + // Sample Bitcoin OHLCV data (daily candles from Dec 2024) |
| 10 | + data := []chart.OHLCV{ |
| 11 | + {Timestamp: 1701388800000, Open: 37500, High: 38200, Low: 37100, Close: 37800, Volume: 28500000000}, |
| 12 | + {Timestamp: 1701475200000, Open: 37800, High: 39100, Low: 37600, Close: 38900, Volume: 32100000000}, |
| 13 | + {Timestamp: 1701561600000, Open: 38900, High: 40200, Low: 38500, Close: 39800, Volume: 41200000000}, |
| 14 | + {Timestamp: 1701648000000, Open: 39800, High: 41500, Low: 39200, Close: 41200, Volume: 45600000000}, |
| 15 | + {Timestamp: 1701734400000, Open: 41200, High: 42100, Low: 40800, Close: 40500, Volume: 38900000000}, |
| 16 | + {Timestamp: 1701820800000, Open: 40500, High: 41800, Low: 39900, Close: 41600, Volume: 35200000000}, |
| 17 | + {Timestamp: 1701907200000, Open: 41600, High: 43500, Low: 41200, Close: 43200, Volume: 52100000000}, |
| 18 | + {Timestamp: 1701993600000, Open: 43200, High: 44100, Low: 42500, Close: 43800, Volume: 48700000000}, |
| 19 | + {Timestamp: 1702080000000, Open: 43800, High: 44500, Low: 42200, Close: 42800, Volume: 39400000000}, |
| 20 | + {Timestamp: 1702166400000, Open: 42800, High: 43900, Low: 41800, Close: 43500, Volume: 36800000000}, |
| 21 | + {Timestamp: 1702252800000, Open: 43500, High: 44200, Low: 42900, Close: 43100, Volume: 34200000000}, |
| 22 | + {Timestamp: 1702339200000, Open: 43100, High: 44800, Low: 42800, Close: 44600, Volume: 42800000000}, |
| 23 | + {Timestamp: 1702425600000, Open: 44600, High: 45500, Low: 43900, Close: 45200, Volume: 46100000000}, |
| 24 | + {Timestamp: 1702512000000, Open: 45200, High: 46100, Low: 44800, Close: 45800, Volume: 43900000000}, |
| 25 | + {Timestamp: 1702598400000, Open: 45800, High: 46500, Low: 44900, Close: 45100, Volume: 38700000000}, |
| 26 | + {Timestamp: 1702684800000, Open: 45100, High: 45900, Low: 44200, Close: 44800, Volume: 35600000000}, |
| 27 | + {Timestamp: 1702771200000, Open: 44800, High: 46200, Low: 44500, Close: 46000, Volume: 41200000000}, |
| 28 | + {Timestamp: 1702857600000, Open: 46000, High: 47100, Low: 45700, Close: 46900, Volume: 48300000000}, |
| 29 | + {Timestamp: 1702944000000, Open: 46900, High: 47800, Low: 46200, Close: 47500, Volume: 51200000000}, |
| 30 | + {Timestamp: 1703030400000, Open: 47500, High: 48200, Low: 46800, Close: 47100, Volume: 44800000000}, |
| 31 | + } |
| 32 | + |
| 33 | + chart.ChartNode( |
| 34 | + chart.ChartBackground(0.08, 0.09, 0.12, 1.0), |
| 35 | + chart.ChartPaddingProp(60, 20, 40, 80), |
| 36 | + chart.ChartInteractive(true), |
| 37 | + |
| 38 | + // X-Axis: Time scale |
| 39 | + chart.XAxis( |
| 40 | + chart.AxisPos(chart.AxisBottom), |
| 41 | + chart.TimeScale(true), |
| 42 | + chart.TickFormat(func(t float64) string { |
| 43 | + return chart.FormatTime(int64(t), "short") |
| 44 | + }), |
| 45 | + chart.GridLines(true), |
| 46 | + chart.GridColor(0.2, 0.2, 0.25, 0.5), |
| 47 | + chart.Label("Date"), |
| 48 | + ), |
| 49 | + |
| 50 | + // Y-Axis: Price scale |
| 51 | + chart.YAxis( |
| 52 | + chart.AxisPos(chart.AxisRight), |
| 53 | + chart.TickFormat(func(v float64) string { |
| 54 | + return chart.FormatCurrency(v, "USD") |
| 55 | + }), |
| 56 | + chart.GridLines(true), |
| 57 | + chart.GridColor(0.2, 0.2, 0.25, 0.5), |
| 58 | + chart.Label("Price (USD)"), |
| 59 | + ), |
| 60 | + |
| 61 | + // Main candlestick series |
| 62 | + chart.CandlestickSeries( |
| 63 | + chart.DataProp(data), |
| 64 | + chart.UpColor(0.18, 0.80, 0.44, 1.0), // Green for gains |
| 65 | + chart.DownColor(0.91, 0.27, 0.38, 1.0), // Red for losses |
| 66 | + chart.WickColor(0.6, 0.6, 0.65, 1.0), |
| 67 | + chart.BarWidth(0.8), |
| 68 | + ), |
| 69 | + ) |
| 70 | +} |
0 commit comments