#pragma once

#include <QDateTime>
#include <vector>

/**
 * @brief The ChartCandle class
 */
class ChartCandle
{
public:
    ChartCandle();
    ChartCandle(const ChartCandle& candle) = default;
    ChartCandle& operator=(const ChartCandle& candle) = default;

    void set(
        double openVal, double highVal, double lowVal,
        double closeVal, long volumeVal);

    QDateTime dateTime() const;
    double open() const;
    double high() const;
    double low() const;
    double close() const;
    long volume() const;

    void dateTime(QDateTime time);
    void open(double openVal);
    void high(double highVal);
    void low(double lowVal);
    void close(double closeVal);
    void volume(long volumeVal);

    bool isValid() const;
    bool isEmpty() const;

    double typical() const;
    bool operator==(const ChartCandle &candle);

    QString toString() const;
    static ChartCandle fromString(const QString &str);

private:
    QDateTime dateTime_;
    double open_;
    double high_;
    double low_;
    double close_;
    long volume_;
    bool valid_;
};

bool load(const std::string& filename, std::vector<ChartCandle>& candles);
