let wasm;

function addToExternrefTable0(obj) {
    const idx = wasm.__externref_table_alloc();
    wasm.__wbindgen_export_2.set(idx, obj);
    return idx;
}

function handleError(f, args) {
    try {
        return f.apply(this, args);
    } catch (e) {
        const idx = addToExternrefTable0(e);
        wasm.__wbindgen_exn_store(idx);
    }
}

const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );

if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };

let cachedUint8ArrayMemory0 = null;

function getUint8ArrayMemory0() {
    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
    }
    return cachedUint8ArrayMemory0;
}

function getStringFromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

function debugString(val) {
    // primitive types
    const type = typeof val;
    if (type == 'number' || type == 'boolean' || val == null) {
        return  `${val}`;
    }
    if (type == 'string') {
        return `"${val}"`;
    }
    if (type == 'symbol') {
        const description = val.description;
        if (description == null) {
            return 'Symbol';
        } else {
            return `Symbol(${description})`;
        }
    }
    if (type == 'function') {
        const name = val.name;
        if (typeof name == 'string' && name.length > 0) {
            return `Function(${name})`;
        } else {
            return 'Function';
        }
    }
    // objects
    if (Array.isArray(val)) {
        const length = val.length;
        let debug = '[';
        if (length > 0) {
            debug += debugString(val[0]);
        }
        for(let i = 1; i < length; i++) {
            debug += ', ' + debugString(val[i]);
        }
        debug += ']';
        return debug;
    }
    // Test for built-in
    const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
    let className;
    if (builtInMatches && builtInMatches.length > 1) {
        className = builtInMatches[1];
    } else {
        // Failed to match the standard '[object ClassName]'
        return toString.call(val);
    }
    if (className == 'Object') {
        // we're a user defined class or Object
        // JSON.stringify avoids problems with cycles, and is generally much
        // easier than looping through ownProperties of `val`.
        try {
            return 'Object(' + JSON.stringify(val) + ')';
        } catch (_) {
            return 'Object';
        }
    }
    // errors
    if (val instanceof Error) {
        return `${val.name}: ${val.message}\n${val.stack}`;
    }
    // TODO we could test for more things here, like `Set`s and `Map`s.
    return className;
}

let WASM_VECTOR_LEN = 0;

const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );

const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
    ? function (arg, view) {
    return cachedTextEncoder.encodeInto(arg, view);
}
    : function (arg, view) {
    const buf = cachedTextEncoder.encode(arg);
    view.set(buf);
    return {
        read: arg.length,
        written: buf.length
    };
});

function passStringToWasm0(arg, malloc, realloc) {

    if (realloc === undefined) {
        const buf = cachedTextEncoder.encode(arg);
        const ptr = malloc(buf.length, 1) >>> 0;
        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
        WASM_VECTOR_LEN = buf.length;
        return ptr;
    }

    let len = arg.length;
    let ptr = malloc(len, 1) >>> 0;

    const mem = getUint8ArrayMemory0();

    let offset = 0;

    for (; offset < len; offset++) {
        const code = arg.charCodeAt(offset);
        if (code > 0x7F) break;
        mem[ptr + offset] = code;
    }

    if (offset !== len) {
        if (offset !== 0) {
            arg = arg.slice(offset);
        }
        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
        const ret = encodeString(arg, view);

        offset += ret.written;
        ptr = realloc(ptr, len, offset, 1) >>> 0;
    }

    WASM_VECTOR_LEN = offset;
    return ptr;
}

let cachedDataViewMemory0 = null;

function getDataViewMemory0() {
    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
    }
    return cachedDataViewMemory0;
}

function isLikeNone(x) {
    return x === undefined || x === null;
}

function _assertClass(instance, klass) {
    if (!(instance instanceof klass)) {
        throw new Error(`expected instance of ${klass.name}`);
    }
}

function takeFromExternrefTable0(idx) {
    const value = wasm.__wbindgen_export_2.get(idx);
    wasm.__externref_table_dealloc(idx);
    return value;
}

function getArrayJsValueFromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    const mem = getDataViewMemory0();
    const result = [];
    for (let i = ptr; i < ptr + 4 * len; i += 4) {
        result.push(wasm.__wbindgen_export_2.get(mem.getUint32(i, true)));
    }
    wasm.__externref_drop_slice(ptr, len);
    return result;
}

function passArrayJsValueToWasm0(array, malloc) {
    const ptr = malloc(array.length * 4, 4) >>> 0;
    for (let i = 0; i < array.length; i++) {
        const add = addToExternrefTable0(array[i]);
        getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
    }
    WASM_VECTOR_LEN = array.length;
    return ptr;
}

let cachedFloat64ArrayMemory0 = null;

function getFloat64ArrayMemory0() {
    if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
        cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
    }
    return cachedFloat64ArrayMemory0;
}

function passArrayF64ToWasm0(arg, malloc) {
    const ptr = malloc(arg.length * 8, 8) >>> 0;
    getFloat64ArrayMemory0().set(arg, ptr / 8);
    WASM_VECTOR_LEN = arg.length;
    return ptr;
}
/**
 * @param {any[] | null} [open_time]
 * @param {any[] | null} [close_time]
 * @param {Float64Array | null} [open]
 * @param {Float64Array | null} [high]
 * @param {Float64Array | null} [low]
 * @param {Float64Array | null} [close]
 * @param {Float64Array | null} [volume]
 * @returns {OhlcvBar[]}
 */
export function zipOhlcvBars(open_time, close_time, open, high, low, close, volume) {
    var ptr0 = isLikeNone(open_time) ? 0 : passArrayJsValueToWasm0(open_time, wasm.__wbindgen_malloc);
    var len0 = WASM_VECTOR_LEN;
    var ptr1 = isLikeNone(close_time) ? 0 : passArrayJsValueToWasm0(close_time, wasm.__wbindgen_malloc);
    var len1 = WASM_VECTOR_LEN;
    var ptr2 = isLikeNone(open) ? 0 : passArrayF64ToWasm0(open, wasm.__wbindgen_malloc);
    var len2 = WASM_VECTOR_LEN;
    var ptr3 = isLikeNone(high) ? 0 : passArrayF64ToWasm0(high, wasm.__wbindgen_malloc);
    var len3 = WASM_VECTOR_LEN;
    var ptr4 = isLikeNone(low) ? 0 : passArrayF64ToWasm0(low, wasm.__wbindgen_malloc);
    var len4 = WASM_VECTOR_LEN;
    var ptr5 = isLikeNone(close) ? 0 : passArrayF64ToWasm0(close, wasm.__wbindgen_malloc);
    var len5 = WASM_VECTOR_LEN;
    var ptr6 = isLikeNone(volume) ? 0 : passArrayF64ToWasm0(volume, wasm.__wbindgen_malloc);
    var len6 = WASM_VECTOR_LEN;
    const ret = wasm.zipOhlcvBars(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
    var v8 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
    wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
    return v8;
}

function getArrayF64FromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
}
/**
 * @returns {string}
 */
export function _getCoreVersion() {
    let deferred1_0;
    let deferred1_1;
    try {
        const ret = wasm._getCoreVersion();
        deferred1_0 = ret[0];
        deferred1_1 = ret[1];
        return getStringFromWasm0(ret[0], ret[1]);
    } finally {
        wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
    }
}

/**
 * @param {Float64Array} equity
 * @param {boolean | null} [skip_first]
 * @returns {Float64Array}
 */
export function returns(equity, skip_first) {
    const ptr0 = passArrayF64ToWasm0(equity, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.returns(ptr0, len0, isLikeNone(skip_first) ? 0xFFFFFF : skip_first ? 1 : 0);
    var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
    wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
    return v2;
}

/**
 * @param {Float64Array} values
 * @returns {number}
 */
export function stdev(values) {
    const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.stdev(ptr0, len0);
    return ret;
}

/**
 * @param {Float64Array} values
 * @returns {number}
 */
export function variance(values) {
    const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.variance(ptr0, len0);
    return ret;
}

/**
 * @param {Float64Array} values
 * @returns {number}
 */
export function mean(values) {
    const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.mean(ptr0, len0);
    return ret;
}

/**
 * @param {Float64Array} values
 * @returns {number}
 */
export function sum(values) {
    const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.sum(ptr0, len0);
    return ret;
}

/**
 * @param {number} precision
 * @param {number} recall
 * @returns {number}
 */
export function f1(precision, recall) {
    const ret = wasm.f1(precision, recall);
    return ret;
}

/**
 * @param {number} tp_count
 * @param {number} fn_count
 * @returns {number}
 */
export function recall(tp_count, fn_count) {
    const ret = wasm.precision(tp_count, fn_count);
    return ret;
}

/**
 * @param {number} tp_count
 * @param {number} fp_count
 * @returns {number}
 */
export function precision(tp_count, fp_count) {
    const ret = wasm.precision(tp_count, fp_count);
    return ret;
}

/**
 * @param {number} tp_count
 * @param {number} fp_count
 * @param {number} fn_count
 * @param {number} tn_count
 * @returns {number}
 */
export function accuracy(tp_count, fp_count, fn_count, tn_count) {
    const ret = wasm.accuracy(tp_count, fp_count, fn_count, tn_count);
    return ret;
}

/**
 * @param {number} short_net_profit
 * @param {number} initial_capital
 * @returns {number}
 */
export function shortNetProfitPct(short_net_profit, initial_capital) {
    const ret = wasm.grossLossPct(short_net_profit, initial_capital);
    return ret;
}

/**
 * @param {number} long_net_profit
 * @param {number} initial_capital
 * @returns {number}
 */
export function longNetProfitPct(long_net_profit, initial_capital) {
    const ret = wasm.grossLossPct(long_net_profit, initial_capital);
    return ret;
}

/**
 * @param {number} gross_loss
 * @param {number} initial_capital
 * @returns {number}
 */
export function grossLossPct(gross_loss, initial_capital) {
    const ret = wasm.grossLossPct(gross_loss, initial_capital);
    return ret;
}

/**
 * @param {number} gross_profit
 * @param {number} initial_capital
 * @returns {number}
 */
export function grossProfitPct(gross_profit, initial_capital) {
    const ret = wasm.grossLossPct(gross_profit, initial_capital);
    return ret;
}

/**
 * @param {number} net_profit
 * @param {number} initial_capital
 * @returns {number}
 */
export function netProfitPct(net_profit, initial_capital) {
    const ret = wasm.grossLossPct(net_profit, initial_capital);
    return ret;
}

/**
 * @param {Float64Array} returns
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function omegaRatioFromReturns(returns, risk_free_rate) {
    const ptr0 = passArrayF64ToWasm0(returns, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.omegaRatioFromReturns(ptr0, len0, risk_free_rate);
    return ret;
}

/**
 * @param {number} positive_returns_sum
 * @param {number} negative_returns_sum
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function omegaRatio(positive_returns_sum, negative_returns_sum, risk_free_rate) {
    const ret = wasm.omegaRatio(positive_returns_sum, negative_returns_sum, risk_free_rate);
    return ret;
}

/**
 * @param {Float64Array} returns
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function sortinoRatioFromReturns(returns, risk_free_rate) {
    const ptr0 = passArrayF64ToWasm0(returns, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.sortinoRatioFromReturns(ptr0, len0, risk_free_rate);
    return ret;
}

/**
 * @param {number} mean_returns
 * @param {number} negative_returns_stdev
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function sortinoRatio(mean_returns, negative_returns_stdev, risk_free_rate) {
    const ret = wasm.omegaRatio(mean_returns, negative_returns_stdev, risk_free_rate);
    return ret;
}

/**
 * @param {Float64Array} returns
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function sharpeRatioFromReturns(returns, risk_free_rate) {
    const ptr0 = passArrayF64ToWasm0(returns, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.sharpeRatioFromReturns(ptr0, len0, risk_free_rate);
    return ret;
}

/**
 * @param {number} mean_returns
 * @param {number} std_returns
 * @param {number} risk_free_rate
 * @returns {number}
 */
export function sharpeRatio(mean_returns, std_returns, risk_free_rate) {
    const ret = wasm.omegaRatio(mean_returns, std_returns, risk_free_rate);
    return ret;
}

/**
 * @param {number} avg_winning_trade
 * @param {number} avg_losing_trade
 * @returns {number}
 */
export function avgWinLossRatio(avg_winning_trade, avg_losing_trade) {
    const ret = wasm.avgWinLossRatio(avg_winning_trade, avg_losing_trade);
    return ret;
}

/**
 * @param {number} gross_loss
 * @param {number} losing_trades
 * @returns {number}
 */
export function avgLosingTrade(gross_loss, losing_trades) {
    const ret = wasm.avgLosingTrade(gross_loss, losing_trades);
    return ret;
}

/**
 * @param {number} gross_profit
 * @param {number} winning_trades
 * @returns {number}
 */
export function avgWinningTrade(gross_profit, winning_trades) {
    const ret = wasm.avgLosingTrade(gross_profit, winning_trades);
    return ret;
}

/**
 * @param {number} net_profit
 * @param {number} closed_trades
 * @returns {number}
 */
export function avgTrade(net_profit, closed_trades) {
    const ret = wasm.avgLosingTrade(net_profit, closed_trades);
    return ret;
}

/**
 * @param {number} profitable_trades
 * @param {number} total_trades
 * @returns {number}
 */
export function winRate(profitable_trades, total_trades) {
    const ret = wasm.winRate(profitable_trades, total_trades);
    return ret;
}

/**
 * @param {number} long_net_profit
 * @param {number} short_net_profit
 * @returns {number}
 */
export function longNetProfitRatio(long_net_profit, short_net_profit) {
    const ret = wasm.longNetProfitRatio(long_net_profit, short_net_profit);
    return ret;
}

/**
 * @param {number} gross_profit
 * @param {number} gross_loss
 * @returns {number}
 */
export function profitFactor(gross_profit, gross_loss) {
    const ret = wasm.avgWinLossRatio(gross_profit, gross_loss);
    return ret;
}

/**
 * @param {number} qty
 * @param {number} entry_price
 * @param {number} current_price
 * @returns {number}
 */
export function pnl(qty, entry_price, current_price) {
    const ret = wasm.pnl(qty, entry_price, current_price);
    return ret;
}

/**
 * @param {number} expectancy
 * @param {number} opportunity_bars
 * @returns {number}
 */
export function expectancyScore(expectancy, opportunity_bars) {
    const ret = wasm.expectancyScore(expectancy, opportunity_bars);
    return ret;
}

/**
 * @param {Float64Array} pnl
 * @returns {number}
 */
export function expectancy(pnl) {
    const ptr0 = passArrayF64ToWasm0(pnl, wasm.__wbindgen_malloc);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.expectancy(ptr0, len0);
    return ret;
}

/**
 * @param {number} equity_pct
 * @param {number} equity
 * @param {number} current_position
 * @param {number} instrument_price
 * @param {number} point_value
 * @param {number} exchange_rate
 * @returns {number}
 */
export function orderSizeForEquityPct(equity_pct, equity, current_position, instrument_price, point_value, exchange_rate) {
    const ret = wasm.orderSizeForEquityPct(equity_pct, equity, current_position, instrument_price, point_value, exchange_rate);
    return ret;
}

/**
 * @param {number} equity_pct
 * @param {number} equity
 * @param {number} exchange_rate
 * @param {number} instrument_price
 * @param {number} point_value
 * @returns {number}
 */
export function orderSize(equity_pct, equity, exchange_rate, instrument_price, point_value) {
    const ret = wasm.orderSize(equity_pct, equity, exchange_rate, instrument_price, point_value);
    return ret;
}

/**
 * @param {number} size
 * @param {number} min_qty
 * @returns {boolean}
 */
export function validateContracts(size, min_qty) {
    const ret = wasm.validateContracts(size, min_qty);
    return ret !== 0;
}

/**
 * @param {number} size
 * @param {number} min_qty
 * @param {number} price_scale
 * @returns {number}
 */
export function roundContracts(size, min_qty, price_scale) {
    const ret = wasm.roundContracts(size, min_qty, price_scale);
    return ret;
}

/**
 * @param {number} value
 * @param {number} min_tick
 * @returns {number}
 */
export function roundToMinTick(value, min_tick) {
    const ret = wasm.roundToMinTick(value, min_tick);
    return ret;
}

function __wbg_adapter_264(arg0, arg1, arg2, arg3) {
    wasm.closure77_externref_shim(arg0, arg1, arg2, arg3);
}

const BacktestFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_backtest_free(ptr >>> 0, 1));

export class Backtest {

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        BacktestFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_backtest_free(ptr, 0);
    }
    /**
     * @param {Ctx} ctx
     * @param {number | null} [initial_capital]
     * @param {boolean | null} [process_orders_on_close]
     */
    constructor(ctx, initial_capital, process_orders_on_close) {
        _assertClass(ctx, Ctx);
        var ptr0 = ctx.__destroy_into_raw();
        const ret = wasm.backtest_wasm_new(ptr0, !isLikeNone(initial_capital), isLikeNone(initial_capital) ? 0 : initial_capital, isLikeNone(process_orders_on_close) ? 0xFFFFFF : process_orders_on_close ? 1 : 0);
        this.__wbg_ptr = ret >>> 0;
        BacktestFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @returns {number}
     */
    get initialCapital() {
        const ret = wasm.backtest_wasm_initial_capital(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {boolean}
     */
    get processOrdersOnClose() {
        const ret = wasm.backtest_wasm_process_orders_on_close(this.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * @returns {Ctx}
     */
    get ctx() {
        const ret = wasm.backtest_wasm_ctx(this.__wbg_ptr);
        return Ctx.__wrap(ret);
    }
    /**
     * @returns {number}
     */
    get equity() {
        const ret = wasm.backtest_wasm_equity(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get netEquity() {
        const ret = wasm.backtest_wasm_net_equity(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {Float64Array}
     */
    get equityList() {
        const ret = wasm.backtest_wasm_equity_list(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get netEquityList() {
        const ret = wasm.backtest_wasm_net_equity_list(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get pnlList() {
        const ret = wasm.backtest_wasm_pnl_list(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {number}
     */
    get openProfit() {
        const ret = wasm.backtest_wasm_open_profit(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get netProfit() {
        const ret = wasm.backtest_wasm_net_profit(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get grossProfit() {
        const ret = wasm.backtest_wasm_gross_profit(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get grossLoss() {
        const ret = wasm.backtest_wasm_gross_loss(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get positionSize() {
        const ret = wasm.backtest_wasm_position_size(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {Trade[]}
     */
    get trades() {
        const ret = wasm.backtest_wasm_trades(this.__wbg_ptr);
        var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
        return v1;
    }
    onBarOpen() {
        wasm.backtest_onBarOpen(this.__wbg_ptr);
    }
    onBarClose() {
        wasm.backtest_onBarClose(this.__wbg_ptr);
    }
    /**
     * @param {Signal} signal
     */
    signal(signal) {
        _assertClass(signal, Signal);
        var ptr0 = signal.__destroy_into_raw();
        wasm.backtest_signal(this.__wbg_ptr, ptr0);
    }
    /**
     * @param {Array<any>} signals
     */
    signalList(signals) {
        wasm.backtest_signalList(this.__wbg_ptr, signals);
    }
    /**
     * @param {Map<any, any>} signals
     */
    signalMap(signals) {
        wasm.backtest_signalMap(this.__wbg_ptr, signals);
    }
    /**
     * @param {CtxSkip} skip
     */
    skip(skip) {
        _assertClass(skip, CtxSkip);
        var ptr0 = skip.__destroy_into_raw();
        wasm.backtest_skip(this.__wbg_ptr, ptr0);
    }
    /**
     * @returns {number}
     */
    length() {
        const ret = wasm.backtest_length(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * @returns {number | undefined}
     */
    next() {
        const ret = wasm.backtest_next(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {string}
     */
    toPine() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.backtest_toPine(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @param {number | null} [risk_free_rate]
     * @returns {BacktestSummary}
     */
    summary(risk_free_rate) {
        const ret = wasm.backtest_summary(this.__wbg_ptr, !isLikeNone(risk_free_rate), isLikeNone(risk_free_rate) ? 0 : risk_free_rate);
        return BacktestSummary.__wrap(ret);
    }
}

const BacktestSummaryFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_backtestsummary_free(ptr >>> 0, 1));

export class BacktestSummary {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(BacktestSummary.prototype);
        obj.__wbg_ptr = ptr;
        BacktestSummaryFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        BacktestSummaryFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_backtestsummary_free(ptr, 0);
    }
    print() {
        wasm.backtestsummary_print(this.__wbg_ptr);
    }
    /**
     * @returns {any}
     */
    toJSON() {
        const ret = wasm.backtestsummary_toJSON(this.__wbg_ptr);
        return ret;
    }
}

const CtxFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_ctx_free(ptr >>> 0, 1));

export class Ctx {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Ctx.prototype);
        obj.__wbg_ptr = ptr;
        CtxFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        CtxFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_ctx_free(ptr, 0);
    }
    /**
     * @param {Ohlcv | null} [ohlcv]
     * @param {Sym | null} [sym]
     */
    constructor(ohlcv, sym) {
        let ptr0 = 0;
        if (!isLikeNone(ohlcv)) {
            _assertClass(ohlcv, Ohlcv);
            ptr0 = ohlcv.__destroy_into_raw();
        }
        let ptr1 = 0;
        if (!isLikeNone(sym)) {
            _assertClass(sym, Sym);
            ptr1 = sym.__destroy_into_raw();
        }
        const ret = wasm.ctx_wasm_new(ptr0, ptr1);
        this.__wbg_ptr = ret >>> 0;
        CtxFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @returns {number}
     */
    get barIndex() {
        const ret = wasm.ctx_wasm_bar_index(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * @returns {OhlcvBar}
     */
    get bar() {
        const ret = wasm.ctx_wasm_bar(this.__wbg_ptr);
        return OhlcvBar.__wrap(ret);
    }
    /**
     * @returns {boolean}
     */
    get isInitialized() {
        const ret = wasm.ctx_wasm_is_initialized(this.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * @returns {Sym}
     */
    get sym() {
        const ret = wasm.ctx_wasm_sym(this.__wbg_ptr);
        return Sym.__wrap(ret);
    }
    /**
     * @returns {Ohlcv}
     */
    get ohlcv() {
        const ret = wasm.ctx_wasm_ohlcv(this.__wbg_ptr);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @returns {Ctx}
     */
    copy() {
        const ret = wasm.ctx_copy(this.__wbg_ptr);
        return Ctx.__wrap(ret);
    }
    reset() {
        wasm.ctx_reset(this.__wbg_ptr);
    }
    /**
     * @returns {number | undefined}
     */
    next() {
        const ret = wasm.ctx_next(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number}
     */
    get length() {
        const ret = wasm.ctx_wasm_length(this.__wbg_ptr);
        return ret >>> 0;
    }
}

const CtxSkipFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_ctxskip_free(ptr >>> 0, 1));

export class CtxSkip {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(CtxSkip.prototype);
        obj.__wbg_ptr = ptr;
        CtxSkipFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        CtxSkipFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_ctxskip_free(ptr, 0);
    }
    /**
     * @returns {CtxSkip}
     */
    static end() {
        const ret = wasm.ctxskip_end();
        return CtxSkip.__wrap(ret);
    }
    /**
     * @param {number} bars
     * @returns {CtxSkip}
     */
    static bars(bars) {
        const ret = wasm.ctxskip_bars(bars);
        return CtxSkip.__wrap(ret);
    }
    /**
     * @param {number} bar_index
     * @returns {CtxSkip}
     */
    static barIndex(bar_index) {
        const ret = wasm.ctxskip_barIndex(bar_index);
        return CtxSkip.__wrap(ret);
    }
    /**
     * @param {Date} open_time
     * @returns {CtxSkip}
     */
    static openTimeEq(open_time) {
        const ret = wasm.ctxskip_openTimeEq(open_time);
        return CtxSkip.__wrap(ret);
    }
    /**
     * @param {Date} open_time
     * @returns {CtxSkip}
     */
    static openTimeGeq(open_time) {
        const ret = wasm.ctxskip_openTimeGeq(open_time);
        return CtxSkip.__wrap(ret);
    }
}

const Incr_fn_accdist_f39f2fFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_incr_fn_accdist_f39f2f_free(ptr >>> 0, 1));

export class Incr_fn_accdist_f39f2f {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Incr_fn_accdist_f39f2f.prototype);
        obj.__wbg_ptr = ptr;
        Incr_fn_accdist_f39f2fFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        Incr_fn_accdist_f39f2fFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_incr_fn_accdist_f39f2f_free(ptr, 0);
    }
    /**
     * @param {Ctx} ctx
     * @returns {Incr_fn_accdist_f39f2f}
     */
    static make(ctx) {
        _assertClass(ctx, Ctx);
        const ret = wasm.incr_fn_accdist_f39f2f_make(ctx.__wbg_ptr);
        return Incr_fn_accdist_f39f2f.__wrap(ret);
    }
    /**
     * @returns {any}
     */
    next() {
        const ret = wasm.incr_fn_accdist_f39f2f_next(this.__wbg_ptr);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        return takeFromExternrefTable0(ret[0]);
    }
    /**
     * @returns {any[]}
     */
    collect() {
        const ret = wasm.incr_fn_accdist_f39f2f_collect(this.__wbg_ptr);
        if (ret[3]) {
            throw takeFromExternrefTable0(ret[2]);
        }
        var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
        return v1;
    }
}

const Incr_fn_rsi_3efcf2Finalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_incr_fn_rsi_3efcf2_free(ptr >>> 0, 1));

export class Incr_fn_rsi_3efcf2 {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Incr_fn_rsi_3efcf2.prototype);
        obj.__wbg_ptr = ptr;
        Incr_fn_rsi_3efcf2Finalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        Incr_fn_rsi_3efcf2Finalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_incr_fn_rsi_3efcf2_free(ptr, 0);
    }
    /**
     * @param {Ctx} ctx
     * @returns {Incr_fn_rsi_3efcf2}
     */
    static make(ctx) {
        _assertClass(ctx, Ctx);
        const ret = wasm.incr_fn_rsi_3efcf2_make(ctx.__wbg_ptr);
        return Incr_fn_rsi_3efcf2.__wrap(ret);
    }
    /**
     * @param {any} src
     * @param {any} length
     * @returns {any}
     */
    next(src, length) {
        const ret = wasm.incr_fn_rsi_3efcf2_next(this.__wbg_ptr, src, length);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        return takeFromExternrefTable0(ret[0]);
    }
    /**
     * @param {any} src
     * @param {any} length
     * @returns {any[]}
     */
    collect(src, length) {
        const ret = wasm.incr_fn_rsi_3efcf2_collect(this.__wbg_ptr, src, length);
        if (ret[3]) {
            throw takeFromExternrefTable0(ret[2]);
        }
        var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
        return v1;
    }
}

const OhlcvFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_ohlcv_free(ptr >>> 0, 1));

export class Ohlcv {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Ohlcv.prototype);
        obj.__wbg_ptr = ptr;
        OhlcvFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        OhlcvFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_ohlcv_free(ptr, 0);
    }
    constructor() {
        const ret = wasm.ohlcv_wasm_new();
        this.__wbg_ptr = ret >>> 0;
        OhlcvFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {OhlcvBar[]} bars
     * @returns {Ohlcv}
     */
    static fromBars(bars) {
        const ptr0 = passArrayJsValueToWasm0(bars, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.ohlcv_fromBars(ptr0, len0);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @returns {Timeframe}
     */
    get timeframe() {
        const ret = wasm.ohlcv_wasm_timeframe(this.__wbg_ptr);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {Timeframe} timeframe
     */
    set timeframe(timeframe) {
        _assertClass(timeframe, Timeframe);
        var ptr0 = timeframe.__destroy_into_raw();
        wasm.ohlcv_wasm_set_timeframe(this.__wbg_ptr, ptr0);
    }
    /**
     * @returns {Array<any>}
     */
    get openTime() {
        const ret = wasm.ohlcv_wasm_open_time(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {Array<any>}
     */
    get closeTime() {
        const ret = wasm.ohlcv_wasm_close_time(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {Float64Array}
     */
    get open() {
        const ret = wasm.ohlcv_wasm_open(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get high() {
        const ret = wasm.ohlcv_wasm_high(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get low() {
        const ret = wasm.ohlcv_wasm_low(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get close() {
        const ret = wasm.ohlcv_wasm_close(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {Float64Array}
     */
    get volume() {
        const ret = wasm.ohlcv_wasm_volume(this.__wbg_ptr);
        var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
        return v1;
    }
    /**
     * @returns {OhlcvBar[]}
     */
    get bars() {
        const ret = wasm.ohlcv_wasm_bars(this.__wbg_ptr);
        var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
        return v1;
    }
    /**
     * @param {number} index
     * @returns {OhlcvBar | undefined}
     */
    at(index) {
        const ret = wasm.ohlcv_at(this.__wbg_ptr, index);
        return ret === 0 ? undefined : OhlcvBar.__wrap(ret);
    }
    /**
     * @returns {number}
     */
    get length() {
        const ret = wasm.ohlcv_wasm_length(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * @param {number} start
     * @param {number} end
     * @returns {Ohlcv}
     */
    slice(start, end) {
        const ret = wasm.ohlcv_slice(this.__wbg_ptr, start, end);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @param {number} count
     * @returns {Ohlcv}
     */
    head(count) {
        const ret = wasm.ohlcv_head(this.__wbg_ptr, count);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @param {number} count
     * @returns {Ohlcv}
     */
    tail(count) {
        const ret = wasm.ohlcv_tail(this.__wbg_ptr, count);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @returns {Ohlcv}
     */
    copy() {
        const ret = wasm.ohlcv_copy(this.__wbg_ptr);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @param {Ohlcv} other
     */
    extend(other) {
        _assertClass(other, Ohlcv);
        wasm.ohlcv_extend(this.__wbg_ptr, other.__wbg_ptr);
    }
    /**
     * @param {Timeframe} timeframe
     * @param {boolean} align_utc
     * @returns {Ohlcv}
     */
    resample(timeframe, align_utc) {
        _assertClass(timeframe, Timeframe);
        var ptr0 = timeframe.__destroy_into_raw();
        const ret = wasm.ohlcv_resample(this.__wbg_ptr, ptr0, align_utc);
        return Ohlcv.__wrap(ret);
    }
    /**
     * @param {boolean} ascending
     */
    sort(ascending) {
        wasm.ohlcv_sort(this.__wbg_ptr, ascending);
    }
    reverse() {
        wasm.ohlcv_reverse(this.__wbg_ptr);
    }
    clear() {
        wasm.ohlcv_clear(this.__wbg_ptr);
    }
    /**
     * @returns {OhlcvBar | undefined}
     */
    pop() {
        const ret = wasm.ohlcv_pop(this.__wbg_ptr);
        return ret === 0 ? undefined : OhlcvBar.__wrap(ret);
    }
    /**
     * @returns {OhlcvBar | undefined}
     */
    shift() {
        const ret = wasm.ohlcv_shift(this.__wbg_ptr);
        return ret === 0 ? undefined : OhlcvBar.__wrap(ret);
    }
    /**
     * @param {OhlcvBar} bar
     */
    push(bar) {
        _assertClass(bar, OhlcvBar);
        var ptr0 = bar.__destroy_into_raw();
        wasm.ohlcv_push(this.__wbg_ptr, ptr0);
    }
    /**
     * @param {OhlcvBar[]} bars
     */
    pushMany(bars) {
        const ptr0 = passArrayJsValueToWasm0(bars, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        wasm.ohlcv_pushMany(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string}
     */
    toString() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.ohlcv_toString(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string[]}
     */
    sanityCheck() {
        const ret = wasm.ohlcv_sanityCheck(this.__wbg_ptr);
        var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
        wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
        return v1;
    }
    /**
     * @returns {Ohlcv}
     */
    ref() {
        const ret = wasm.ohlcv_ref(this.__wbg_ptr);
        return Ohlcv.__wrap(ret);
    }
}

const OhlcvBarFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_ohlcvbar_free(ptr >>> 0, 1));

export class OhlcvBar {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(OhlcvBar.prototype);
        obj.__wbg_ptr = ptr;
        OhlcvBarFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    static __unwrap(jsValue) {
        if (!(jsValue instanceof OhlcvBar)) {
            return 0;
        }
        return jsValue.__destroy_into_raw();
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        OhlcvBarFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_ohlcvbar_free(ptr, 0);
    }
    /**
     * @param {Date | null} [open_time]
     * @param {Date | null} [close_time]
     * @param {number | null} [open]
     * @param {number | null} [high]
     * @param {number | null} [low]
     * @param {number | null} [close]
     * @param {number | null} [volume]
     */
    constructor(open_time, close_time, open, high, low, close, volume) {
        const ret = wasm.ohlcvbar_wasm_new(isLikeNone(open_time) ? 0 : addToExternrefTable0(open_time), isLikeNone(close_time) ? 0 : addToExternrefTable0(close_time), !isLikeNone(open), isLikeNone(open) ? 0 : open, !isLikeNone(high), isLikeNone(high) ? 0 : high, !isLikeNone(low), isLikeNone(low) ? 0 : low, !isLikeNone(close), isLikeNone(close) ? 0 : close, !isLikeNone(volume), isLikeNone(volume) ? 0 : volume);
        this.__wbg_ptr = ret >>> 0;
        OhlcvBarFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @returns {Date | undefined}
     */
    get openTime() {
        const ret = wasm.ohlcvbar_wasm_open_time(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {Date | undefined}
     */
    get closeTime() {
        const ret = wasm.ohlcvbar_wasm_close_time(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get open() {
        const ret = wasm.ohlcvbar_wasm_open(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get high() {
        const ret = wasm.ohlcvbar_wasm_high(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get low() {
        const ret = wasm.ohlcvbar_wasm_low(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get close() {
        const ret = wasm.ohlcvbar_wasm_close(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {number}
     */
    get volume() {
        const ret = wasm.ohlcvbar_wasm_volume(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {OhlcvBar} other
     * @returns {OhlcvBar}
     */
    merge(other) {
        _assertClass(other, OhlcvBar);
        const ret = wasm.ohlcvbar_merge(this.__wbg_ptr, other.__wbg_ptr);
        return OhlcvBar.__wrap(ret);
    }
    /**
     * @returns {string}
     */
    toString() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.ohlcvbar_toString(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {any}
     */
    toJSON() {
        const ret = wasm.ohlcvbar_toJSON(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {any} json
     * @returns {OhlcvBar}
     */
    static fromJSON(json) {
        const ret = wasm.ohlcvbar_fromJSON(json);
        return OhlcvBar.__wrap(ret);
    }
}

const SignalFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_signal_free(ptr >>> 0, 1));

export class Signal {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Signal.prototype);
        obj.__wbg_ptr = ptr;
        SignalFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    static __unwrap(jsValue) {
        if (!(jsValue instanceof Signal)) {
            return 0;
        }
        return jsValue.__destroy_into_raw();
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        SignalFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_signal_free(ptr, 0);
    }
    /**
     * @returns {Signal}
     */
    static Hold() {
        const ret = wasm.signal_Hold();
        return Signal.__wrap(ret);
    }
    /**
     * @param {number} size
     * @returns {Signal}
     */
    static Size(size) {
        const ret = wasm.signal_Size(size);
        return Signal.__wrap(ret);
    }
    /**
     * @param {number} equity_pct
     * @returns {Signal}
     */
    static EquityPct(equity_pct) {
        const ret = wasm.signal_EquityPct(equity_pct);
        return Signal.__wrap(ret);
    }
    /**
     * @returns {Signal}
     */
    static CloseAll() {
        const ret = wasm.signal_CloseAll();
        return Signal.__wrap(ret);
    }
    /**
     * @returns {Signal}
     */
    static Long() {
        const ret = wasm.signal_Long();
        return Signal.__wrap(ret);
    }
    /**
     * @returns {Signal}
     */
    static Short() {
        const ret = wasm.signal_Short();
        return Signal.__wrap(ret);
    }
    /**
     * @returns {string | undefined}
     */
    get id() {
        const ret = wasm.signal_wasm_id(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [id]
     */
    set id(id) {
        var ptr0 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.signal_wasm_set_id(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get comment() {
        const ret = wasm.signal_wasm_comment(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [comment]
     */
    set comment(comment) {
        var ptr0 = isLikeNone(comment) ? 0 : passStringToWasm0(comment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.signal_wasm_set_comment(this.__wbg_ptr, ptr0, len0);
    }
}

const SymFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_sym_free(ptr >>> 0, 1));

export class Sym {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Sym.prototype);
        obj.__wbg_ptr = ptr;
        SymFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        SymFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_sym_free(ptr, 0);
    }
    constructor() {
        const ret = wasm.sym_new();
        this.__wbg_ptr = ret >>> 0;
        SymFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @returns {string | undefined}
     */
    get id() {
        const ret = wasm.sym_wasm_id(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [id]
     */
    set id(id) {
        var ptr0 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_id(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get tickerId() {
        const ret = wasm.sym_wasm_ticker_id(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [id]
     */
    set tickerId(id) {
        var ptr0 = isLikeNone(id) ? 0 : passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_ticker_id(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {SymKind}
     */
    get kind() {
        const ret = wasm.sym_wasm_kind(this.__wbg_ptr);
        return SymKind.__wrap(ret);
    }
    /**
     * @param {SymKind} kind
     */
    set kind(kind) {
        _assertClass(kind, SymKind);
        var ptr0 = kind.__destroy_into_raw();
        wasm.sym_wasm_set_kind(this.__wbg_ptr, ptr0);
    }
    /**
     * @returns {number}
     */
    get minTick() {
        const ret = wasm.sym_wasm_min_tick(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {number} min_tick
     */
    set minTick(min_tick) {
        wasm.sym_wasm_set_min_tick(this.__wbg_ptr, min_tick);
    }
    /**
     * @returns {number}
     */
    get minQty() {
        const ret = wasm.sym_wasm_min_qty(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {number} min_qty
     */
    set minQty(min_qty) {
        wasm.sym_wasm_set_min_qty(this.__wbg_ptr, min_qty);
    }
    /**
     * @returns {string | undefined}
     */
    get prefix() {
        const ret = wasm.sym_wasm_prefix(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [prefix]
     */
    set prefix(prefix) {
        var ptr0 = isLikeNone(prefix) ? 0 : passStringToWasm0(prefix, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_prefix(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get currency() {
        const ret = wasm.sym_wasm_currency(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [currency]
     */
    set currency(currency) {
        var ptr0 = isLikeNone(currency) ? 0 : passStringToWasm0(currency, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_currency(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get baseCurrency() {
        const ret = wasm.sym_wasm_base_currency(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [base_currency]
     */
    set baseCurrency(base_currency) {
        var ptr0 = isLikeNone(base_currency) ? 0 : passStringToWasm0(base_currency, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_base_currency(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get ticker() {
        const ret = wasm.sym_wasm_ticker(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [ticker]
     */
    set ticker(ticker) {
        var ptr0 = isLikeNone(ticker) ? 0 : passStringToWasm0(ticker, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_ticker(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get country() {
        const ret = wasm.sym_wasm_country(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [country]
     */
    set country(country) {
        var ptr0 = isLikeNone(country) ? 0 : passStringToWasm0(country, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_country(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {number}
     */
    get priceScale() {
        const ret = wasm.sym_wasm_price_scale(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {number} price_scale
     */
    set priceScale(price_scale) {
        wasm.sym_wasm_set_price_scale(this.__wbg_ptr, price_scale);
    }
    /**
     * @returns {number}
     */
    get pointValue() {
        const ret = wasm.sym_wasm_point_value(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {number} point_value
     */
    set pointValue(point_value) {
        wasm.sym_wasm_set_point_value(this.__wbg_ptr, point_value);
    }
    /**
     * @returns {string | undefined}
     */
    get metadata() {
        const ret = wasm.sym_wasm_metadata(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @param {string | null} [metadata]
     */
    set metadata(metadata) {
        var ptr0 = isLikeNone(metadata) ? 0 : passStringToWasm0(metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len0 = WASM_VECTOR_LEN;
        wasm.sym_wasm_set_metadata(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {Sym}
     */
    static BTC_USD() {
        const ret = wasm.sym_BTC_USD();
        return Sym.__wrap(ret);
    }
    /**
     * @returns {Sym}
     */
    static ETH_USD() {
        const ret = wasm.sym_ETH_USD();
        return Sym.__wrap(ret);
    }
    /**
     * @returns {Sym}
     */
    static SOL_USD() {
        const ret = wasm.sym_SOL_USD();
        return Sym.__wrap(ret);
    }
    /**
     * @returns {Sym}
     */
    static DOGE_USD() {
        const ret = wasm.sym_DOGE_USD();
        return Sym.__wrap(ret);
    }
    /**
     * @returns {any}
     */
    toJSON() {
        const ret = wasm.sym_toJSON(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {any} json
     * @returns {Sym}
     */
    static fromJSON(json) {
        const ret = wasm.sym_fromJSON(json);
        return Sym.__wrap(ret);
    }
    /**
     * @param {Sym} other
     * @returns {boolean}
     */
    eq(other) {
        _assertClass(other, Sym);
        var ptr0 = other.__destroy_into_raw();
        const ret = wasm.sym_eq(this.__wbg_ptr, ptr0);
        return ret !== 0;
    }
}

const SymKindFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_symkind_free(ptr >>> 0, 1));

export class SymKind {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(SymKind.prototype);
        obj.__wbg_ptr = ptr;
        SymKindFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        SymKindFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_symkind_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    toString() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.symkind_toString(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @param {string} kind
     * @returns {SymKind}
     */
    static fromString(kind) {
        const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.symkind_fromString(ptr0, len0);
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Stock() {
        const ret = wasm.symkind_Stock();
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Future() {
        const ret = wasm.symkind_Future();
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Option() {
        const ret = wasm.symkind_Option();
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Crypto() {
        const ret = wasm.symkind_Crypto();
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Forex() {
        const ret = wasm.symkind_Forex();
        return SymKind.__wrap(ret);
    }
    /**
     * @returns {SymKind}
     */
    static Unknown() {
        const ret = wasm.symkind_Unknown();
        return SymKind.__wrap(ret);
    }
    /**
     * @param {string} kind
     * @returns {SymKind}
     */
    static Other(kind) {
        const ptr0 = passStringToWasm0(kind, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.symkind_Other(ptr0, len0);
        return SymKind.__wrap(ret);
    }
    /**
     * @param {SymKind} other
     * @returns {boolean}
     */
    eq(other) {
        _assertClass(other, SymKind);
        var ptr0 = other.__destroy_into_raw();
        const ret = wasm.symkind_eq(this.__wbg_ptr, ptr0);
        return ret !== 0;
    }
}

const TimeframeFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_timeframe_free(ptr >>> 0, 1));

export class Timeframe {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Timeframe.prototype);
        obj.__wbg_ptr = ptr;
        TimeframeFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        TimeframeFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_timeframe_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    toString() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.timeframe_toString(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @param {string} timeframe
     * @returns {Timeframe}
     */
    static fromString(timeframe) {
        const ptr0 = passStringToWasm0(timeframe, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.timeframe_fromString(ptr0, len0);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Years(value) {
        const ret = wasm.timeframe_Years(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Months(value) {
        const ret = wasm.timeframe_Months(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Weeks(value) {
        const ret = wasm.timeframe_Weeks(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Days(value) {
        const ret = wasm.timeframe_Days(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Hours(value) {
        const ret = wasm.timeframe_Hours(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Minutes(value) {
        const ret = wasm.timeframe_Minutes(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Seconds(value) {
        const ret = wasm.timeframe_Seconds(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Ticks(value) {
        const ret = wasm.timeframe_Ticks(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @param {number} value
     * @returns {Timeframe}
     */
    static Ranges(value) {
        const ret = wasm.timeframe_Ranges(value);
        return Timeframe.__wrap(ret);
    }
    /**
     * @returns {Timeframe}
     */
    static Unknown() {
        const ret = wasm.timeframe_Unknown();
        return Timeframe.__wrap(ret);
    }
    /**
     * @returns {number | undefined}
     */
    get years() {
        const ret = wasm.timeframe_wasm_years(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get months() {
        const ret = wasm.timeframe_wasm_months(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get weeks() {
        const ret = wasm.timeframe_wasm_weeks(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get days() {
        const ret = wasm.timeframe_wasm_days(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get hours() {
        const ret = wasm.timeframe_wasm_hours(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get minutes() {
        const ret = wasm.timeframe_wasm_minutes(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get seconds() {
        const ret = wasm.timeframe_wasm_seconds(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get ticks() {
        const ret = wasm.timeframe_wasm_ticks(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {number | undefined}
     */
    get ranges() {
        const ret = wasm.timeframe_wasm_ranges(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * @returns {boolean}
     */
    get unknown() {
        const ret = wasm.timeframe_wasm_unknown(this.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * @param {Timeframe} other
     * @returns {boolean}
     */
    eq(other) {
        _assertClass(other, Timeframe);
        const ret = wasm.timeframe_eq(this.__wbg_ptr, other.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * @returns {number}
     */
    toDurationS() {
        const ret = wasm.timeframe_toDurationS(this.__wbg_ptr);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        return ret[0];
    }
    /**
     * @param {number} duration
     * @returns {Timeframe}
     */
    static fromDurationS(duration) {
        const ret = wasm.timeframe_fromDurationS(duration);
        return Timeframe.__wrap(ret);
    }
}

const TradeFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_trade_free(ptr >>> 0, 1));

export class Trade {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(Trade.prototype);
        obj.__wbg_ptr = ptr;
        TradeFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        TradeFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_trade_free(ptr, 0);
    }
    /**
     * @returns {number}
     */
    get size() {
        const ret = wasm.trade_wasm_size(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {TradeEvent | undefined}
     */
    get entry() {
        const ret = wasm.trade_wasm_entry(this.__wbg_ptr);
        return ret === 0 ? undefined : TradeEvent.__wrap(ret);
    }
    /**
     * @returns {TradeEvent | undefined}
     */
    get exit() {
        const ret = wasm.trade_wasm_exit(this.__wbg_ptr);
        return ret === 0 ? undefined : TradeEvent.__wrap(ret);
    }
    /**
     * @returns {number}
     */
    get pnl() {
        const ret = wasm.trade_wasm_pnl(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {TradeDirection}
     */
    get direction() {
        const ret = wasm.trade_wasm_direction(this.__wbg_ptr);
        return TradeDirection.__wrap(ret);
    }
    /**
     * @returns {boolean}
     */
    get isActive() {
        const ret = wasm.trade_wasm_is_active(this.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * @returns {boolean}
     */
    get isClosed() {
        const ret = wasm.trade_wasm_is_closed(this.__wbg_ptr);
        return ret !== 0;
    }
}

const TradeDirectionFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_tradedirection_free(ptr >>> 0, 1));

export class TradeDirection {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(TradeDirection.prototype);
        obj.__wbg_ptr = ptr;
        TradeDirectionFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        TradeDirectionFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_tradedirection_free(ptr, 0);
    }
    /**
     * @returns {TradeDirection}
     */
    Long() {
        const ret = wasm.tradedirection_Long(this.__wbg_ptr);
        return TradeDirection.__wrap(ret);
    }
    /**
     * @returns {TradeDirection}
     */
    Short() {
        const ret = wasm.tradedirection_Short(this.__wbg_ptr);
        return TradeDirection.__wrap(ret);
    }
    /**
     * @returns {number}
     */
    toNumber() {
        const ret = wasm.tradedirection_toNumber(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {number} value
     * @returns {TradeDirection}
     */
    static fromNumber(value) {
        const ret = wasm.tradedirection_fromNumber(value);
        return TradeDirection.__wrap(ret);
    }
}

const TradeEventFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_tradeevent_free(ptr >>> 0, 1));

export class TradeEvent {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(TradeEvent.prototype);
        obj.__wbg_ptr = ptr;
        TradeEventFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        TradeEventFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_tradeevent_free(ptr, 0);
    }
    /**
     * @returns {string | undefined}
     */
    get id() {
        const ret = wasm.tradeevent_wasm_id(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * @returns {number}
     */
    get orderBarIndex() {
        const ret = wasm.tradeevent_wasm_order_bar_index(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * @returns {number}
     */
    get fillBarIndex() {
        const ret = wasm.tradeevent_wasm_fill_bar_index(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * @returns {number}
     */
    get price() {
        const ret = wasm.tradeevent_wasm_price(this.__wbg_ptr);
        return ret;
    }
    /**
     * @returns {string | undefined}
     */
    get comment() {
        const ret = wasm.tradeevent_wasm_comment(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
}

async function __wbg_load(module, imports) {
    if (typeof Response === 'function' && module instanceof Response) {
        if (typeof WebAssembly.instantiateStreaming === 'function') {
            try {
                return await WebAssembly.instantiateStreaming(module, imports);

            } catch (e) {
                if (module.headers.get('Content-Type') != 'application/wasm') {
                    console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);

                } else {
                    throw e;
                }
            }
        }

        const bytes = await module.arrayBuffer();
        return await WebAssembly.instantiate(bytes, imports);

    } else {
        const instance = await WebAssembly.instantiate(module, imports);

        if (instance instanceof WebAssembly.Instance) {
            return { instance, module };

        } else {
            return instance;
        }
    }
}

function __wbg_get_imports() {
    const imports = {};
    imports.wbg = {};
    imports.wbg.__wbg_forEach_e1cf6f7c8ecb7dae = function(arg0, arg1, arg2) {
        try {
            var state0 = {a: arg1, b: arg2};
            var cb0 = (arg0, arg1) => {
                const a = state0.a;
                state0.a = 0;
                try {
                    return __wbg_adapter_264(a, state0.b, arg0, arg1);
                } finally {
                    state0.a = a;
                }
            };
            arg0.forEach(cb0);
        } finally {
            state0.a = state0.b = 0;
        }
    };
    imports.wbg.__wbg_from_2a5d3e218e67aa85 = function(arg0) {
        const ret = Array.from(arg0);
        return ret;
    };
    imports.wbg.__wbg_getTime_46267b1c24877e30 = function(arg0) {
        const ret = arg0.getTime();
        return ret;
    };
    imports.wbg.__wbg_get_67b2ba62fc30de12 = function() { return handleError(function (arg0, arg1) {
        const ret = Reflect.get(arg0, arg1);
        return ret;
    }, arguments) };
    imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
        const ret = arg0[arg1 >>> 0];
        return ret;
    };
    imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
        const ret = arg0.length;
        return ret;
    };
    imports.wbg.__wbg_new0_f788a2397c7ca929 = function() {
        const ret = new Date();
        return ret;
    };
    imports.wbg.__wbg_new_31a97dac4f10fab7 = function(arg0) {
        const ret = new Date(arg0);
        return ret;
    };
    imports.wbg.__wbg_new_405e22f390576ce2 = function() {
        const ret = new Object();
        return ret;
    };
    imports.wbg.__wbg_new_78feb108b6472713 = function() {
        const ret = new Array();
        return ret;
    };
    imports.wbg.__wbg_new_c68d7209be747379 = function(arg0, arg1) {
        const ret = new Error(getStringFromWasm0(arg0, arg1));
        return ret;
    };
    imports.wbg.__wbg_ohlcvbar_new = function(arg0) {
        const ret = OhlcvBar.__wrap(arg0);
        return ret;
    };
    imports.wbg.__wbg_ohlcvbar_unwrap = function(arg0) {
        const ret = OhlcvBar.__unwrap(arg0);
        return ret;
    };
    imports.wbg.__wbg_push_737cfc8c1432c2c6 = function(arg0, arg1) {
        const ret = arg0.push(arg1);
        return ret;
    };
    imports.wbg.__wbg_set_bb8cecf6a62b9f46 = function() { return handleError(function (arg0, arg1, arg2) {
        const ret = Reflect.set(arg0, arg1, arg2);
        return ret;
    }, arguments) };
    imports.wbg.__wbg_signal_unwrap = function(arg0) {
        const ret = Signal.__unwrap(arg0);
        return ret;
    };
    imports.wbg.__wbg_table_3fe1372fc884b498 = function(arg0) {
        console.table(arg0);
    };
    imports.wbg.__wbg_trade_new = function(arg0) {
        const ret = Trade.__wrap(arg0);
        return ret;
    };
    imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
        const ret = debugString(arg1);
        const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len1 = WASM_VECTOR_LEN;
        getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
        getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
    };
    imports.wbg.__wbindgen_init_externref_table = function() {
        const table = wasm.__wbindgen_export_2;
        const offset = table.grow(4);
        table.set(0, undefined);
        table.set(offset + 0, undefined);
        table.set(offset + 1, null);
        table.set(offset + 2, true);
        table.set(offset + 3, false);
        ;
    };
    imports.wbg.__wbindgen_is_null = function(arg0) {
        const ret = arg0 === null;
        return ret;
    };
    imports.wbg.__wbindgen_is_undefined = function(arg0) {
        const ret = arg0 === undefined;
        return ret;
    };
    imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
        const obj = arg1;
        const ret = typeof(obj) === 'number' ? obj : undefined;
        getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
        getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
    };
    imports.wbg.__wbindgen_number_new = function(arg0) {
        const ret = arg0;
        return ret;
    };
    imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
        const obj = arg1;
        const ret = typeof(obj) === 'string' ? obj : undefined;
        var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len1 = WASM_VECTOR_LEN;
        getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
        getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
    };
    imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
        const ret = getStringFromWasm0(arg0, arg1);
        return ret;
    };
    imports.wbg.__wbindgen_throw = function(arg0, arg1) {
        throw new Error(getStringFromWasm0(arg0, arg1));
    };

    return imports;
}

function __wbg_init_memory(imports, memory) {

}

function __wbg_finalize_init(instance, module) {
    wasm = instance.exports;
    __wbg_init.__wbindgen_wasm_module = module;
    cachedDataViewMemory0 = null;
    cachedFloat64ArrayMemory0 = null;
    cachedUint8ArrayMemory0 = null;


    wasm.__wbindgen_start();
    return wasm;
}

function initSync(module) {
    if (wasm !== undefined) return wasm;


    if (typeof module !== 'undefined') {
        if (Object.getPrototypeOf(module) === Object.prototype) {
            ({module} = module)
        } else {
            console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
        }
    }

    const imports = __wbg_get_imports();

    __wbg_init_memory(imports);

    if (!(module instanceof WebAssembly.Module)) {
        module = new WebAssembly.Module(module);
    }

    const instance = new WebAssembly.Instance(module, imports);

    return __wbg_finalize_init(instance, module);
}

async function __wbg_init(module_or_path) {
    if (wasm !== undefined) return wasm;


    if (typeof module_or_path !== 'undefined') {
        if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
            ({module_or_path} = module_or_path)
        } else {
            console.warn('using deprecated parameters for the initialization function; pass a single object instead')
        }
    }

    if (typeof module_or_path === 'undefined') {
        module_or_path = new URL('index_bg.wasm', import.meta.url);
    }
    const imports = __wbg_get_imports();

    if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
        module_or_path = fetch(module_or_path);
    }

    __wbg_init_memory(imports);

    const { instance, module } = await __wbg_load(await module_or_path, imports);

    return __wbg_finalize_init(instance, module);
}

export { initSync };
export default __wbg_init;
