private static QuoteCurrency CreateQuoteCurrencyFromGetLatestCryptocurrencyQuotesResponseJsonContent(
            string jsonText)
        {
            var jsonReader = new Utf8JsonReader(Encoding.UTF8.GetBytes(jsonText), isFinalBlock: true, state: default);

            CurrencyCode         currencyCode = null;
            CurrencyExchangeRate crossRate    = null;

            var currentPropertyName = string.Empty;

            while (jsonReader.Read())
            {
                switch (jsonReader.TokenType)
                {
                case JsonTokenType.PropertyName:
                    var previousPropertyName = currentPropertyName;
                    currentPropertyName = jsonReader.GetString();
                    TryParseQuoteCurrencyCode(previousPropertyName, currentPropertyName, ref currencyCode);
                    continue;

                case JsonTokenType.Number:
                    TryParseQuoteCurrencyCrossRate(jsonReader.GetDecimal(), currentPropertyName, ref crossRate);
                    break;

                default:
                    continue;
                }
            }

            return(QuoteCurrency.Of(currencyCode, crossRate));
        }
Пример #2
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)

                hashCode = hashCode * 59 + QuoteCurrency.GetHashCode();

                hashCode = hashCode * 59 + Kind.GetHashCode();
                if (TickSize != null)
                {
                    hashCode = hashCode * 59 + TickSize.GetHashCode();
                }
                if (ContractSize != null)
                {
                    hashCode = hashCode * 59 + ContractSize.GetHashCode();
                }
                if (IsActive != null)
                {
                    hashCode = hashCode * 59 + IsActive.GetHashCode();
                }

                hashCode = hashCode * 59 + OptionType.GetHashCode();
                if (MinTradeAmount != null)
                {
                    hashCode = hashCode * 59 + MinTradeAmount.GetHashCode();
                }
                if (InstrumentName != null)
                {
                    hashCode = hashCode * 59 + InstrumentName.GetHashCode();
                }

                hashCode = hashCode * 59 + SettlementPeriod.GetHashCode();
                if (Strike != null)
                {
                    hashCode = hashCode * 59 + Strike.GetHashCode();
                }

                hashCode = hashCode * 59 + BaseCurrency.GetHashCode();
                if (CreationTimestamp != null)
                {
                    hashCode = hashCode * 59 + CreationTimestamp.GetHashCode();
                }
                if (ExpirationTimestamp != null)
                {
                    hashCode = hashCode * 59 + ExpirationTimestamp.GetHashCode();
                }
                return(hashCode);
            }
        }
        /// <summary>
        /// Creates a Quote Currency
        /// </summary>
        /// <param name="givenQuoteCurrency">The given quote currency</param>
        private void CreateQuoteCurrency(string givenQuoteCurrency)
        {
            var quoteCurrencyInfo = this.ecbEnvelope.CubeRootEl[0].CubeItems.Find(c => c.Currency == givenQuoteCurrency);

            if (!this.CheckIfEuro(givenQuoteCurrency))
            {
                if (quoteCurrencyInfo == null)
                {
                    throw new CustomArgumentException(string.Format(GlobalConstants.ERROR_QuoteCurrencyDoesNotExists, givenQuoteCurrency));
                }
            }


            this.quoteCurrency      = new QuoteCurrency();
            this.quoteCurrency.Name = this.CheckIfEuro(givenQuoteCurrency) ? GlobalConstants.EURO_NAME : quoteCurrencyInfo.Currency;
            this.quoteCurrency.Rate = this.CheckIfEuro(givenQuoteCurrency) ? GlobalConstants.EURO_RATE : quoteCurrencyInfo.Rate;
        }
Пример #4
0
 /// <summary>Returns the hash code for this instance.</summary>
 /// <returns>A 32-bit signed integer that is the hash code for this instance.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         return(Value.GetHashCode() + (397 * BaseCurrency.GetHashCode()) + (397 * QuoteCurrency.GetHashCode()));
     }
 }
Пример #5
0
        /// <summary>
        /// Returns true if Instrument instances are equal
        /// </summary>
        /// <param name="other">Instance of Instrument to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Instrument other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     QuoteCurrency == other.QuoteCurrency ||

                     QuoteCurrency.Equals(other.QuoteCurrency)
                     ) &&
                 (
                     Kind == other.Kind ||

                     Kind.Equals(other.Kind)
                 ) &&
                 (
                     TickSize == other.TickSize ||
                     TickSize != null &&
                     TickSize.Equals(other.TickSize)
                 ) &&
                 (
                     ContractSize == other.ContractSize ||
                     ContractSize != null &&
                     ContractSize.Equals(other.ContractSize)
                 ) &&
                 (
                     IsActive == other.IsActive ||
                     IsActive != null &&
                     IsActive.Equals(other.IsActive)
                 ) &&
                 (
                     OptionType == other.OptionType ||

                     OptionType.Equals(other.OptionType)
                 ) &&
                 (
                     MinTradeAmount == other.MinTradeAmount ||
                     MinTradeAmount != null &&
                     MinTradeAmount.Equals(other.MinTradeAmount)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     SettlementPeriod == other.SettlementPeriod ||

                     SettlementPeriod.Equals(other.SettlementPeriod)
                 ) &&
                 (
                     Strike == other.Strike ||
                     Strike != null &&
                     Strike.Equals(other.Strike)
                 ) &&
                 (
                     BaseCurrency == other.BaseCurrency ||

                     BaseCurrency.Equals(other.BaseCurrency)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     ExpirationTimestamp == other.ExpirationTimestamp ||
                     ExpirationTimestamp != null &&
                     ExpirationTimestamp.Equals(other.ExpirationTimestamp)
                 ));
        }
Пример #6
0
 public override string ToString()
 {
     return($"{Id} - [Base Currency : {BaseCurrency?.ToString()}] - [Quote Currency : {QuoteCurrency?.ToString()}] | {Value}");
 }
Пример #7
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (UnderlyingIndex != null)
         {
             hashCode = hashCode * 59 + UnderlyingIndex.GetHashCode();
         }
         if (Volume != null)
         {
             hashCode = hashCode * 59 + Volume.GetHashCode();
         }
         if (VolumeUsd != null)
         {
             hashCode = hashCode * 59 + VolumeUsd.GetHashCode();
         }
         if (UnderlyingPrice != null)
         {
             hashCode = hashCode * 59 + UnderlyingPrice.GetHashCode();
         }
         if (BidPrice != null)
         {
             hashCode = hashCode * 59 + BidPrice.GetHashCode();
         }
         if (OpenInterest != null)
         {
             hashCode = hashCode * 59 + OpenInterest.GetHashCode();
         }
         if (QuoteCurrency != null)
         {
             hashCode = hashCode * 59 + QuoteCurrency.GetHashCode();
         }
         if (High != null)
         {
             hashCode = hashCode * 59 + High.GetHashCode();
         }
         if (EstimatedDeliveryPrice != null)
         {
             hashCode = hashCode * 59 + EstimatedDeliveryPrice.GetHashCode();
         }
         if (Last != null)
         {
             hashCode = hashCode * 59 + Last.GetHashCode();
         }
         if (MidPrice != null)
         {
             hashCode = hashCode * 59 + MidPrice.GetHashCode();
         }
         if (InterestRate != null)
         {
             hashCode = hashCode * 59 + InterestRate.GetHashCode();
         }
         if (Funding8h != null)
         {
             hashCode = hashCode * 59 + Funding8h.GetHashCode();
         }
         if (MarkPrice != null)
         {
             hashCode = hashCode * 59 + MarkPrice.GetHashCode();
         }
         if (AskPrice != null)
         {
             hashCode = hashCode * 59 + AskPrice.GetHashCode();
         }
         if (InstrumentName != null)
         {
             hashCode = hashCode * 59 + InstrumentName.GetHashCode();
         }
         if (Low != null)
         {
             hashCode = hashCode * 59 + Low.GetHashCode();
         }
         if (BaseCurrency != null)
         {
             hashCode = hashCode * 59 + BaseCurrency.GetHashCode();
         }
         if (CreationTimestamp != null)
         {
             hashCode = hashCode * 59 + CreationTimestamp.GetHashCode();
         }
         if (CurrentFunding != null)
         {
             hashCode = hashCode * 59 + CurrentFunding.GetHashCode();
         }
         return(hashCode);
     }
 }
Пример #8
0
        /// <summary>
        /// Returns true if BookSummary instances are equal
        /// </summary>
        /// <param name="other">Instance of BookSummary to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BookSummary other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     UnderlyingIndex == other.UnderlyingIndex ||
                     UnderlyingIndex != null &&
                     UnderlyingIndex.Equals(other.UnderlyingIndex)
                     ) &&
                 (
                     Volume == other.Volume ||
                     Volume != null &&
                     Volume.Equals(other.Volume)
                 ) &&
                 (
                     VolumeUsd == other.VolumeUsd ||
                     VolumeUsd != null &&
                     VolumeUsd.Equals(other.VolumeUsd)
                 ) &&
                 (
                     UnderlyingPrice == other.UnderlyingPrice ||
                     UnderlyingPrice != null &&
                     UnderlyingPrice.Equals(other.UnderlyingPrice)
                 ) &&
                 (
                     BidPrice == other.BidPrice ||
                     BidPrice != null &&
                     BidPrice.Equals(other.BidPrice)
                 ) &&
                 (
                     OpenInterest == other.OpenInterest ||
                     OpenInterest != null &&
                     OpenInterest.Equals(other.OpenInterest)
                 ) &&
                 (
                     QuoteCurrency == other.QuoteCurrency ||
                     QuoteCurrency != null &&
                     QuoteCurrency.Equals(other.QuoteCurrency)
                 ) &&
                 (
                     High == other.High ||
                     High != null &&
                     High.Equals(other.High)
                 ) &&
                 (
                     EstimatedDeliveryPrice == other.EstimatedDeliveryPrice ||
                     EstimatedDeliveryPrice != null &&
                     EstimatedDeliveryPrice.Equals(other.EstimatedDeliveryPrice)
                 ) &&
                 (
                     Last == other.Last ||
                     Last != null &&
                     Last.Equals(other.Last)
                 ) &&
                 (
                     MidPrice == other.MidPrice ||
                     MidPrice != null &&
                     MidPrice.Equals(other.MidPrice)
                 ) &&
                 (
                     InterestRate == other.InterestRate ||
                     InterestRate != null &&
                     InterestRate.Equals(other.InterestRate)
                 ) &&
                 (
                     Funding8h == other.Funding8h ||
                     Funding8h != null &&
                     Funding8h.Equals(other.Funding8h)
                 ) &&
                 (
                     MarkPrice == other.MarkPrice ||
                     MarkPrice != null &&
                     MarkPrice.Equals(other.MarkPrice)
                 ) &&
                 (
                     AskPrice == other.AskPrice ||
                     AskPrice != null &&
                     AskPrice.Equals(other.AskPrice)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     Low == other.Low ||
                     Low != null &&
                     Low.Equals(other.Low)
                 ) &&
                 (
                     BaseCurrency == other.BaseCurrency ||
                     BaseCurrency != null &&
                     BaseCurrency.Equals(other.BaseCurrency)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     CurrentFunding == other.CurrentFunding ||
                     CurrentFunding != null &&
                     CurrentFunding.Equals(other.CurrentFunding)
                 ));
        }
Пример #9
0
        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            var sb = new System.Text.StringBuilder();

            sb.Append("class PositionResponse {\n");
            sb.Append("  Account: ").Append(Account.ToString()).Append("\n");
            sb.Append("  Symbol: ").Append(Symbol.ToString()).Append("\n");
            sb.Append("  Currency: ").Append(Currency.ToString()).Append("\n");
            sb.Append("  Underlying: ").Append(Underlying.ToString()).Append("\n");
            sb.Append("  QuoteCurrency: ").Append(QuoteCurrency.ToString()).Append("\n");
            sb.Append("  Commission: ").Append(Commission.ToString()).Append("\n");
            sb.Append("  InitMarginReq: ").Append(InitMarginReq.ToString()).Append("\n");
            sb.Append("  MaintMarginReq: ").Append(MaintMarginReq.ToString()).Append("\n");
            sb.Append("  RiskLimit: ").Append(RiskLimit.ToString()).Append("\n");
            sb.Append("  Leverage: ").Append(Leverage.ToString()).Append("\n");
            sb.Append("  CrossMargin: ").Append(CrossMargin.ToString()).Append("\n");
            //sb.Append("  DeleveragePercentile: ").Append(DeleveragePercentile.ToString()).Append("\n");
            sb.Append("  RebalancedPnl: ").Append(RebalancedPnl.ToString()).Append("\n");
            sb.Append("  PrevRealisedPnl: ").Append(PrevRealisedPnl.ToString()).Append("\n");
            sb.Append("  PrevUnrealisedPnl: ").Append(PrevUnrealisedPnl.ToString()).Append("\n");
            sb.Append("  PrevClosePrice: ").Append(PrevClosePrice.ToString()).Append("\n");
            sb.Append("  OpeningTimestamp: ").Append(OpeningTimestamp.ToString()).Append("\n");
            sb.Append("  OpeningQty: ").Append(OpeningQty.ToString()).Append("\n");
            sb.Append("  OpeningCost: ").Append(OpeningCost.ToString()).Append("\n");
            sb.Append("  OpeningComm: ").Append(OpeningComm.ToString()).Append("\n");
            sb.Append("  OpenOrderBuyQty: ").Append(OpenOrderBuyQty.ToString()).Append("\n");
            sb.Append("  OpenOrderBuyCost: ").Append(OpenOrderBuyCost.ToString()).Append("\n");
            sb.Append("  OpenOrderBuyPremium: ").Append(OpenOrderBuyPremium.ToString()).Append("\n");
            sb.Append("  OpenOrderSellQty: ").Append(OpenOrderSellQty.ToString()).Append("\n");
            sb.Append("  OpenOrderSellCost: ").Append(OpenOrderSellCost.ToString()).Append("\n");
            sb.Append("  OpenOrderSellPremium: ").Append(OpenOrderSellPremium.ToString()).Append("\n");
            sb.Append("  ExecBuyQty: ").Append(ExecBuyQty.ToString()).Append("\n");
            sb.Append("  ExecBuyCost: ").Append(ExecBuyCost.ToString()).Append("\n");
            sb.Append("  ExecSellQty: ").Append(ExecSellQty.ToString()).Append("\n");
            sb.Append("  ExecSellCost: ").Append(ExecSellCost.ToString()).Append("\n");
            sb.Append("  ExecQty: ").Append(ExecQty.ToString()).Append("\n");
            sb.Append("  ExecCost: ").Append(ExecCost.ToString()).Append("\n");
            sb.Append("  ExecComm: ").Append(ExecComm.ToString()).Append("\n");
            sb.Append("  CurrentTimestamp: ").Append(CurrentTimestamp.ToString()).Append("\n");
            sb.Append("  CurrentQty: ").Append(CurrentQty.ToString()).Append("\n");
            sb.Append("  CurrentCost: ").Append(CurrentCost.ToString()).Append("\n");
            sb.Append("  CurrentComm: ").Append(CurrentComm.ToString()).Append("\n");
            sb.Append("  RealisedCost: ").Append(RealisedCost.ToString()).Append("\n");
            sb.Append("  UnrealisedCost: ").Append(UnrealisedCost.ToString()).Append("\n");
            sb.Append("  GrossOpenCost: ").Append(GrossOpenCost.ToString()).Append("\n");
            sb.Append("  GrossOpenPremium: ").Append(GrossOpenPremium.ToString()).Append("\n");
            sb.Append("  GrossExecCost: ").Append(GrossExecCost.ToString()).Append("\n");
            sb.Append("  IsOpen: ").Append(IsOpen.ToString()).Append("\n");
            sb.Append("  MarkPrice: ").Append(MarkPrice.ToString()).Append("\n");
            sb.Append("  MarkValue: ").Append(MarkValue.ToString()).Append("\n");
            sb.Append("  RiskValue: ").Append(RiskValue.ToString()).Append("\n");
            sb.Append("  HomeNotional: ").Append(HomeNotional.ToString()).Append("\n");
            sb.Append("  ForeignNotional: ").Append(ForeignNotional.ToString()).Append("\n");
            sb.Append("  PosState: ").Append(PosState.ToString()).Append("\n");
            sb.Append("  PosCost: ").Append(PosCost.ToString()).Append("\n");
            sb.Append("  PosCost2: ").Append(PosCost2.ToString()).Append("\n");
            sb.Append("  PosCross: ").Append(PosCross.ToString()).Append("\n");
            sb.Append("  PosInit: ").Append(PosInit.ToString()).Append("\n");
            sb.Append("  PosComm: ").Append(PosComm.ToString()).Append("\n");
            sb.Append("  PosLoss: ").Append(PosLoss.ToString()).Append("\n");
            sb.Append("  PosMargin: ").Append(PosMargin.ToString()).Append("\n");
            sb.Append("  PosMaint: ").Append(PosMaint.ToString()).Append("\n");
            sb.Append("  PosAllowance: ").Append(PosAllowance.ToString()).Append("\n");
            sb.Append("  TaxableMargin: ").Append(TaxableMargin.ToString()).Append("\n");
            sb.Append("  InitMargin: ").Append(InitMargin.ToString()).Append("\n");
            sb.Append("  MaintMargin: ").Append(MaintMargin.ToString()).Append("\n");
            sb.Append("  SessionMargin: ").Append(SessionMargin.ToString()).Append("\n");
            sb.Append("  TargetExcessMargin: ").Append(TargetExcessMargin.ToString()).Append("\n");
            sb.Append("  VarMargin: ").Append(VarMargin.ToString()).Append("\n");
            sb.Append("  RealisedGrossPnl: ").Append(RealisedGrossPnl.ToString()).Append("\n");
            sb.Append("  RealisedTax: ").Append(RealisedTax.ToString()).Append("\n");
            sb.Append("  RealisedPnl: ").Append(RealisedPnl.ToString()).Append("\n");
            sb.Append("  UnrealisedGrossPnl: ").Append(UnrealisedGrossPnl.ToString()).Append("\n");
            sb.Append("  LongBankrupt: ").Append(LongBankrupt.ToString()).Append("\n");
            sb.Append("  ShortBankrupt: ").Append(ShortBankrupt.ToString()).Append("\n");
            sb.Append("  TaxBase: ").Append(TaxBase.ToString()).Append("\n");
            sb.Append("  IndicativeTaxRate: ").Append(IndicativeTaxRate.ToString()).Append("\n");
            sb.Append("  IndicativeTax: ").Append(IndicativeTax.ToString()).Append("\n");
            sb.Append("  UnrealisedTax: ").Append(UnrealisedTax.ToString()).Append("\n");
            sb.Append("  UnrealisedPnl: ").Append(UnrealisedPnl.ToString()).Append("\n");
            sb.Append("  UnrealisedPnlPcnt: ").Append(UnrealisedPnlPcnt.ToString()).Append("\n");
            sb.Append("  UnrealisedRoePcnt: ").Append(UnrealisedRoePcnt.ToString()).Append("\n");
            //sb.Append("  SimpleQty: ").Append(SimpleQty.ToString()).Append("\n");
            //sb.Append("  SimpleCost: ").Append(SimpleCost.ToString()).Append("\n");
            //sb.Append("  SimpleValue: ").Append(SimpleValue.ToString()).Append("\n");
            //sb.Append("  SimplePnl: ").Append(SimplePnl.ToString()).Append("\n");
            //sb.Append("  SimplePnlPcnt: ").Append(SimplePnlPcnt.ToString()).Append("\n");
            //sb.Append("  AvgCostPrice: ").Append(AvgCostPrice.ToString()).Append("\n");
            //sb.Append("  AvgEntryPrice: ").Append(AvgEntryPrice.ToString()).Append("\n");
            //sb.Append("  BreakEvenPrice: ").Append(BreakEvenPrice.ToString()).Append("\n");
            //sb.Append("  MarginCallPrice: ").Append(MarginCallPrice.ToString()).Append("\n");
            //sb.Append("  LiquidationPrice: ").Append(LiquidationPrice.ToString()).Append("\n");
            //sb.Append("  BankruptPrice: ").Append(BankruptPrice.ToString()).Append("\n");
            sb.Append("  Timestamp: ").Append(Timestamp.ToString()).Append("\n");
            sb.Append("  LastPrice: ").Append(LastPrice.ToString()).Append("\n");
            sb.Append("  LastValue: ").Append(LastValue.ToString()).Append("\n");
            sb.Append("}\n");
            return(sb.ToString());
        }