//
// Generated by SwagGen
// https://github.com/yonaskolb/SwagGen
//

import Foundation

public struct IBMarketData: APIModel {

    public let ask: Double?

    public let askSize: Double?

    public let bid: Double?

    public let bidSize: Double?

    /** IBKR Contract ID */
    public let conid: Double?

    /** Exchange */
    public let exchange: String?

    public let last: Double?

    public let lastSize: Double?

    public let minTick: Double?

    public init(ask: Double? = nil, askSize: Double? = nil, bid: Double? = nil, bidSize: Double? = nil, conid: Double? = nil, exchange: String? = nil, last: Double? = nil, lastSize: Double? = nil, minTick: Double? = nil) {
        self.ask = ask
        self.askSize = askSize
        self.bid = bid
        self.bidSize = bidSize
        self.conid = conid
        self.exchange = exchange
        self.last = last
        self.lastSize = lastSize
        self.minTick = minTick
    }

    public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: StringCodingKey.self)

        ask = try container.decodeIfPresent("Ask")
        askSize = try container.decodeIfPresent("AskSize")
        bid = try container.decodeIfPresent("Bid")
        bidSize = try container.decodeIfPresent("BidSize")
        conid = try container.decodeIfPresent("Conid")
        exchange = try container.decodeIfPresent("Exchange")
        last = try container.decodeIfPresent("Last")
        lastSize = try container.decodeIfPresent("LastSize")
        minTick = try container.decodeIfPresent("minTick")
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: StringCodingKey.self)

        try container.encodeIfPresent(ask, forKey: "Ask")
        try container.encodeIfPresent(askSize, forKey: "AskSize")
        try container.encodeIfPresent(bid, forKey: "Bid")
        try container.encodeIfPresent(bidSize, forKey: "BidSize")
        try container.encodeIfPresent(conid, forKey: "Conid")
        try container.encodeIfPresent(exchange, forKey: "Exchange")
        try container.encodeIfPresent(last, forKey: "Last")
        try container.encodeIfPresent(lastSize, forKey: "LastSize")
        try container.encodeIfPresent(minTick, forKey: "minTick")
    }

}
