/*
EMS - REST API

This section will provide necessary information about the `CoinAPI EMS REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a>        Implemented Standards:    * [HTTP1.0](https://datatracker.ietf.org/doc/html/rfc1945)   * [HTTP1.1](https://datatracker.ietf.org/doc/html/rfc2616)   * [HTTP2.0](https://datatracker.ietf.org/doc/html/rfc7540)     ### Endpoints  <table>   <thead>     <tr>       <th>Deployment method</th>       <th>Environment</th>       <th>Url</th>     </tr>   </thead>   <tbody>     <tr>       <td>Managed Cloud</td>       <td>Production</td>       <td>Use <a href=\"#ems-docs-sh\">Managed Cloud REST API /v1/locations</a> to get specific endpoints to each server site where your deployments span</td>     </tr>     <tr>       <td>Self Hosted</td>       <td>Production</td>       <td>IP Address of the <code>ems-gateway</code> container/excecutable in the closest server site to the caller location</td>     </tr>   </tbody> </table>  ### Authentication If the software is deployed as `Self-Hosted` then API do not require authentication as inside your infrastructure, your company is responsible for the security and access controls.  If the software is deployed in our `Managed Cloud`, there are 2 methods for authenticating with us, you only need to use one:   1. Custom authorization header named `X-CoinAPI-Key` with the API Key  2. Query string parameter named `apikey` with the API Key  3. <a href=\"#certificate\">TLS Client Certificate</a> from the `Managed Cloud REST API` (/v1/certificate/pem endpoint) while establishing a TLS session with us.  #### Custom authorization header You can authorize by providing additional custom header named `X-CoinAPI-Key` and API key as its value. Assuming that your API key is `73034021-THIS-IS-SAMPLE-KEY`, then the authorization header you should send to us will look like: `X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY` <aside class=\"success\">This method is recommended by us and you should use it in production environments.</aside> #### Query string authorization parameter You can authorize by providing an additional parameter named `apikey` with a value equal to your API key in the query string of your HTTP request. Assuming that your API key is `73034021-THIS-IS-SAMPLE-KEY` and that you want to request all balances, then your query string should look like this: `GET /v1/balances?apikey=73034021-THIS-IS-SAMPLE-KEY` <aside class=\"notice\">Query string method may be more practical for development activities.</aside> 

API version: v1
Contact: support@coinapi.io
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package openapi

import (
	"encoding/json"
)

// checks if the PositionDataInner type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &PositionDataInner{}

// PositionDataInner The Position object.
type PositionDataInner struct {
	// Exchange symbol.
	SymbolIdExchange *string `json:"symbol_id_exchange,omitempty"`
	// CoinAPI symbol.
	SymbolIdCoinapi *string `json:"symbol_id_coinapi,omitempty"`
	// Calculated average price of all fills on this position.
	AvgEntryPrice *float32 `json:"avg_entry_price,omitempty"`
	// The current position quantity.
	Quantity *float32 `json:"quantity,omitempty"`
	Side *OrdSide `json:"side,omitempty"`
	// Unrealised profit or loss (PNL) of this position.
	UnrealizedPnl *float32 `json:"unrealized_pnl,omitempty"`
	// Leverage for this position reported by the exchange.
	Leverage *float32 `json:"leverage,omitempty"`
	// Is cross margin mode enable for this position?
	CrossMargin *bool `json:"cross_margin,omitempty"`
	// Liquidation price. If mark price will reach this value, the position will be liquidated.
	LiquidationPrice *float32 `json:"liquidation_price,omitempty"`
	RawData map[string]interface{} `json:"raw_data,omitempty"`
}

// NewPositionDataInner instantiates a new PositionDataInner object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewPositionDataInner() *PositionDataInner {
	this := PositionDataInner{}
	return &this
}

// NewPositionDataInnerWithDefaults instantiates a new PositionDataInner object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewPositionDataInnerWithDefaults() *PositionDataInner {
	this := PositionDataInner{}
	return &this
}

// GetSymbolIdExchange returns the SymbolIdExchange field value if set, zero value otherwise.
func (o *PositionDataInner) GetSymbolIdExchange() string {
	if o == nil || IsNil(o.SymbolIdExchange) {
		var ret string
		return ret
	}
	return *o.SymbolIdExchange
}

// GetSymbolIdExchangeOk returns a tuple with the SymbolIdExchange field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetSymbolIdExchangeOk() (*string, bool) {
	if o == nil || IsNil(o.SymbolIdExchange) {
		return nil, false
	}
	return o.SymbolIdExchange, true
}

// HasSymbolIdExchange returns a boolean if a field has been set.
func (o *PositionDataInner) HasSymbolIdExchange() bool {
	if o != nil && !IsNil(o.SymbolIdExchange) {
		return true
	}

	return false
}

// SetSymbolIdExchange gets a reference to the given string and assigns it to the SymbolIdExchange field.
func (o *PositionDataInner) SetSymbolIdExchange(v string) {
	o.SymbolIdExchange = &v
}

// GetSymbolIdCoinapi returns the SymbolIdCoinapi field value if set, zero value otherwise.
func (o *PositionDataInner) GetSymbolIdCoinapi() string {
	if o == nil || IsNil(o.SymbolIdCoinapi) {
		var ret string
		return ret
	}
	return *o.SymbolIdCoinapi
}

// GetSymbolIdCoinapiOk returns a tuple with the SymbolIdCoinapi field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetSymbolIdCoinapiOk() (*string, bool) {
	if o == nil || IsNil(o.SymbolIdCoinapi) {
		return nil, false
	}
	return o.SymbolIdCoinapi, true
}

// HasSymbolIdCoinapi returns a boolean if a field has been set.
func (o *PositionDataInner) HasSymbolIdCoinapi() bool {
	if o != nil && !IsNil(o.SymbolIdCoinapi) {
		return true
	}

	return false
}

// SetSymbolIdCoinapi gets a reference to the given string and assigns it to the SymbolIdCoinapi field.
func (o *PositionDataInner) SetSymbolIdCoinapi(v string) {
	o.SymbolIdCoinapi = &v
}

// GetAvgEntryPrice returns the AvgEntryPrice field value if set, zero value otherwise.
func (o *PositionDataInner) GetAvgEntryPrice() float32 {
	if o == nil || IsNil(o.AvgEntryPrice) {
		var ret float32
		return ret
	}
	return *o.AvgEntryPrice
}

// GetAvgEntryPriceOk returns a tuple with the AvgEntryPrice field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetAvgEntryPriceOk() (*float32, bool) {
	if o == nil || IsNil(o.AvgEntryPrice) {
		return nil, false
	}
	return o.AvgEntryPrice, true
}

// HasAvgEntryPrice returns a boolean if a field has been set.
func (o *PositionDataInner) HasAvgEntryPrice() bool {
	if o != nil && !IsNil(o.AvgEntryPrice) {
		return true
	}

	return false
}

// SetAvgEntryPrice gets a reference to the given float32 and assigns it to the AvgEntryPrice field.
func (o *PositionDataInner) SetAvgEntryPrice(v float32) {
	o.AvgEntryPrice = &v
}

// GetQuantity returns the Quantity field value if set, zero value otherwise.
func (o *PositionDataInner) GetQuantity() float32 {
	if o == nil || IsNil(o.Quantity) {
		var ret float32
		return ret
	}
	return *o.Quantity
}

// GetQuantityOk returns a tuple with the Quantity field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetQuantityOk() (*float32, bool) {
	if o == nil || IsNil(o.Quantity) {
		return nil, false
	}
	return o.Quantity, true
}

// HasQuantity returns a boolean if a field has been set.
func (o *PositionDataInner) HasQuantity() bool {
	if o != nil && !IsNil(o.Quantity) {
		return true
	}

	return false
}

// SetQuantity gets a reference to the given float32 and assigns it to the Quantity field.
func (o *PositionDataInner) SetQuantity(v float32) {
	o.Quantity = &v
}

// GetSide returns the Side field value if set, zero value otherwise.
func (o *PositionDataInner) GetSide() OrdSide {
	if o == nil || IsNil(o.Side) {
		var ret OrdSide
		return ret
	}
	return *o.Side
}

// GetSideOk returns a tuple with the Side field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetSideOk() (*OrdSide, bool) {
	if o == nil || IsNil(o.Side) {
		return nil, false
	}
	return o.Side, true
}

// HasSide returns a boolean if a field has been set.
func (o *PositionDataInner) HasSide() bool {
	if o != nil && !IsNil(o.Side) {
		return true
	}

	return false
}

// SetSide gets a reference to the given OrdSide and assigns it to the Side field.
func (o *PositionDataInner) SetSide(v OrdSide) {
	o.Side = &v
}

// GetUnrealizedPnl returns the UnrealizedPnl field value if set, zero value otherwise.
func (o *PositionDataInner) GetUnrealizedPnl() float32 {
	if o == nil || IsNil(o.UnrealizedPnl) {
		var ret float32
		return ret
	}
	return *o.UnrealizedPnl
}

// GetUnrealizedPnlOk returns a tuple with the UnrealizedPnl field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetUnrealizedPnlOk() (*float32, bool) {
	if o == nil || IsNil(o.UnrealizedPnl) {
		return nil, false
	}
	return o.UnrealizedPnl, true
}

// HasUnrealizedPnl returns a boolean if a field has been set.
func (o *PositionDataInner) HasUnrealizedPnl() bool {
	if o != nil && !IsNil(o.UnrealizedPnl) {
		return true
	}

	return false
}

// SetUnrealizedPnl gets a reference to the given float32 and assigns it to the UnrealizedPnl field.
func (o *PositionDataInner) SetUnrealizedPnl(v float32) {
	o.UnrealizedPnl = &v
}

// GetLeverage returns the Leverage field value if set, zero value otherwise.
func (o *PositionDataInner) GetLeverage() float32 {
	if o == nil || IsNil(o.Leverage) {
		var ret float32
		return ret
	}
	return *o.Leverage
}

// GetLeverageOk returns a tuple with the Leverage field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetLeverageOk() (*float32, bool) {
	if o == nil || IsNil(o.Leverage) {
		return nil, false
	}
	return o.Leverage, true
}

// HasLeverage returns a boolean if a field has been set.
func (o *PositionDataInner) HasLeverage() bool {
	if o != nil && !IsNil(o.Leverage) {
		return true
	}

	return false
}

// SetLeverage gets a reference to the given float32 and assigns it to the Leverage field.
func (o *PositionDataInner) SetLeverage(v float32) {
	o.Leverage = &v
}

// GetCrossMargin returns the CrossMargin field value if set, zero value otherwise.
func (o *PositionDataInner) GetCrossMargin() bool {
	if o == nil || IsNil(o.CrossMargin) {
		var ret bool
		return ret
	}
	return *o.CrossMargin
}

// GetCrossMarginOk returns a tuple with the CrossMargin field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetCrossMarginOk() (*bool, bool) {
	if o == nil || IsNil(o.CrossMargin) {
		return nil, false
	}
	return o.CrossMargin, true
}

// HasCrossMargin returns a boolean if a field has been set.
func (o *PositionDataInner) HasCrossMargin() bool {
	if o != nil && !IsNil(o.CrossMargin) {
		return true
	}

	return false
}

// SetCrossMargin gets a reference to the given bool and assigns it to the CrossMargin field.
func (o *PositionDataInner) SetCrossMargin(v bool) {
	o.CrossMargin = &v
}

// GetLiquidationPrice returns the LiquidationPrice field value if set, zero value otherwise.
func (o *PositionDataInner) GetLiquidationPrice() float32 {
	if o == nil || IsNil(o.LiquidationPrice) {
		var ret float32
		return ret
	}
	return *o.LiquidationPrice
}

// GetLiquidationPriceOk returns a tuple with the LiquidationPrice field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetLiquidationPriceOk() (*float32, bool) {
	if o == nil || IsNil(o.LiquidationPrice) {
		return nil, false
	}
	return o.LiquidationPrice, true
}

// HasLiquidationPrice returns a boolean if a field has been set.
func (o *PositionDataInner) HasLiquidationPrice() bool {
	if o != nil && !IsNil(o.LiquidationPrice) {
		return true
	}

	return false
}

// SetLiquidationPrice gets a reference to the given float32 and assigns it to the LiquidationPrice field.
func (o *PositionDataInner) SetLiquidationPrice(v float32) {
	o.LiquidationPrice = &v
}

// GetRawData returns the RawData field value if set, zero value otherwise.
func (o *PositionDataInner) GetRawData() map[string]interface{} {
	if o == nil || IsNil(o.RawData) {
		var ret map[string]interface{}
		return ret
	}
	return o.RawData
}

// GetRawDataOk returns a tuple with the RawData field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PositionDataInner) GetRawDataOk() (map[string]interface{}, bool) {
	if o == nil || IsNil(o.RawData) {
		return map[string]interface{}{}, false
	}
	return o.RawData, true
}

// HasRawData returns a boolean if a field has been set.
func (o *PositionDataInner) HasRawData() bool {
	if o != nil && !IsNil(o.RawData) {
		return true
	}

	return false
}

// SetRawData gets a reference to the given map[string]interface{} and assigns it to the RawData field.
func (o *PositionDataInner) SetRawData(v map[string]interface{}) {
	o.RawData = v
}

func (o PositionDataInner) MarshalJSON() ([]byte, error) {
	toSerialize,err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o PositionDataInner) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.SymbolIdExchange) {
		toSerialize["symbol_id_exchange"] = o.SymbolIdExchange
	}
	if !IsNil(o.SymbolIdCoinapi) {
		toSerialize["symbol_id_coinapi"] = o.SymbolIdCoinapi
	}
	if !IsNil(o.AvgEntryPrice) {
		toSerialize["avg_entry_price"] = o.AvgEntryPrice
	}
	if !IsNil(o.Quantity) {
		toSerialize["quantity"] = o.Quantity
	}
	if !IsNil(o.Side) {
		toSerialize["side"] = o.Side
	}
	if !IsNil(o.UnrealizedPnl) {
		toSerialize["unrealized_pnl"] = o.UnrealizedPnl
	}
	if !IsNil(o.Leverage) {
		toSerialize["leverage"] = o.Leverage
	}
	if !IsNil(o.CrossMargin) {
		toSerialize["cross_margin"] = o.CrossMargin
	}
	if !IsNil(o.LiquidationPrice) {
		toSerialize["liquidation_price"] = o.LiquidationPrice
	}
	if !IsNil(o.RawData) {
		toSerialize["raw_data"] = o.RawData
	}
	return toSerialize, nil
}

type NullablePositionDataInner struct {
	value *PositionDataInner
	isSet bool
}

func (v NullablePositionDataInner) Get() *PositionDataInner {
	return v.value
}

func (v *NullablePositionDataInner) Set(val *PositionDataInner) {
	v.value = val
	v.isSet = true
}

func (v NullablePositionDataInner) IsSet() bool {
	return v.isSet
}

func (v *NullablePositionDataInner) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullablePositionDataInner(val *PositionDataInner) *NullablePositionDataInner {
	return &NullablePositionDataInner{value: val, isSet: true}
}

func (v NullablePositionDataInner) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullablePositionDataInner) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}


