예제 #1
0
 internal DayQuotation(IDBRow dayQuotationRow, Instrument instrument)
 {
     this.instrument = instrument;
     this.tradeDay   = (DateTime)dayQuotationRow["TradeDay"];
     this.ask        = Price.CreateInstance((string)dayQuotationRow["Ask"], instrument.NumeratorUnit, instrument.Denominator);
     this.bid        = Price.CreateInstance((string)dayQuotationRow["Bid"], instrument.NumeratorUnit, instrument.Denominator);
 }
예제 #2
0
 public Price CreatePriceFromString(string value)
 {
     if (string.IsNullOrEmpty(value))
     {
         return(null);
     }
     else
     {
         return(Price.CreateInstance(value, _instrument.NumeratorUnit, _instrument.Denominator));
     }
 }
예제 #3
0
        private Transaction FillIndividualDoneTran(Transaction tran, string doneLimitPrice, string doneStopPrice, Guid sourceOrderId)
        {
            if (string.IsNullOrEmpty(doneLimitPrice) && string.IsNullOrEmpty(doneStopPrice))
            {
                return(null);
            }
            var instrument = tran.SettingInstrument();
            var limitPrice = string.IsNullOrEmpty(doneLimitPrice) ? null : Price.CreateInstance(doneLimitPrice, instrument.NumeratorUnit, instrument.Denominator);
            var stopPrice  = string.IsNullOrEmpty(doneStopPrice) ? null : Price.CreateInstance(doneStopPrice, instrument.NumeratorUnit, instrument.Denominator);

            return(this.CreateDoneTransactionAndOrderRelation(tran, sourceOrderId, limitPrice, stopPrice));
        }
예제 #4
0
 private decimal ConvertPriceValue(decimal value)
 {
     if (value == decimal.Zero)
     {
         return(value);
     }
     if (value < decimal.Zero)
     {
         return(decimal.Zero - (decimal)Price.CreateInstance(Decimal.ToDouble(Math.Abs(value)), this.numeratorUnit.Value, this.denominator.Value));
     }
     else
     {
         return((decimal)Price.CreateInstance(Decimal.ToDouble(value), this.numeratorUnit.Value, this.denominator.Value));
     }
 }
예제 #5
0
 private Price GetHistoryHitPrice(string connectionString)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         SqlCommand command = connection.CreateCommand();
         command.CommandType = System.Data.CommandType.StoredProcedure;
         command.CommandText = "P_GetBOOrderHistoryHitPrice";
         command.Parameters.AddWithValue("@submitorID", this.Owner.SubmitorId);
         command.Parameters.AddWithValue("@instrumentID", this.Instrument().Id);
         command.Parameters.AddWithValue("@timestamp", new SqlDateTime(_nextHitTime.Value).Value);
         SqlParameter parameter = command.Parameters.Add("@hitPrice", System.Data.SqlDbType.VarChar);
         parameter.Size      = 10;
         parameter.Direction = System.Data.ParameterDirection.Output;
         connection.Open();
         command.ExecuteNonQuery();
         string hitPrice = (string)command.Parameters["@hitPrice"].Value;
         return(Price.CreateInstance(hitPrice, this.Instrument().NumeratorUnit, this.Instrument().Denominator));
     }
 }
        public async Task <IResultModel> Handle(CreateProductCommand request, CancellationToken cancellationToken)
        {
            var productName = ProductName.CreateInstance(request.Name);
            var price       = Price.CreateInstance(request.Price);

            var resultModel = await ResultModelExtensions.Validate <Product>(productName, price)
                              .OnSuccess(() =>
            {
                var product = new Product(productName.Value, request.Description, price.Value, request.ImagePath, request.ProductType);
                _           = this.productsRepository.Add(product);

                return(this.productsRepository.UnitOfWork.SaveEntitiesAsync(cancellationToken));
            })
                              .OnFail((rs) =>
            {
                this.logger.LogError($"Could not add product due to: {rs.ApiResult.Message}, errors: {string.Join(",", rs.ApiResult.ValidationErrors)}");
            });

            return(resultModel);
        }
예제 #7
0
        private Price CreatePrice(string priceString, Guid instrumentId)
        {
            var instrument = InstrumentManager.Default.Get(instrumentId);

            return(Price.CreateInstance(priceString, instrument.NumeratorUnit, instrument.Denominator));
        }
예제 #8
0
 public static Price CreatePrice(this string price, Settings.Instrument instrument)
 {
     return(Price.CreateInstance(price, instrument.NumeratorUnit, instrument.Denominator));
 }