Exemple #1
0
 public StopOrderTransaction(TransactionID id, DateTime time, int userID, AccountID accountID, TransactionID batchID, RequestID requestID, TransactionType type, InstrumentName instrument, double units, PriceValue price, PriceValue priceBound, TimeInForce timeInForce, DateTime gTDTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, StopOrderReason reason, ClientExtensions clientExtensions, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, OrderID replacesOrderID, TransactionID cancellingTransactionID)
 {
     this.Id                      = id;
     this.Time                    = time;
     this.UserID                  = userID;
     this.AccountID               = accountID;
     this.BatchID                 = batchID;
     this.RequestID               = requestID;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.PriceBound              = priceBound;
     this.TimeInForce             = timeInForce;
     this.GTDTime                 = gTDTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.Reason                  = reason;
     this.ClientExtensions        = clientExtensions;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.ReplacesOrderID         = replacesOrderID;
     this.CancellingTransactionID = cancellingTransactionID;
 }
Exemple #2
0
 public CandlestickData()
 {
     this.O = new PriceValue();
     this.H = new PriceValue();
     this.L = new PriceValue();
     this.C = new PriceValue();
 }
Exemple #3
0
        public List <PriceValue> GetPrices(string[] symbols)
        {
            List <PriceValue> prices = new List <PriceValue>();
            string            json;
            string            joinedSymbols = string.Join(",", symbols);

            using (var web = new WebClient())
            {
                //var url = $"http://finance.google.com/finance/info?client=ig&amp;amp;q=NASDAQ%3A{tickers}";
                var url = $"http://finance.google.com/finance/info?client=ig&q={joinedSymbols}";
                json = web.DownloadString(url);
            }

            //Google adds a comment before the json for some unknown reason, so we need to remove it
            json = json.Replace("//", "");

            var v = JArray.Parse(json);

            foreach (var i in v)
            {
                PriceValue pricevalue = new PriceValue();
                pricevalue.Symbol         = (string)i.SelectToken("t");
                pricevalue.Price          = (decimal)i.SelectToken("l");
                pricevalue.PriceDate      = (DateTime)i.SelectToken("lt_dts");
                pricevalue.IntradayChange = (decimal)i.SelectToken("c");

                //set the creation date
                pricevalue.CreationDate = DateTime.Now;
                pricevalue.CreationName = "SYSTEM";

                prices.Add(pricevalue);
            }

            return(prices);
        }
        private void UpdatePriceOnSku(string code, DateTime from, DateTime until, IMarket market, string currency, decimal value)
        {
            var catalogKey = new CatalogKey(Mediachase.Commerce.Core.AppContext.Current.ApplicationId, code);



            var priceServiceDatabase = ServiceLocator.Current.GetInstance <IPriceService>();

            CustomerPricing.PriceType type =
                (CustomerPricing.PriceType)Enum.Parse(typeof(CustomerPricing.PriceType), PriceType.SelectedValue);
            var priceCode = PriceCode.Text;


            var price = new PriceValue()
            {
                CatalogKey      = catalogKey,
                CustomerPricing = new CustomerPricing(type, priceCode),
                MarketId        = market.MarketId,
                MinQuantity     = 0,
                UnitPrice       = new Money(value, new Currency(currency)),
                ValidFrom       = from,
                ValidUntil      = until
            };


            priceServiceDatabase.SetCatalogEntryPrices(catalogKey, new[] { price });
        }
 public MarketOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.MARKET);
     this.Instrument              = new InstrumentName();
     this.TimeInForce             = new TimeInForce(ETimeInForce.FOK);
     this.PriceBound              = new PriceValue();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TradeClose              = new MarketOrderTradeClose();
     this.LongPositionCloseout    = new MarketOrderPositionCloseout();
     this.ShortPositionCloseout   = new MarketOrderPositionCloseout();
     this.MarginCloseout          = new MarketOrderMarginCloseout();
     this.DelayedTradeClose       = new MarketOrderDelayedTradeClose();
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
 }
Exemple #6
0
        public async Task <IHttpActionResult> PutPriceValue(int id, PriceValue priceValue)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != priceValue.Id)
            {
                return(BadRequest());
            }



            try
            {
                await repo.UpdateAsync(priceValue);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!repo.PriceValueExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public MarketOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, TimeInForce timeInForce, PriceValue priceBound, OrderPositionFill positionFill, MarketOrderTradeClose tradeClose, MarketOrderPositionCloseout longPositionCloseout, MarketOrderPositionCloseout shortPositionCloseout, MarketOrderMarginCloseout marginCloseout, MarketOrderDelayedTradeClose delayedTradeClose, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.TimeInForce             = timeInForce;
     this.PriceBound              = priceBound;
     this.PositionFill            = positionFill;
     this.TradeClose              = tradeClose;
     this.LongPositionCloseout    = longPositionCloseout;
     this.ShortPositionCloseout   = shortPositionCloseout;
     this.MarginCloseout          = marginCloseout;
     this.DelayedTradeClose       = delayedTradeClose;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
 }
Exemple #8
0
 public TakeProfitDetails(PriceValue priceValue, ETimeInForce timeInForce, DateTime dateTime, ClientExtensions clientExtensions)
 {
     this.Price            = priceValue;
     this.TimeInForce      = timeInForce.ToString();
     this.GTDTime          = dateTime;
     this.ClientExtensions = clientExtensions;
 }
Exemple #9
0
 public StopOrder()
 {
     this.Id                      = new OrderID();
     this.CreateTime              = new DateTime();
     this.State                   = new OrderState();
     this.ClientExtensions        = new ClientExtensions();
     this.Type                    = new OrderType(EOrderType.STOP);
     this.Instrument              = new InstrumentName();
     this.Price                   = new PriceValue();
     this.PriceBound              = new PriceValue();
     this.TimeInForce             = new TimeInForce(ETimeInForce.GTC);
     this.GtdTime                 = new DateTime();
     this.PositionFill            = new OrderPositionFill(EOrderPositionFill.DEFAULT);
     this.TriggerCondition        = new OrderTriggerCondition(EOrderTriggerCondition.DEFAULT);
     this.TakeProfitOnFill        = new TakeProfitDetails();
     this.StopLossOnFill          = new StopLossDetails();
     this.TrailingStopLossOnFill  = new TrailingStopLossDetails();
     this.TradeClientExtensions   = new ClientExtensions();
     this.FillingTransactionID    = new TransactionID();
     this.FilledTime              = new DateTime();
     this.TradeOpenedID           = new TradeID();
     this.TradeReducedID          = new TradeID();
     this.TradeClosedIDs          = new List <TradeID>();
     this.CancellingTransactionID = new TransactionID();
     this.CancelledTime           = new DateTime();
     this.ReplacesOrderID         = new OrderID();
     this.ReplacedByOrderID       = new OrderID();
 }
Exemple #10
0
 public CandlestickData(PriceValue o, PriceValue h, PriceValue l, PriceValue c)
 {
     this.O = o;
     this.H = h;
     this.L = l;
     this.C = c;
 }
Exemple #11
0
 public StopOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, InstrumentName instrument, double units, PriceValue price, PriceValue priceBound, TimeInForce timeInForce, DateTime gtdTime, OrderPositionFill positionFill, OrderTriggerCondition triggerCondition, TakeProfitDetails takeProfitOnFill, StopLossDetails stopLossOnFill, TrailingStopLossDetails trailingStopLossOnFill, ClientExtensions tradeClientExtensions, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime, OrderID replacesOrderID, OrderID replacedByOrderID)
 {
     this.Id                      = id;
     this.CreateTime              = createTime;
     this.State                   = state;
     this.ClientExtensions        = clientExtensions;
     this.Type                    = type;
     this.Instrument              = instrument;
     this.Units                   = units;
     this.Price                   = price;
     this.PriceBound              = priceBound;
     this.TimeInForce             = timeInForce;
     this.GtdTime                 = gtdTime;
     this.PositionFill            = positionFill;
     this.TriggerCondition        = triggerCondition;
     this.TakeProfitOnFill        = takeProfitOnFill;
     this.StopLossOnFill          = stopLossOnFill;
     this.TrailingStopLossOnFill  = trailingStopLossOnFill;
     this.TradeClientExtensions   = tradeClientExtensions;
     this.FillingTransactionID    = fillingTransactionID;
     this.FilledTime              = filledTime;
     this.TradeOpenedID           = tradeOpenedID;
     this.TradeReducedID          = tradeReducedID;
     this.TradeClosedIDs          = tradeClosedIDs;
     this.CancellingTransactionID = cancellingTransactionID;
     this.CancelledTime           = cancelledTime;
     this.ReplacesOrderID         = replacesOrderID;
     this.ReplacedByOrderID       = replacedByOrderID;
 }
Exemple #12
0
 public DynamicOrderState(OrderID id, PriceValue trailingStopValue, PriceValue triggerDistance, bool isTriggerDistanceExact)
 {
     this.Id = id;
     this.TrailingStopValue      = trailingStopValue;
     this.TriggerDistance        = triggerDistance;
     this.IsTriggerDistanceExact = isTriggerDistanceExact;
 }
        public void Dump()
        {
            var languageBranch = _languageBranchRepository.ListAll().First();

            var currentMarket = _currentMarket.GetCurrentMarket();
            var market        = (MarketImpl)_marketService.GetMarket(currentMarket.MarketId);

            market.DefaultCurrency = Currency.EUR;
            market.DefaultLanguage = languageBranch.Culture;
            _marketService.UpdateMarket(market);

            var rootLink = _referenceConverter.GetRootLink();
            var catalog  = _contentRepository.GetDefault <CatalogContent>(rootLink, languageBranch.Culture);

            catalog.Name             = "Catalog";
            catalog.DefaultCurrency  = market.DefaultCurrency;
            catalog.CatalogLanguages = new ItemCollection <string> {
                languageBranch.LanguageID
            };
            catalog.DefaultLanguage = "en";
            catalog.WeightBase      = "kg";
            catalog.LengthBase      = "cm";
            var catalogRef = _contentRepository.Save(catalog, SaveAction.Publish, AccessLevel.NoAccess);

            var category = _contentRepository.GetDefault <NodeContent>(catalogRef);

            category.Name        = "Category";
            category.DisplayName = "Category";
            category.Code        = "category";
            var categoryRef = _contentRepository.Save(category, SaveAction.Publish, AccessLevel.NoAccess);

            var product = _contentRepository.GetDefault <ProductContent>(categoryRef);

            product.Name        = "Product";
            product.DisplayName = "Product";
            product.Code        = "product";
            var productRef = _contentRepository.Save(product, SaveAction.Publish, AccessLevel.NoAccess);

            var variant = _contentRepository.GetDefault <VariationContent>(productRef);

            variant.Name        = "Variant";
            variant.DisplayName = "Variant";
            variant.Code        = "test";
            variant.MinQuantity = 1;
            variant.MaxQuantity = 100;
            _contentRepository.Save(variant, SaveAction.Publish, AccessLevel.NoAccess);

            var price = new PriceValue
            {
                UnitPrice       = new Money(100, market.DefaultCurrency),
                CatalogKey      = new CatalogKey(variant.Code),
                MarketId        = market.MarketId,
                ValidFrom       = DateTime.Today.AddYears(-1),
                ValidUntil      = DateTime.Today.AddYears(1),
                CustomerPricing = CustomerPricing.AllCustomers,
                MinQuantity     = 0
            };

            _priceService.SetCatalogEntryPrices(price.CatalogKey, new[] { price });
        }
Exemple #14
0
        /// <summary>
        /// 将字符串金额格式化"9785.335"→"9,78.33"
        /// </summary>
        /// <param name="strPriceValue">需要转换的字符串</param>
        /// <param name="FractionalDigit">四舍五入的小数位数</param>
        /// <returns></returns>
        public string FormatCurrency(string strPriceValue, int fractionalDigit)
        {
            try
            {
                Decimal PriceValue;
                if (!Decimal.TryParse(strPriceValue, out PriceValue))
                {
                    return(strPriceValue);
                }
                strPriceValue = PriceValue.ToString("F" + fractionalDigit.ToString());
                string retValue = "." + strPriceValue.Split('.')[1];
                strPriceValue = strPriceValue.Split('.')[0];

                while (strPriceValue.Length > 3)
                {
                    retValue      = "," + strPriceValue.Substring(strPriceValue.Length - 3, 3) + retValue;
                    strPriceValue = strPriceValue.Substring(0, strPriceValue.Length - 3);
                }
                retValue = strPriceValue + retValue;
                return(retValue);
            }
            catch (Exception)
            {
                return(strPriceValue);
            }
        }
 public StopLossOrder(OrderID id, DateTime createTime, OrderState state, ClientExtensions clientExtensions, OrderType type, double guaranteedExecutionPremium, TradeID tradeID, ClientID clientTradeID, PriceValue price, double distance, TimeInForce timeInForce, DateTime gtdTime, OrderTriggerCondition triggerCondition, bool guaranteed, TransactionID fillingTransactionID, DateTime filledTime, TradeID tradeOpenedID, TradeID tradeReducedID, List <TradeID> tradeClosedIDs, TransactionID cancellingTransactionID, DateTime cancelledTime, OrderID replacesOrderID, OrderID replacedByOrderID)
 {
     this.Id                         = id;
     this.CreateTime                 = createTime;
     this.State                      = state;
     this.ClientExtensions           = clientExtensions;
     this.Type                       = type;
     this.GuaranteedExecutionPremium = guaranteedExecutionPremium;
     this.TradeID                    = tradeID;
     this.ClientTradeID              = clientTradeID;
     this.Price                      = price;
     this.Distance                   = distance;
     this.TimeInForce                = timeInForce;
     this.GtdTime                    = gtdTime;
     this.TriggerCondition           = triggerCondition;
     this.Guaranteed                 = guaranteed;
     this.FillingTransactionID       = fillingTransactionID;
     this.FilledTime                 = filledTime;
     this.TradeOpenedID              = tradeOpenedID;
     this.TradeReducedID             = tradeReducedID;
     this.TradeClosedIDs             = tradeClosedIDs;
     this.CancellingTransactionID    = cancellingTransactionID;
     this.CancelledTime              = cancelledTime;
     this.ReplacesOrderID            = replacesOrderID;
     this.ReplacedByOrderID          = replacedByOrderID;
 }
        //	s: Symbol
        //  l1: Last Trade (Price Only)
        //  d1: Last Trade Date
        //  t1: Last Trade Time
        //  c1: Change

        public List <PriceValue> GetPrices(string[] symbols)
        {
            List <PriceValue> prices        = new List <PriceValue>();
            string            joinedSymbols = string.Join("+", symbols);
            string            url           = "";


            // Remove the trailing plus sign.

            url = joinedSymbols;

            // Prepend the base URL.

            url = base_url.Replace("@", url);

            // Get the response.
            try
            {
                // Get the web response.
                string result = GetWebResponse(url);


                // Pull out the current prices.
                string[] lines = result.Split(
                    new char[] { '\r', '\n' },
                    StringSplitOptions.RemoveEmptyEntries);

                foreach (string line in lines)
                {
                    PriceValue pricevalue  = new PriceValue();
                    char[]     charsToTrim = { '*', '\"', '"' };
                    //set the stock symbol
                    pricevalue.Symbol = line.Split(',')[0].Trim(charsToTrim);
                    pricevalue.Price  = Convert.ToDecimal(line.Split(',')[1]);
                    //compile the date time by combining the Date and the time
                    string   date = line.Split(',')[2].Trim(charsToTrim);
                    string   time = line.Split(',')[3].Trim(charsToTrim);
                    DateTime dt   = Convert.ToDateTime(date + " " + time);
                    //convert the date time to CST from EST
                    DateTime priceDateTime = dt.Subtract(TimeSpan.FromHours(1));
                    //set the pricedate
                    pricevalue.PriceDate = priceDateTime;

                    pricevalue.IntradayChange = Convert.ToDecimal(line.Split(',')[4]);
                    //set the creation date
                    pricevalue.CreationDate = DateTime.Now;
                    pricevalue.CreationName = "SYSTEM";



                    prices.Add(pricevalue);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(prices);
        }
Exemple #17
0
        public IEnumerable <IPriceValue> GetPrices(string code)
        {
            List <IPriceValue> priceList = new List <IPriceValue>();
            IMarket            market    = _marketService.GetCurrentMarket(); // DEFAULT

            if (String.IsNullOrEmpty(code))
            {
                throw new ArgumentNullException("Code is needed");
            }

            // need the key
            var catalogKey = new CatalogKey(code);

            //PriceFilter filter = new PriceFilter();

            //priceList.(_priceService.GetPrices(market.MarketId, DateTime.Now, catalogKey, filter));

            priceList = _priceService.GetCatalogEntryPrices(catalogKey).ToList();

            foreach (IPriceValue item in priceList)
            {
                if (item.CustomerPricing.PriceTypeId.ToString() == "7") // could use the int
                {
                    priceList.Clear();
                    break;
                }
            }

            //CustomerPricing.PriceType ppp = new CustomerPricing.PriceType();

            // custom PriceTypeId, a bit cumbersome
            PriceFilter filter = new PriceFilter()
            {
                Quantity        = 0M,
                Currencies      = new Currency[] { "USD" },
                CustomerPricing = new CustomerPricing[]
                {
                    new CustomerPricing((CustomerPricing.PriceType) 7, "VIP") // or "Andersson"... need the code...or
                    // ... do filtering (like remove from list)
                },
                ReturnCustomerPricing = true // ...see below for info
                                             // interpretation of the CustomerPricing property... if true; gets all that applies
            };

            //IEnumerable< CustomerPricing> custPrice = new CustomerPricing(CustomerPricing.PriceType.PriceGroup, "PriceOverride");
            //filter.CustomerPricing = custPrice;

            priceList = _priceService.GetPrices(
                _marketService.GetCurrentMarket().MarketId.Value, DateTime.Now, catalogKey, filter).ToList();

            // just checking
            var p = new PriceValue();

            p.UnitPrice   = new Money(99, "USD");
            p.MinQuantity = 2;
            priceList.Add((IPriceValue)p);

            return(priceList);
        }
Exemple #18
0
 public PriceModel(PriceValue price)
 {
     id         = price.Id;
     startDate  = price.StartDate;
     endDate    = price.EndDate;
     cost       = price.Cost;
     this.price = price.Price;
 }
Exemple #19
0
 public async Task InsertAsync(PriceValue pricevalue)
 {
     using (_db)
     {
         _db.PriceValues.Add(pricevalue);
         await _db.SaveChangesAsync();
     }
 }
Exemple #20
0
 /// <summary>
 /// A TakeProfitOrderRequest specifies the parameters that may be set when creating a Take Profit Order. Only one of the price and distance fields may be specified.
 /// </summary>
 /// <param name="tradeID">The ID of the Trade to close when the price threshold is breached.</param>
 /// <param name="price">The price threshold specified for the TakeProfit Order. The associated Trade will be closed by a market price that is equal to or better than this threshold.</param>
 public TakeProfitOrderRequest(TradeID tradeID, PriceValue price)
 {
     this.Type             = EOrderType.TAKE_PROFIT.ToString();
     this.TradeID          = tradeID;
     this.Price            = price;
     this.TimeInForce      = ETimeInForce.GTC.ToString();
     this.TriggerCondition = EOrderTriggerCondition.DEFAULT.ToString();
 }
Exemple #21
0
 public PositionBook(InstrumentName instrument, DateTime time, PriceValue price, PriceValue bucketWidth, List <PositionBookBucket> buckets)
 {
     this.Instrument  = instrument;
     this.Time        = time;
     this.Price       = price;
     this.BucketWidth = bucketWidth;
     this.Buckets     = buckets;
 }
 /// <summary>
 /// A StopLossOrderRequest specifies the parameters that may be set when creating a Stop Loss Order. Only one of the price and distance fields may be specified.
 /// </summary>
 /// <param name="tradeID">The ID of the Trade to close when the price threshold is breached.</param>
 /// <param name="price">The price threshold specified for the Stop Loss Order. If the guaranteed flag is false, the associated Trade will be closed by a market price that is equal to or worse than this threshold. If the flag is true the associated Trade will be closed at this price.</param>
 public StopLossOrderRequest(TradeID tradeID, PriceValue price)
 {
     this.Type             = EOrderType.STOP_LOSS.ToString();
     this.TradeID          = tradeID;
     this.Price            = price;
     this.TimeInForce      = ETimeInForce.GTC.ToString();
     this.TriggerCondition = EOrderTriggerCondition.DEFAULT.ToString();
 }
Exemple #23
0
 public PositionBook()
 {
     this.Instrument  = new InstrumentName();
     this.Time        = new DateTime();
     this.Price       = new PriceValue();
     this.BucketWidth = new PriceValue();
     this.Buckets     = new List <PositionBookBucket>();
 }
 /// <summary>
 /// A TakeProfitOrderRequest specifies the parameters that may be set when creating a Take Profit Order. Only one of the price and distance fields may be specified.
 /// </summary>
 /// <param name="tradeID">The ID of the Trade to close when the price threshold is breached.</param>
 /// <param name="price">The price threshold specified for the TakeProfit Order. The associated Trade will be closed by a market price that is equal to or better than this threshold.</param>
 public TakeProfitOrderRequest(TradeID tradeID, PriceValue price)
 {
     this.Type             = EOrderType.TAKE_PROFIT;
     this.TradeID          = tradeID;
     this.Price            = price;
     this.TimeInForce      = ETimeInForce.GTC;
     this.GtdTime          = DateTime.UtcNow;
     this.TriggerCondition = EOrderTriggerCondition.DEFAULT;
 }
Exemple #25
0
 public async Task UpdateAsync(PriceValue pricevalue)
 {
     using (_db)
     {
         _db.PriceValues.Attach(pricevalue);
         _db.Entry(pricevalue).State = EntityState.Modified;
         await _db.SaveChangesAsync();
     }
 }
Exemple #26
0
 public QuotaPriceData(QuotaPriceData from)
 {
     QuotaState  = from.QuotaState;
     QuotaPlaces = from.QuotaPlaces;
     if (from.PriceValue != null)
     {
         PriceValue = new PriceValue(from.PriceValue);
     }
 }
Exemple #27
0
 public TradeOpen()
 {
     this.TradeID = new TradeID();
     this.Price   = new PriceValue();
     this.GuaranteedExecutionFee = new AccountUnits();
     this.ClientExtensions       = new ClientExtensions();
     this.HalfSpreadCost         = new AccountUnits();
     this.InitialMarginRequired  = new AccountUnits();
 }
Exemple #28
0
 /// <summary>
 /// A StopLossOrderRequest specifies the parameters that may be set when creating a Stop Loss Order. Only one of the price and distance fields may be specified.
 /// </summary>
 /// <param name="tradeID">The ID of the Trade to close when the price threshold is breached.</param>
 /// <param name="price">The price threshold specified for the Stop Loss Order. If the guaranteed flag is false, the associated Trade will be closed by a market price that is equal to or worse than this threshold. If the flag is true the associated Trade will be closed at this price.</param>
 public StopLossOrderRequest(TradeID tradeID, PriceValue price)
 {
     this.Type             = EOrderType.STOP_LOSS;
     this.TradeID          = tradeID;
     this.Price            = price;
     this.TimeInForce      = ETimeInForce.GTC;
     this.GtdTime          = DateTime.UtcNow;
     this.TriggerCondition = EOrderTriggerCondition.DEFAULT;
 }
Exemple #29
0
 public TradeReduce()
 {
     this.TradeID                = new TradeID();
     this.Price                  = new PriceValue();
     this.RealizedPL             = new AccountUnits();
     this.Financing              = new AccountUnits();
     this.GuaranteedExecutionFee = new AccountUnits();
     this.HalfSpreadCost         = new AccountUnits();
 }
 /// <summary>
 /// A StopOrderRequest specifies the parameters that may be set when creating a Stop Order.
 /// </summary>
 /// <param name="instrument">The Stop Order’s Instrument.</param>
 /// <param name="units">The quantity requested to be filled by the Stop Order. A posititive number of units results in a long Order, and a negative number of units results in a short Order.</param>
 /// <param name="price">The price threshold specified for the Stop Order. The Stop Order will only be filled by a market price that is equal to or worse than this price.</param>
 public StopOrderRequest(InstrumentName instrument, double units, PriceValue price)
 {
     this.Type             = EOrderType.STOP.ToString();
     this.Instrument       = instrument.ToString();
     this.Units            = units;
     this.Price            = price;
     this.TimeInForce      = ETimeInForce.GTC.ToString();
     this.PositionFill     = EOrderPositionFill.DEFAULT.ToString();
     this.TriggerCondition = EOrderTriggerCondition.DEFAULT.ToString();
 }
	    public void Insert(DateTime? RequestDate,int? RequestUserId,int? RequestCompanyId,string RequestIp,string BookTitle,int InDimensions,string InCurrency,string InPallet,double? InLength,double? InWidth,double? InDepth,double? InWeight,double? InExtent,double? InPapergsm,bool? InHardback,int? CopiesCarton,string OriginName,string CountryName,string FinalName,int? TotCopies,double? PriceLoose,double? PricePallet,double? PriceTotal,double? PriceEx,double? PriceLooseGbp,double? PricePalletGbp,double? PriceTotalGbp,double? PriceClient,string ShipVia,string PalletType,string LooseName,string LclName,double? LclV,double? LclV20,double? LclV40,double? LclV40hc,string LclLooseName,double? LclVloose,double? LclVloose20,double? LclVloose40,double? LclVloose40hc,int? PoLogId,bool? ClientVisible,double? OutLength,double? OutWidth,double? OutDepth,double? OutWeight,int? CopyFromId,string SpreadsheetUsed,string InUserRef,byte[] PvTimestamp)
	    {
		    PriceValue item = new PriceValue();
		    
            item.RequestDate = RequestDate;
            
            item.RequestUserId = RequestUserId;
            
            item.RequestCompanyId = RequestCompanyId;
            
            item.RequestIp = RequestIp;
            
            item.BookTitle = BookTitle;
            
            item.InDimensions = InDimensions;
            
            item.InCurrency = InCurrency;
            
            item.InPallet = InPallet;
            
            item.InLength = InLength;
            
            item.InWidth = InWidth;
            
            item.InDepth = InDepth;
            
            item.InWeight = InWeight;
            
            item.InExtent = InExtent;
            
            item.InPapergsm = InPapergsm;
            
            item.InHardback = InHardback;
            
            item.CopiesCarton = CopiesCarton;
            
            item.OriginName = OriginName;
            
            item.CountryName = CountryName;
            
            item.FinalName = FinalName;
            
            item.TotCopies = TotCopies;
            
            item.PriceLoose = PriceLoose;
            
            item.PricePallet = PricePallet;
            
            item.PriceTotal = PriceTotal;
            
            item.PriceEx = PriceEx;
            
            item.PriceLooseGbp = PriceLooseGbp;
            
            item.PricePalletGbp = PricePalletGbp;
            
            item.PriceTotalGbp = PriceTotalGbp;
            
            item.PriceClient = PriceClient;
            
            item.ShipVia = ShipVia;
            
            item.PalletType = PalletType;
            
            item.LooseName = LooseName;
            
            item.LclName = LclName;
            
            item.LclV = LclV;
            
            item.LclV20 = LclV20;
            
            item.LclV40 = LclV40;
            
            item.LclV40hc = LclV40hc;
            
            item.LclLooseName = LclLooseName;
            
            item.LclVloose = LclVloose;
            
            item.LclVloose20 = LclVloose20;
            
            item.LclVloose40 = LclVloose40;
            
            item.LclVloose40hc = LclVloose40hc;
            
            item.PoLogId = PoLogId;
            
            item.ClientVisible = ClientVisible;
            
            item.OutLength = OutLength;
            
            item.OutWidth = OutWidth;
            
            item.OutDepth = OutDepth;
            
            item.OutWeight = OutWeight;
            
            item.CopyFromId = CopyFromId;
            
            item.SpreadsheetUsed = SpreadsheetUsed;
            
            item.InUserRef = InUserRef;
            
            item.PvTimestamp = PvTimestamp;
            
	    
		    item.Save(UserName);
	    }
        private void UpdatePriceOnSku(string code, DateTime from, DateTime until, IMarket market, string currency, decimal value)
        {
            var catalogKey = new CatalogKey(AppContext.Current.ApplicationId, code);

            var priceServiceDatabase =ServiceLocator.Current.GetInstance<IPriceService>();

            CustomerPricing.PriceType type =
                (CustomerPricing.PriceType)Enum.Parse(typeof(CustomerPricing.PriceType), PriceType.SelectedValue);
            var priceCode = PriceCode.Text;

            var price = new PriceValue()
            {
                CatalogKey = catalogKey,
                CustomerPricing = new CustomerPricing(type, priceCode),
                MarketId = market.MarketId,
                MinQuantity = 0,
                UnitPrice = new Money(value, new Currency(currency)),
                ValidFrom = from,
                ValidUntil = until
            };

            priceServiceDatabase.SetCatalogEntryPrices(catalogKey,new[]{price});
        }
        protected void SetPrices(string code, List<Price> prices)
        {
            if (code == null) throw new ArgumentNullException("code");
            if (prices == null)
                return;

            CatalogKey key = new CatalogKey(AppContext.Current.ApplicationId, code);

            var catalogEntryPrices = _priceService.GetCatalogEntryPrices(key); //.ToList();
            List<IPriceValue> priceValues = new List<IPriceValue>(catalogEntryPrices);

            foreach (Price price in prices)
            {
                // Already there?
                IPriceValue priceValue = priceValues.FirstOrDefault(p => p.MarketId.Value == price.marketId);
                if(priceValue == null)
                {
                    // No - add it
                    PriceValue newPrice = new PriceValue()
                    {
                        CatalogKey = key,
                        MarketId = price.marketId,
                        UnitPrice = new Money(price.price, new Currency(price.currency)),
                        ValidFrom = DateTime.Now,
                        CustomerPricing = CustomerPricing.AllCustomers,
                        MinQuantity = 0

                    };
                    priceValues.Add(newPrice);
                }
                else
                {
                    // We don't touch prices for the same market
                }
            }
            _log.Debug("Saving {0} prices for {1}", priceValues.Count, code);
            // Save prices back
            _priceService.SetCatalogEntryPrices(key, priceValues);
        }