All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fluxtion.server.lib.pnl.MidPrice Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: © 2024 Gregory Higgins 
 * SPDX-License-Identifier: AGPL-3.0-only
 */

package com.fluxtion.server.lib.pnl;

import com.fluxtion.server.lib.pnl.refdata.Instrument;
import com.fluxtion.server.lib.pnl.refdata.Symbol;
import lombok.Value;

@Value
public class MidPrice {
    Symbol symbol;
    double rate;

    public Instrument dealtInstrument() {
        return getSymbol().dealtInstrument();
    }

    public Instrument contraInstrument() {
        return getSymbol().contraInstrument();
    }

    public double getRateForInstrument(Instrument ccy) {
        if (symbol.dealtInstrument().equals(ccy)) {
            return 1 / rate;
        } else if (symbol.contraInstrument().equals(ccy)) {
            return rate;
        }
        return Double.NaN;
    }

    public Instrument getOppositeInstrument(Instrument searchCcy) {
        if (symbol.dealtInstrument().equals(searchCcy)) {
            return symbol.contraInstrument();
        } else if (symbol.contraInstrument().equals(searchCcy)) {
            return symbol.dealtInstrument();
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy