first commit of restructured project

This commit is contained in:
KS Jannette
2026-02-22 15:21:18 -05:00
commit 9fca234606
75 changed files with 8299 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package models
import (
"encoding/json"
"time"
)
type GridState struct {
ID int `json:"id"`
BasePrice *float64 `json:"basePrice,omitempty"`
GridLevelsJSON json.RawMessage `json:"gridLevelsJson,omitempty"`
TradesExecuted int `json:"tradesExecuted"`
TotalProfit float64 `json:"totalProfit"`
LastSRRefresh *time.Time `json:"lastSrRefresh,omitempty"`
IsActive bool `json:"isActive"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// Paper wallet fields (NULL for live trading)
PaperETHBalance *float64 `json:"paperEthBalance,omitempty"`
PaperUSDCBalance *float64 `json:"paperUsdcBalance,omitempty"`
PaperTotalGasSpent *float64 `json:"paperTotalGasSpent,omitempty"`
PaperTradesJSON json.RawMessage `json:"paperTradesJson,omitempty"`
PaperStartTime *time.Time `json:"paperStartTime,omitempty"`
PaperInitialETH *float64 `json:"paperInitialEth,omitempty"`
PaperInitialUSDC *float64 `json:"paperInitialUsdc,omitempty"`
}
type PaperWallet struct {
ETHBalance float64 `json:"ethBalance"`
USDCBalance float64 `json:"usdcBalance"`
TotalGasSpent float64 `json:"totalGasSpent"`
Trades json.RawMessage `json:"trades"`
StartTime *time.Time `json:"startTime"`
InitialETH float64 `json:"initialEth"`
InitialUSDC float64 `json:"initialUsdc"`
}

View File

@@ -0,0 +1,12 @@
package models
import "time"
type PricePoint struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
Price float64 `json:"price"`
TradingDay string `json:"tradingDay"`
Source string `json:"source"`
CreatedAt time.Time `json:"createdAt"`
}

View File

@@ -0,0 +1,27 @@
package models
import (
"math"
"time"
)
type SupportResistance struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
Method string `json:"method"`
LookbackDays int `json:"lookbackDays"`
Support float64 `json:"support"`
Resistance float64 `json:"resistance"`
Midpoint float64 `json:"midpoint"`
AvgPrice *float64 `json:"avgPrice,omitempty"`
GridRecalculated bool `json:"gridRecalculated"`
CreatedAt time.Time `json:"createdAt"`
}
func (sr *SupportResistance) HasChangedSignificantly(previous *SupportResistance, thresholdPercent float64) bool {
if previous == nil || previous.Midpoint == 0 {
return true
}
change := math.Abs((sr.Midpoint - previous.Midpoint) / previous.Midpoint * 100)
return change >= thresholdPercent
}

View File

@@ -0,0 +1,29 @@
package models
import "time"
type Trade struct {
ID int64 `json:"id"`
Timestamp time.Time `json:"timestamp"`
TradingDay string `json:"tradingDay"`
Side string `json:"side"` // "buy" or "sell"
Price float64 `json:"price"`
Quantity float64 `json:"quantity"`
USDValue float64 `json:"usdValue"`
GridLevel *int `json:"gridLevel,omitempty"`
TxHash *string `json:"txHash,omitempty"`
IsPaperTrade bool `json:"isPaperTrade"`
SlippagePercent *float64 `json:"slippagePercent,omitempty"`
GasCostETH *float64 `json:"gasCostEth,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type TradeStats struct {
TotalTrades int64 `json:"totalTrades"`
BuyCount int64 `json:"buyCount"`
SellCount int64 `json:"sellCount"`
TotalVolume *float64 `json:"totalVolume"`
AvgPrice *float64 `json:"avgPrice"`
FirstTrade *time.Time `json:"firstTrade"`
LastTrade *time.Time `json:"lastTrade"`
}