# coding: utf-8

"""
    OANDA v20 REST API

    The full OANDA v20 REST API Specification. This specification defines how to interact with v20 Accounts, Trades, Orders, Pricing and more. To authenticate use the string 'Bearer ' followed by the token which can be obtained at https://www.oanda.com/demo-account/tpa/personal_token  # noqa: E501

    OpenAPI spec version: 3.0.23
    Contact: api@oanda.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


import pprint
import re  # noqa: F401

import six

from oanda.models.position_side import PositionSide  # noqa: F401,E501


class Position(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    """

    """
    Attributes:
      swagger_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    """
    swagger_types = {
        'instrument': 'str',
        'pl': 'str',
        'unrealized_pl': 'str',
        'margin_used': 'str',
        'resettable_pl': 'str',
        'financing': 'str',
        'commission': 'str',
        'guaranteed_execution_fees': 'str',
        'long': 'PositionSide',
        'short': 'PositionSide'
    }

    attribute_map = {
        'instrument': 'instrument',
        'pl': 'pl',
        'unrealized_pl': 'unrealizedPL',
        'margin_used': 'marginUsed',
        'resettable_pl': 'resettablePL',
        'financing': 'financing',
        'commission': 'commission',
        'guaranteed_execution_fees': 'guaranteedExecutionFees',
        'long': 'long',
        'short': 'short'
    }

    def __init__(self, instrument=None, pl=None, unrealized_pl=None, margin_used=None, resettable_pl=None, financing=None, commission=None, guaranteed_execution_fees=None, long=None, short=None):  # noqa: E501
        """Position - a model defined in Swagger"""  # noqa: E501

        self._instrument = None
        self._pl = None
        self._unrealized_pl = None
        self._margin_used = None
        self._resettable_pl = None
        self._financing = None
        self._commission = None
        self._guaranteed_execution_fees = None
        self._long = None
        self._short = None
        self.discriminator = None

        if instrument is not None:
            self.instrument = instrument
        if pl is not None:
            self.pl = pl
        if unrealized_pl is not None:
            self.unrealized_pl = unrealized_pl
        if margin_used is not None:
            self.margin_used = margin_used
        if resettable_pl is not None:
            self.resettable_pl = resettable_pl
        if financing is not None:
            self.financing = financing
        if commission is not None:
            self.commission = commission
        if guaranteed_execution_fees is not None:
            self.guaranteed_execution_fees = guaranteed_execution_fees
        if long is not None:
            self.long = long
        if short is not None:
            self.short = short

    @property
    def instrument(self):
        """Gets the instrument of this Position.  # noqa: E501

        The Position's Instrument.  # noqa: E501

        :return: The instrument of this Position.  # noqa: E501
        :rtype: str
        """
        return self._instrument

    @instrument.setter
    def instrument(self, instrument):
        """Sets the instrument of this Position.

        The Position's Instrument.  # noqa: E501

        :param instrument: The instrument of this Position.  # noqa: E501
        :type: str
        """

        self._instrument = instrument

    @property
    def pl(self):
        """Gets the pl of this Position.  # noqa: E501

        Profit/loss realized by the Position over the lifetime of the Account.  # noqa: E501

        :return: The pl of this Position.  # noqa: E501
        :rtype: str
        """
        return self._pl

    @pl.setter
    def pl(self, pl):
        """Sets the pl of this Position.

        Profit/loss realized by the Position over the lifetime of the Account.  # noqa: E501

        :param pl: The pl of this Position.  # noqa: E501
        :type: str
        """

        self._pl = pl

    @property
    def unrealized_pl(self):
        """Gets the unrealized_pl of this Position.  # noqa: E501

        The unrealized profit/loss of all open Trades that contribute to this Position.  # noqa: E501

        :return: The unrealized_pl of this Position.  # noqa: E501
        :rtype: str
        """
        return self._unrealized_pl

    @unrealized_pl.setter
    def unrealized_pl(self, unrealized_pl):
        """Sets the unrealized_pl of this Position.

        The unrealized profit/loss of all open Trades that contribute to this Position.  # noqa: E501

        :param unrealized_pl: The unrealized_pl of this Position.  # noqa: E501
        :type: str
        """

        self._unrealized_pl = unrealized_pl

    @property
    def margin_used(self):
        """Gets the margin_used of this Position.  # noqa: E501

        Margin currently used by the Position.  # noqa: E501

        :return: The margin_used of this Position.  # noqa: E501
        :rtype: str
        """
        return self._margin_used

    @margin_used.setter
    def margin_used(self, margin_used):
        """Sets the margin_used of this Position.

        Margin currently used by the Position.  # noqa: E501

        :param margin_used: The margin_used of this Position.  # noqa: E501
        :type: str
        """

        self._margin_used = margin_used

    @property
    def resettable_pl(self):
        """Gets the resettable_pl of this Position.  # noqa: E501

        Profit/loss realized by the Position since the Account's resettablePL was last reset by the client.  # noqa: E501

        :return: The resettable_pl of this Position.  # noqa: E501
        :rtype: str
        """
        return self._resettable_pl

    @resettable_pl.setter
    def resettable_pl(self, resettable_pl):
        """Sets the resettable_pl of this Position.

        Profit/loss realized by the Position since the Account's resettablePL was last reset by the client.  # noqa: E501

        :param resettable_pl: The resettable_pl of this Position.  # noqa: E501
        :type: str
        """

        self._resettable_pl = resettable_pl

    @property
    def financing(self):
        """Gets the financing of this Position.  # noqa: E501

        The total amount of financing paid/collected for this instrument over the lifetime of the Account.  # noqa: E501

        :return: The financing of this Position.  # noqa: E501
        :rtype: str
        """
        return self._financing

    @financing.setter
    def financing(self, financing):
        """Sets the financing of this Position.

        The total amount of financing paid/collected for this instrument over the lifetime of the Account.  # noqa: E501

        :param financing: The financing of this Position.  # noqa: E501
        :type: str
        """

        self._financing = financing

    @property
    def commission(self):
        """Gets the commission of this Position.  # noqa: E501

        The total amount of commission paid for this instrument over the lifetime of the Account.  # noqa: E501

        :return: The commission of this Position.  # noqa: E501
        :rtype: str
        """
        return self._commission

    @commission.setter
    def commission(self, commission):
        """Sets the commission of this Position.

        The total amount of commission paid for this instrument over the lifetime of the Account.  # noqa: E501

        :param commission: The commission of this Position.  # noqa: E501
        :type: str
        """

        self._commission = commission

    @property
    def guaranteed_execution_fees(self):
        """Gets the guaranteed_execution_fees of this Position.  # noqa: E501

        The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop Loss Orders for this instrument.  # noqa: E501

        :return: The guaranteed_execution_fees of this Position.  # noqa: E501
        :rtype: str
        """
        return self._guaranteed_execution_fees

    @guaranteed_execution_fees.setter
    def guaranteed_execution_fees(self, guaranteed_execution_fees):
        """Sets the guaranteed_execution_fees of this Position.

        The total amount of fees charged over the lifetime of the Account for the execution of guaranteed Stop Loss Orders for this instrument.  # noqa: E501

        :param guaranteed_execution_fees: The guaranteed_execution_fees of this Position.  # noqa: E501
        :type: str
        """

        self._guaranteed_execution_fees = guaranteed_execution_fees

    @property
    def long(self):
        """Gets the long of this Position.  # noqa: E501


        :return: The long of this Position.  # noqa: E501
        :rtype: PositionSide
        """
        return self._long

    @long.setter
    def long(self, long):
        """Sets the long of this Position.


        :param long: The long of this Position.  # noqa: E501
        :type: PositionSide
        """

        self._long = long

    @property
    def short(self):
        """Gets the short of this Position.  # noqa: E501


        :return: The short of this Position.  # noqa: E501
        :rtype: PositionSide
        """
        return self._short

    @short.setter
    def short(self, short):
        """Sets the short of this Position.


        :param short: The short of this Position.  # noqa: E501
        :type: PositionSide
        """

        self._short = short

    def to_dict(self):
        """Returns the model properties as a dict"""
        result = {}

        for attr, _ in six.iteritems(self.swagger_types):
            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
                    value
                ))
            elif hasattr(value, "to_dict"):
                result[attr] = value.to_dict()
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1].to_dict())
                    if hasattr(item[1], "to_dict") else item,
                    value.items()
                ))
            else:
                result[attr] = value

        return result

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self.to_dict())

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, Position):
            return False

        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        return not self == other
