コード例 #1
0
        /// <summary>
        /// Constructs parameters to be sent as part of a request to Cryptsy.
        /// </summary>
        /// <param name="method">The API method to call</param>
        /// <param name="orderId">An optional order ID to be passed as a parameter to the method</param>
        /// <param name="marketId">An optional market ID to be passsed as a parameter to the method</param>
        /// <param name="limit">An optional limit on number of returned items, to be passed as a parameter to the method</param>
        /// <returns>An array of key-value pairs</returns>
        private KeyValuePair <string, string>[] GenerateParameters(CryptsyMethod method,
                                                                   OrderId orderId, MarketId marketId, int?limit)
        {
            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(PARAM_METHOD, System.Enum.GetName(typeof(CryptsyMethod), method)),
                new KeyValuePair <string, string>(PARAM_NONCE, GetNextNonce())
            };

            if (null != marketId)
            {
                parameters.Add(new KeyValuePair <string, string>(PARAM_MARKET_ID, marketId.ToString()));
            }

            if (null != orderId)
            {
                parameters.Add(new KeyValuePair <string, string>(PARAM_ORDER_ID, orderId.ToString()));
            }

            if (null != limit)
            {
                parameters.Add(new KeyValuePair <string, string>(PARAM_LIMIT, limit.ToString()));
            }

            return(parameters.ToArray());
        }
コード例 #2
0
 public override string ToString()
 {
     return(MarketId.ToString()
            + "," + MarketOffDatetime.ToString("yyyy-MM-dd HH:mm:ss")
            + "," + SnapshotDatetime.ToString("yyyy-MM-dd HH:mm:ss")
            + "," + SecondsBeforeOff.ToString()
            + "," + SelectionId.ToString()
            + "," + SelectionName.ToString()
            + "," + (Back3 == 0 ? @"\N" : Back3.ToString())
            + "," + (Back3Vol == 0 ? @"\N" : Back3Vol.ToString())
            + "," + (Back2 == 0 ? @"\N" : Back2.ToString())
            + "," + (Back2Vol == 0 ? @"\N" : Back2Vol.ToString())
            + "," + (Back == 0 ? @"\N" : Back.ToString())
            + "," + (BackVol == 0 ? @"\N" : BackVol.ToString())
            + "," + (Lay == 0 ? @"\N" : Lay.ToString())
            + "," + (LayVol == 0 ? @"\N" : LayVol.ToString())
            + "," + (Lay2 == 0 ? @"\N" : Lay2.ToString())
            + "," + (Lay2Vol == 0 ? @"\N" : Lay2Vol.ToString())
            + "," + (Lay3 == 0 ? @"\N" : Lay3.ToString())
            + "," + (Lay3Vol == 0 ? @"\N" : Lay3Vol.ToString())
            + "," + (Trade ? "1" : "0")
            + "," + (LastTradedPrice == 0 ? @"\N" : LastTradedPrice.ToString())
            + "," + CumulTradedVolSelection.ToString()
            + "," + CumulTradedVolMarket.ToString()
            + "," + (BecomesNonRunner ? "1" : "0")
            + "," + (ReductionFactorToApply > 0 ? ReductionFactorToApply.ToString() : @"\N")
            + "," + (Midpoint == 0 ? @"\N" : Midpoint.ToString())
            + "," + (WeightedAverage == 0 ? @"\N" : WeightedAverage.ToString())
            );
 }
コード例 #3
0
        /// <summary>
        /// Determines whether the specific catalog entry is available in market
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <param name="currentMarketId">The current market id.</param>
        /// <returns>
        ///   <c>true</c> if [is available in market] [the specified entry]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsAvailableInMarket(this Entry entry, MarketId currentMarketId)
        {
            var excludedCatalogEntryMarkets = entry.ItemAttributes["_ExcludedCatalogEntryMarkets"].Value;

            if (excludedCatalogEntryMarkets == null)
            {
                return(true);
            }
            return(!excludedCatalogEntryMarkets.Contains(currentMarketId.ToString()));
        }
コード例 #4
0
        IEnumerable <Instrument> GetContracts(MarketId market, ProductType productType, string productCode)
        {
            InstrumentCatalog instruments = new InstrumentCatalog(market, productType, productCode, _dispatcher);
            ProductDataEvent  e           = instruments.Get();

            var subscriptionDetails = $"{market.ToString()} : {productType.ToString()} : {productCode}";

            if (e == ProductDataEvent.Found)
            {
                _log.Info($"Fetched instrument count for '{productCode}': {subscriptionDetails} : {instruments.InstrumentList.Count()}");
                return(instruments.InstrumentList);
            }
            else
            {
                _log.Error($"Failed to fetch intruments for: {subscriptionDetails}");
                return(Enumerable.Empty <Instrument>());
            }
        }
コード例 #5
0
        /// <summary>
        /// Constructs parameters to be sent as part of a request to Cryptsy.
        /// </summary>
        /// <param name="method">The API method to call</param>
        /// <param name="marketId">An optional market ID to be passsed as a parameter to the method</param>
        /// <returns>An array of key-value pairs</returns>
        private KeyValuePair <string, string>[] GenerateOrderParameters(CryptsyMethod method,
                                                                        MarketId marketId, OrderType orderType, decimal quantity, decimal price)
        {
            List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>(PARAM_METHOD, System.Enum.GetName(typeof(CryptsyMethod), method)),
                new KeyValuePair <string, string>(PARAM_NONCE, GetNextNonce()),
                new KeyValuePair <string, string>(PARAM_ORDER_TYPE, orderType.ToString()),
                new KeyValuePair <string, string>(PARAM_QUANTITY, quantity.ToString()),
                new KeyValuePair <string, string>(PARAM_PRICE, price.ToString())
            };

            if (null != marketId)
            {
                parameters.Add(new KeyValuePair <string, string>(PARAM_MARKET_ID, marketId.ToString()));
            }

            return(parameters.ToArray());
        }
コード例 #6
0
        public string[] ToJQueryDataTableResult()
        {
            var url = new UrlHelper(HttpContext.Current.Request.RequestContext);

            return(new[]
            {
                FdpPublishId.GetValueOrDefault().ToString(),
                MarketId.ToString(),
                PublishOn.GetValueOrDefault().ToString("dd/MM/yyyy"),
                PublishBy,
                Programme.GetDisplayString(),
                Document.Gateway,
                Document.VersionLabel,
                Document.Status,
                MarketName,
                Comment,
                url.RouteUrl("TakeRateDataByMarket", new { takeRateId = FdpVolumeHeaderId, marketId = MarketId })
            });
        }
コード例 #7
0
 public override string ToString()
 {
     return(EventId.ToString()
            + "," + MarketId.ToString()
            + "," + (MeetingDate > DateTime.MinValue ? MeetingDate.ToString("yyyy-MM-dd") : @"\N")
            + "," + DayOfWeek.ToString()
            + "," + CountryCode.ToString()
            + "," + Track.ToString()
            + "," + (RaceTime > DateTime.MinValue ? RaceTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N")
            + "," + (OffTime > DateTime.MinValue ? OffTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N")
            + "," + MarketName.ToString()
            + "," + Entries.ToString()
            + "," + Runners.ToString()
            + "," + SelectionId.ToString()
            + "," + SelectionName.ToString()
            + "," + (Bsp > 1 ? Bsp.ToString() : @"\N")
            + "," + (NonRunner ? "1" : "0")
            + "," + (RemovalTime > DateTime.MinValue ? RemovalTime.ToString("yyyy-MM-dd HH:mm:ss") : @"\N")
            + "," + (NonRunner ? ReductionFactor.ToString() : @"\N")
            );
 }
コード例 #8
0
 private string GetMarketUrl(MarketId marketId)
 {
     return(this.BaseUrl + "market/"
            + Uri.EscapeUriString(marketId.ToString()) + "/");
 }