add trade and position service

This commit is contained in:
zipfriis
2026-03-27 10:14:43 +01:00
parent 2c24ee48b0
commit d0cb9af746
7 changed files with 35 additions and 22 deletions

View File

@@ -81,15 +81,15 @@ func GetTradeListHandler(db *sql.DB) http.HandlerFunc {
func GetPositionListHandler(db *sql.DB) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
tradeList, err := database.GetPositions(db)
posList, err := database.GetPositions(db)
if err != nil {
http.Error(w, "failed to fetch trades", http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("failed to fetch postiton: %s", err), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(tradeList); err != nil {
http.Error(w, "failed to encode trades", http.StatusInternalServerError)
if err := json.NewEncoder(w).Encode(map[string]any{"List": posList}); err != nil {
http.Error(w, fmt.Sprintf("failed to encode positions: %s", err), http.StatusInternalServerError)
return
}
}