import Transaction from "../../apiwrapper/transaction/Transaction.js";
import Logger from "../../logging/Logger.js";
import Serializable from "../../util/Serializable.js";
import AssetData from "../data/asset/AssetData.js";

export default class AbstractStrategy extends Serializable {
    /**
     * @type {AssetData}
     */
    #assetData = null;

    /**
     * @type {Logger}
     */
    #logger = null;

    /**
     * @param {Logger} logger 
     */
    init(logger){
        this.#logger = logger;
    }

    /**
     * @returns {Logger}
     */
    getLogger(){
        return this.#logger;
    }

    /**
     * @param {AssetData} assetData 
     */
    setAssetData(assetData) {
        this.#assetData = assetData;
        this.updateAssetData();
    }

    /**
     * @returns {AssetData}
     */
    getAssetData() {
        return this.#assetData;
    }

    updateAssetData(assetData) {
        // implement in strategy
    }

    /**
     * @param {Transaction} transaction 
     * @returns {boolean}
     */
    shouldSell(transaction) {
        // implement in strategy
        return false;
    }

    /**
     * @returns {boolean}
     */
    shouldBuy() {
        // implement in strategy
        return false;
    }

    /**
     * @param {Transaction} transaction 
     * @returns {boolean}
     */
    shouldCancle(transaction) {
        // implement in strategy
        return false;
    }

    /**
     * @param {Transaction} transaction 
     */
    addTransaction(transaction){
        // implement in strategy
    }

    /**
    * @returns {string} string representation of this object
    */
    toJson() {
        const obj = JSON.parse(super.toJson());

        return JSON.stringify(obj);
    }

    /**
     * @param {string} objString 
     * @returns {AbstractWorker}
     */
    static fromJson(objString) {
        return new AbstractStrategy();
    }
}