package se.koc.trader.struct;

import se.koc.trader.api.ExchangeConfig;
import zutil.db.DBConnection;
import zutil.db.bean.DBBean;
import zutil.db.bean.DBBeanObjectDSO;

import java.sql.SQLException;
import java.util.List;

/**
 * A data class referencing a symbol
 */
@DBBean.DBTable("symbol")
public class Symbol extends DBBean {
    private String name;
    private String baseAsset;
    private String quoteAsset;
    private double price;
    private long priceTimestamp;

    private ExchangeConfig exchangeConfig;


    public static List<Symbol> getSymbols(DBConnection db) throws SQLException {
        return DBBean.load(db, Symbol.class);
    }

    public static Symbol getSymbol(DBConnection db, long id) throws SQLException {
        return DBBean.load(db, Symbol.class, id);
    }


    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getBaseAsset() {
        return baseAsset;
    }
    public void setBaseAsset(String baseAsset) {
        this.baseAsset = baseAsset;
    }

    public String getQuoteAsset() {
        return quoteAsset;
    }
    public void setQuoteAsset(String quoteAsset) {
        this.quoteAsset = quoteAsset;
    }

    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }

    public long getPriceTimestamp() {
        return priceTimestamp;
    }
    public void setPriceTimestamp(long priceTimestamp) {
        this.priceTimestamp = priceTimestamp;
    }

    public ExchangeConfig getExchangeConfig() {
        return exchangeConfig;
    }
    public void setExchangeConfig(ExchangeConfig exchangeConfig) {
        this.exchangeConfig = exchangeConfig;
    }



    @Override
    public String toString() {
        return baseAsset + "/" + quoteAsset;
    }
}
