Пример #1
0
        public async Task <List <Balance> > GetBalances()
        {
            var exchanges = new Exchanges();
            var balances  = await exchanges.GetBalances();

            return(balances);
        }
Пример #2
0
 /// <summary>
 ///     Constructor
 /// </summary>
 public Order(bool error)
 {
     if (error == true)
     {
         cryptoTrader    = new My_CryptoTrader.My_CryptoTrader();
         this.exchange   = Exchanges.BITTREX;
         this.side       = OrderType.BUY;
         this.style      = OrderStyle.LIMIT;
         this.success    = false;
         this.ccyPair    = MainCryptos.USDT;
         this.ccyBase    = MainCryptos.BTC;
         this.amount     = 0;
         this.orderPrice = new Price(error: true);
         this.message    = "ERROR";
         this.ID         = "ERROR";
         this.valueBTC   = 0;
         this.valueUSD   = 0;
     }
     else
     {
         cryptoTrader    = new My_CryptoTrader.My_CryptoTrader();
         this.exchange   = Exchanges.BITTREX;
         this.side       = OrderType.BUY;
         this.style      = OrderStyle.LIMIT;
         this.success    = false;
         this.ccyPair    = MainCryptos.USDT;
         this.ccyBase    = MainCryptos.BTC;
         this.amount     = 0;
         this.orderPrice = new Price(error: true);
         this.message    = "";
         this.ID         = "";
         this.valueBTC   = 0;
         this.valueUSD   = 0;
     }
 }
Пример #3
0
        public static void SaveExchange(Exchanges exc, string value)
        {
            dc = ApplicationData.Current.LocalSettings;
            switch (exc)
            {
            case Exchanges.EurPnd:
                dc.Values[KEY_EURPND] = value;
                break;

            case Exchanges.EurDol:
                dc.Values[KEY_EURDOL] = value;
                break;

            case Exchanges.EurYen:
                dc.Values[KEY_EURYEN] = value;
                break;

            case Exchanges.PndDol:
                dc.Values[KEY_PNDDOL] = value;
                break;

            case Exchanges.DolYen:
                dc.Values[KEY_DOLYEN] = value;
                break;

            case Exchanges.PndYen:
                dc.Values[KEY_PNDYEN] = value;
                break;
            }
        }
Пример #4
0
        public async Task <Dictionary <string, Yield> > GetCoinYield()
        {
            var exchanges = new Exchanges();
            var yield     = await exchanges.GetCoinYield();

            return(yield);
        }
Пример #5
0
        public async Task <decimal> GetEntryValue()
        {
            var exchanges = new Exchanges();
            var value     = await exchanges.GetEntryValue();

            return(value);
        }
Пример #6
0
        public void addIndicator(Exchanges selectedExchange, Coins selectedCoin, Coins selectedPairing, CandleWidth selectedWidth, Indicators selectedIndicator, IndicatorConditions selectedCondition, double value)
        {
            foreach (AlertLayout l in listCellCoin.Children)                                               //in every current layout
            {
                if (l.Coin == selectedCoin && l.Pair == selectedPairing && l.Exchange == selectedExchange) // if layout exists with params
                {
                    foreach (AlertCard c in l.CardGrid.Children)                                           //search for card with same indicator exists
                    {
                        if (c.Indicator == selectedIndicator && c.CandleWidth == selectedWidth)            //if card with same indicator and candle width exists
                        {
                            c.addCondition(selectedCondition, value);                                      //just needed to add condition, else it is a new card
                            return;
                        }
                    }
                    //indicator was not found in card list, need to create new one
                    AlertCard _card = new AlertCard(l, selectedWidth, selectedExchange, selectedCoin, selectedPairing, selectedIndicator);
                    _card.addCondition(selectedCondition, value);
                    l.addTo(_card);
                    return;
                }
            }

            AlertLayout alert = new AlertLayout(selectedExchange, selectedCoin, selectedPairing);
            AlertCard   card  = new AlertCard(alert, selectedWidth, selectedExchange, selectedCoin, selectedPairing, selectedIndicator);

            card.addCondition(selectedCondition, value);
            alert.addTo(card);
            listCellCoin.Children.Add(alert);
            reSize();
        }
Пример #7
0
        public async Task <List <Transaction> > RecentTransactions()
        {
            var exchanges    = new Exchanges();
            var transactions = await exchanges.GetRecentBinanceTransactions();

            return(transactions);
        }
Пример #8
0
        /// <summary>
        ///     Function that cancel an order placed on bittrex markets,
        ///     identified with its <paramref name="orderId"/>
        /// </summary>
        /// <param name="orderId">the ID of the order to cancel.</param>
        /// <returns>
        ///     a <see cref="Order"/> object, representing the cancelled order
        /// </returns>
        override public Order CancelOrder(string currency, string orderId)
        {
            BittrexSharp.ResponseWrapper <object> responseCancelOrder;
            object      canceledOrder;
            OrderType   oneOrderType  = OrderType.CANCEL;
            OrderStyle  oneOrderStyle = OrderStyle.CANCELLATION;
            Exchanges   oneExchange   = Exchanges.BINANCE;
            MainCryptos ccyBase       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());
            MainCryptos ccyPair       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());;

            Order oneNewOrder = new Order(oneExchange, oneOrderType, oneOrderStyle, false, ccyBase, ccyPair, 0, 0);

            try
            {
                responseCancelOrder = this.my_bittrex.CancelOrder(orderId).Result;
                canceledOrder       = this.my_bittrex.CancelOrder(orderId).Result;
                oneNewOrder.message = responseCancelOrder.Message;
                oneNewOrder.success = responseCancelOrder.Success;

                return(oneNewOrder);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                oneNewOrder.message = "ERROR";
                oneNewOrder.success = false;
                return(oneNewOrder);
            }
        }
Пример #9
0
        private void listExchange_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((ListBox)e.Source).SelectedItem != null)
            {
                Exchanges ex = (Exchanges)Enum.Parse(typeof(Exchanges), (string)((ImageTextItem)((ListBox)e.Source).SelectedItem).text.Content);
                if (ex == Exchanges.Binance)
                {
                    selectedExchange = ex;
                    exchange         = binance;
                }

                List <ImageTextItem> list = null;

                if (list == null || list.Count == 0)
                {
                    list = exchange.GetPairList();
                }

                listPairing.ItemsSource = null;
                listPairing.ItemsSource = list;

                gridPairing.Visibility = Visibility.Visible;
                initSelectionCondition();
            }
        }
Пример #10
0
        /// <summary>
        ///     Function that send an order to <paramref name="side"/>.
        ///     The order is for <paramref name="amount"/> <paramref name="currency"/>,
        ///     at a limit price of <paramref name="price"/>, to bitfinex market
        ///     <paramref name="currency"/> have to be in <see cref="MainCryptos"/>
        ///     <paramref name="amount"/> have to be positive
        ///     <paramref name="price"/> have to be positive
        /// </summary>
        /// <param name="currency">the name of the cryptocurrency.</param>
        /// <param name="amount">amount to buy.</param>
        /// <param name="price">limit price of the order.</param>
        /// <returns>
        ///     A <see cref="Order"/> object, representing the new order that has been send to Bitfinex market
        /// </returns>
        override public Order NewOrder(string currency, double amount, double price, string side)
        {
            OrderType   oneOrderType  = (OrderType)Enum.Parse(typeof(OrderType), side.ToUpper());
            OrderStyle  oneOrderStyle = OrderStyle.LIMIT;
            Exchanges   oneExchange   = Exchanges.BITFINEX;
            MainCryptos ccyBase       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());
            MainCryptos ccyPair;
            Order       oneNewOrder;
            string      message = "";
            string      completeUrl;
            string      market;

            this.nonce    = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();
            this.endpoint = "order/new";
            completeUrl   = this.apiV1 + this.endpoint;
            this.request  = new HttpRequestMessage(HttpMethod.Post, completeUrl);

            if (ccyBase != MainCryptos.BTC)
            {
                market  = currency.ToUpper() + "BTC";
                ccyPair = MainCryptos.BTC;
            }
            else
            {
                market  = currency.ToUpper() + "USD";
                ccyPair = MainCryptos.USDT;
            }

            oneNewOrder = new Order(oneExchange, oneOrderType, oneOrderStyle, false, ccyBase, ccyPair, amount, price);

            this.body.Clear();
            this.body.Add("request", "/v1/order/new");
            this.body.Add("nonce", nonce.ToString());
            this.body.Add("symbol", market);
            this.body.Add("amount", oneNewOrder.amount.ToString());
            this.body.Add("price", oneNewOrder.orderPrice.price.ToString("F5"));
            this.body.Add("exchange", oneNewOrder.exchange.ToString().ToLower());
            this.body.Add("side", oneNewOrder.side.ToString().ToLower());
            this.body.Add("type", "exchange market");

            this.setRequestHeaders(this.body);

            this.response        = this.client.SendAsync(this.request).Result;
            this.jStringResponse = this.response.Content.ReadAsStringAsync().Result;

            this.requestResponse = JsonConvert.DeserializeObject <Dictionary <dynamic, dynamic> >(this.jStringResponse);

            if (this.requestResponse.ContainsKey("message"))
            {
                message             = this.requestResponse["message"];
                oneNewOrder.success = false;
                oneNewOrder.message = message;
            }
            else
            {
                oneNewOrder.success = true;
            }

            return(oneNewOrder);
        }
Пример #11
0
        public async Task <Dictionary <string, List <Trade> > > GetTrades()
        {
            var exchanges = new Exchanges();
            var trades    = await exchanges.GetTrades();

            return(trades);
        }
Пример #12
0
        public async Task <BinanceAccountInfo> AccountInfo()
        {
            var exchanges   = new Exchanges();
            var accountInfo = await exchanges.GetAccountInfo();

            return(accountInfo);
        }
Пример #13
0
        public void Produce(Exchanges exchangeName, string message, string bindingKey)
        {
            if (!Connect())
            {
                throw new Exception("Connection failed!");
            }

            var exName = exchangeName.ToString();

            if (!string.IsNullOrEmpty(exName))
            {
                Channel.ExchangeDeclare(exName, ExchangeTypeName, false, false, null);
            }

            var properties = Channel.CreateBasicProperties();

            properties.DeliveryMode = 2;

            properties.ContentType = "application/json";
            var binaryMessage = Encoding.UTF8.GetBytes(message);

            lock (Channel)
            {
                Channel.BasicPublish(exName, bindingKey, properties, binaryMessage);
            }
        }
Пример #14
0
        public void Consume(Exchanges exchangeName, Action <object, string> messageHandler, params string[] bindingKeys)
        {
            if (!Connect())
            {
                throw new Exception("Connection failed!");
            }

            string exName = exchangeName.ToString();

            Channel.ExchangeDeclare(exName, ExchangeTypeName, false, false, null);
            string queueName = $"{exchangeName.ToString()}_{string.Join("_", bindingKeys)}_{Guid.NewGuid()}";

            queueName = (queueName.Length > 255 ? queueName.Substring(0, 254) : queueName);
            var queue = Channel.QueueDeclare(queueName, false, false, true, _args);

            string[] strArrays = bindingKeys;

            for (int i = 0; i < (int)strArrays.Length; i++)
            {
                string bindingKey = strArrays[i];
                Channel.QueueBind(queue.QueueName, exName, bindingKey, null);
            }

            var consumer = new EventingBasicConsumer(Channel);

            Channel.ContinuationTimeout = TimeSpan.FromSeconds(20);
            consumer.Received          += (model, ea) => messageHandler(model, Encoding.UTF8.GetString(ea.Body));
            Channel.BasicConsume(queue.QueueName, true, consumer);
        }
Пример #15
0
        public ExchangesViewModel()
        {
            Exchanges = DbContext.Exchanges.ToList();


            FilteredExchanges = new ReactiveList <Exchange>(Exchanges.OrderBy(x => x.Name));
            SelectedExchange  = Exchanges.First();
            var canExecute = this.WhenAny(x => x.SelectedExchange, x => x.Value != null);

            AddCommand    = ReactiveCommand.Create(Add);
            DeleteCommand = ReactiveCommand.Create(Delete, canExecute);
            EditCommand   = ReactiveCommand.Create(Modify, canExecute);
            var canSearch = this.WhenAny(x => x.SearchBoxText,
                                         x => !string.IsNullOrWhiteSpace(x.Value));

            this.WhenAnyObservable(x => x.FilteredExchanges.ItemsAdded)
            .Subscribe(async item => { await ItemsAddedTask(item); });

            this.WhenAnyObservable(x => x.FilteredExchanges.ItemsRemoved)
            .Subscribe(async item => { await ItemsRemovedTask(item); });


            DeleteCommand = ReactiveCommand.Create(() => { FilteredExchanges.Remove(SelectedExchange); });

            SearchCommand = ReactiveCommand.Create(Search, canSearch);

            this.WhenAny(x => x.SearchBoxText, x => x.Value)
            .Subscribe(text => { SearchCommand.Execute(); });
        }
Пример #16
0
        protected virtual void InitializeExchangesEdit()
        {
            Exchanges.Add(new FondExchangeInfo()
            {
                Name = "NYSE", Currency = TickerCurrency.USD
            });
            Exchanges.Add(new FondExchangeInfo()
            {
                Name = "NASDAQ", Currency = TickerCurrency.USD
            });
            Exchanges.Add(new FondExchangeInfo()
            {
                Name = "Xetra", Currency = TickerCurrency.EURO
            });
            Exchanges.Add(new FondExchangeInfo()
            {
                Name = "MOEX", Currency = TickerCurrency.RUB
            });
            Exchanges.Add(new FondExchangeInfo()
            {
                Name = "SPB", Currency = TickerCurrency.RUB
            });

            ExchangeTextEdit.Properties.DisplayMember = "Name";
            ExchangeTextEdit.Properties.ValueMember   = "Name";
            ExchangeTextEdit.Properties.DataSource    = Exchanges;
            ExchangeTextEdit.EditValueChanged        += ExchangeTextEdit_EditValueChanged;
        }
Пример #17
0
        public AlertLayout(Exchanges Exchange, Coins Coin, Coins Pair)
        {
            childList = new List <AlertCard>();
            InitializeComponent();

            this.Exchange = Exchange;
            this.Coin     = Coin;
            this.Pair     = Pair;

            Header.alert    = this;
            Header.Exchange = Exchange;
            Header.Symbol   = Coin.ToString() + Pair.ToString();

            if (Exchange == Exchanges.Binance)
            {
                Binance b = Binance.Instance;
                exchangeIF = b;
            }

            /*AlertCard card = new AlertCard();
             * card.KlineWidth = KLineWidth.m5;
             * card.Indicator = Indicators.RSI;
             * card.Coin = Coins.ETH;
             * card.Pair = Coins.BTC;
             * this.addTo(card);*/
        }
Пример #18
0
 public void Initialize(List <string> exchanges)
 {
     foreach (var exchange in exchanges)
     {
         Exchanges.Add(exchange);
     }
 }
 public AccountBalancesForm(Exchange exchange)
 {
     InitializeComponent();
     Text     = exchange.Name + " Account Balances";
     Exchange = exchange;
     Exchanges.Add(Exchange);
     UpdateFilter();
 }
Пример #20
0
 public static string ToDescriptionString(this Exchanges val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val
                                         .GetType()
                                         .GetField(val.ToString())
                                         .GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }
Пример #21
0
 public Publisher(IBus bus, ILogger <Publisher> logger,
                  IOptions <Exchanges> exchanges, IOptions <Routings> routings)
 {
     _advancedBus = bus.Advanced;
     _logger      = logger;
     _exchanges   = exchanges.Value;
     _routings    = routings.Value;
 }
Пример #22
0
 public ICryptoExchange this [CryptoExchangeId index]
 {
     get
     {
         Exchanges.TryGetValue(index, out var exchange);
         return(exchange);
     }
 }
Пример #23
0
        /// <summary>
        ///     Function that cancel an order placed on cex.IO markets,
        ///     identified with its <paramref name="orderId"/>
        /// </summary>
        /// <param name="orderId">the ID of the order to cancel.</param>
        /// <returns>
        ///     a <see cref="Order"/> object, representing the cancelled order
        /// </returns>
        override public Order CancelOrder(string currency, string orderId)
        {
            string      queryJson = "";
            string      stringResponse;
            OrderType   oneOrderType  = OrderType.CANCEL;
            OrderStyle  oneOrderStyle = OrderStyle.CANCELLATION;
            Exchanges   oneExchange   = Exchanges.BINANCE;
            MainCryptos ccyBase       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());
            MainCryptos ccyPair       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());;

            Order oneNewOrder = new Order(oneExchange, oneOrderType, oneOrderStyle, false, ccyBase, ccyPair, 0, 0);

            this.nonce = DateTimeOffset.Now.ToUnixTimeSeconds();

            this.endpoint = "cancel_order/";

            this.httpRequest = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, this.api + this.endpoint);

            this.hexHash = this.getSignature(this.nonce);

            this.bodyRequest.Clear();

            this.bodyRequest.Add("key", this.apiKey);
            this.bodyRequest.Add("signature", this.hexHash);
            this.bodyRequest.Add("nonce", this.nonce.ToString());
            this.bodyRequest.Add("id", orderId);

            queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(this.bodyRequest);

            this.httpRequest.Content = new System.Net.Http.StringContent(queryJson, System.Text.Encoding.UTF8, "application/json");

            this.httpRequest.Content.Headers.Add("key", this.apiKey);
            this.httpRequest.Content.Headers.Add("signature", this.hexHash);
            this.httpRequest.Content.Headers.Add("nonce", this.nonce.ToString());
            this.httpRequest.Content.Headers.Add("currency", currency);

            this.httpResponse = this.httpClient.SendAsync(this.httpRequest).Result;
            stringResponse    = this.httpResponse.Content.ReadAsStringAsync().Result;

            try
            {
                this.responseRequest = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <dynamic, dynamic> >(stringResponse);
                oneNewOrder.message  = this.responseRequest["data"];
                oneNewOrder.success  = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                this.responseRequest = new Dictionary <dynamic, dynamic>()
                {
                    { "ERROR", "ERROR" }
                };
                oneNewOrder.message = "ERROR";
                oneNewOrder.success = false;
            }

            return(oneNewOrder);
        }
Пример #24
0
        /// <summary>
        ///     Function that send <paramref name="amount"/> <paramref name="currency"/>,
        ///     to the specified <paramref name="adress"/>
        ///     <paramref name="currency"/> have to be in <see cref="MainCryptos"/>
        ///     <paramref name="amount"/> have to be positive
        /// </summary>
        /// <param name="currency">the name of the cryptocurrency.</param>
        /// <param name="amount">amount to buy.</param>
        /// <param name="currency">the crypto currency to send.</param>
        /// <returns>
        ///     A <see cref="Order"/> object representing the sending.
        /// </returns>
        override public Order SendCryptos(string adress, string currency, double amount)
        {
            OrderType   oneOrderType  = OrderType.SEND;
            OrderStyle  oneOrderStyle = OrderStyle.WITHDRAWAL;
            Exchanges   oneExchange   = Exchanges.BINANCE;
            MainCryptos ccyBase       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());
            MainCryptos ccyPair       = (MainCryptos)Enum.Parse(typeof(MainCryptos), currency.ToUpper());
            Order       oneNewOrder;
            string      stringResponse = "";

            oneNewOrder = new Order(oneExchange, oneOrderType, oneOrderStyle, false, ccyBase, ccyPair, amount, 0);

            this.endpoint    = "wapi/v3/withdraw.html";
            this.queryString = "";
            this.bodyRequest.Clear();

            this.bodyRequest.Add("asset", currency);
            this.bodyRequest.Add("address", adress);
            this.bodyRequest.Add("amount", amount.ToString());
            this.bodyRequest.Add("recvWindow", 1000000.ToString());
            this.bodyRequest.Add("timestamp", (DateTimeOffset.Now.ToUnixTimeMilliseconds()).ToString());

            foreach (KeyValuePair <string, string> row in this.bodyRequest)
            {
                this.queryString += row.Key + "=" + row.Value + "&";
            }
            this.queryString = this.queryString.Substring(0, this.queryString.Length - 1);

            this.hexHash = Tools.byteToString(hasher.ComputeHash(System.Text.Encoding.UTF8.GetBytes(queryString))).ToLower();

            this.queryString += "&signature=" + this.hexHash;

            this.httpRequest = new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Post, this.api + this.endpoint + "?" + this.queryString);

            this.httpRequest.Headers.Add("X-MBX-APIKEY", this.api_key);

            this.httpResponse = this.httpClient.SendAsync(this.httpRequest).Result;

            stringResponse = this.httpResponse.Content.ReadAsStringAsync().Result;

            this.responseRequest = JsonConvert.DeserializeObject <Dictionary <dynamic, dynamic> >(stringResponse);

            if (this.responseRequest.ContainsKey("success"))
            {
                oneNewOrder.success = this.responseRequest["success"];
            }
            else
            {
                oneNewOrder.success = false;
            }

            if (this.responseRequest.ContainsKey("msg"))
            {
                oneNewOrder.message = this.responseRequest["msg"];
            }

            return(oneNewOrder);
        }
Пример #25
0
        public async Task <Dictionary <string, Dictionary <string, decimal> > > GetPriceAtTime([FromQuery] string symbol, [FromQuery] int timestamp)
        {
            var            time      = epoch.AddSeconds(timestamp);
            DateTimeOffset offset    = DateTime.SpecifyKind(time, DateTimeKind.Utc);
            var            exchanges = new Exchanges();
            var            price     = await exchanges.GetPriceAtTime(symbol, offset);

            return(price);
        }
Пример #26
0
 public QueueProvider(IBus bus, ILogger <QueueProvider> logger,
                      IOptions <Exchanges> exchanges, IOptions <Queues> queues, IOptions <Routings> routings)
 {
     _advancedBus = bus.Advanced;
     _logger      = logger;
     _exchanges   = exchanges.Value;
     _queues      = queues.Value;
     _routings    = routings.Value;
 }
Пример #27
0
        private async Task HandleSubscribe(Message message, IList <string> @params)
        {
            // Check exchange name
            var chosen = @params
                         .Where(x => GetExchangeBase(x) != null)
                         .Select(GetExchangeBase)
                         .FirstOrDefault( );

            if (chosen == null)
            {
                await SendBlockText(message, "No exchanges provided.").ConfigureAwait(false);
                await SendBlockText(message,
                                    "Supported Exchanges:\n" +
                                    $"{Exchanges.Select ( e => e.Value.Name ).Join ( "\n" )}"
                                    ).ConfigureAwait(false);

                return;
            }

            // Check threshold value
            var threshold       = 0.05m;
            var thresholdString = @params
                                  .FirstOrDefault(x => decimal.TryParse(x.Trim('%'), out var _));

            if (!string.IsNullOrEmpty(thresholdString))
            {
                threshold = decimal.Parse(thresholdString) / 100m;
            }
            else
            {
                await SendBlockText(message, $"No threshold provided, setting to default {threshold:P}")
                .ConfigureAwait(false);
            }

            // Check coin symbols
            var supported = CryptoTickerBotCore.SupportedCoins;
            var coinIds   = supported
                            .Where(x => @params.Any(
                                       c => c.Equals(x.Symbol, StringComparison.InvariantCultureIgnoreCase)
                                       )
                                   )
                            .Select(x => x.Id)
                            .ToList( );

            if (coinIds.Count == 0)
            {
                await SendBlockText(
                    message,
                    "No coin symbols provided. Subscribing to all coin notifications."
                    ).ConfigureAwait(false);

                coinIds = supported.Select(x => x.Id).ToList( );
            }

            await AddSubscription(message, chosen, threshold, coinIds).ConfigureAwait(false);
        }
Пример #28
0
        /// <summary>
        ///     Function returning all open orders (BUY or SELL) placed on any crypto currencies
        ///     <paramref name="currency"/> have to be in <see cref="MainCryptos"/>
        /// </summary>
        /// <returns>
        ///     a List of <see cref="Order"/>, representing all open orders
        /// </returns>
        override public List <Order> GetOpenOrders(string currency)
        {
            OrderType    oneOrderType;
            OrderStyle   oneOrderStyle = OrderStyle.LIMIT;
            Exchanges    oneExchange   = Exchanges.BITFINEX;
            MainCryptos  ccyBase;
            MainCryptos  ccyPair;
            double       amount;
            double       orderPrice;
            List <Order> orderList = new List <Order>();
            Order        oneNewOrder;
            Dictionary <dynamic, dynamic> newBody = new Dictionary <dynamic, dynamic>();

            this.endpoint = "orders";
            string completeUrl = this.apiV1 + this.endpoint;

            this.request = new HttpRequestMessage(HttpMethod.Post, completeUrl);
            this.nonce   = DateTimeOffset.Now.ToUnixTimeSeconds().ToString();

            this.request = new HttpRequestMessage(HttpMethod.Post, completeUrl);

            this.body.Clear();
            this.body.Add("request", "/v1/" + this.endpoint);
            this.body.Add("nonce", nonce.ToString());

            this.setRequestHeaders(this.body);

            this.response        = this.client.SendAsync(this.request).Result;
            this.jStringResponse = this.response.Content.ReadAsStringAsync().Result;

            try
            {
                if (this.jStringResponse != "[]")
                {
                    this.requestResponse = JsonConvert.DeserializeObject <Dictionary <dynamic, dynamic> >(this.jStringResponse);

                    if (this.requestResponse.ContainsKey("message"))
                    {
                        oneNewOrder         = new Order(error: true);
                        oneNewOrder.message = this.requestResponse["message"];
                    }
                }
                else
                {
                    oneNewOrder         = new Order(error: true);
                    oneNewOrder.message = "NO OPEN ORDERS";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                oneNewOrder = new Order(error: true);
            }

            return(orderList);
        }
Пример #29
0
        public async Task <IActionResult> SVGIntercept(string filename)
        {
            var symbol = filename.ToLower().Replace(".svg", "").ToUpper();

            var exchanges = new Exchanges();
            var chart     = await exchanges.GetChart(symbol);


            return(File(chart, "image/svg+xml"));
        }
Пример #30
0
        private void LoadSymbols()
        {
            var symbols = Serializer.GetConfiguration <List <string> >(ConfigurationFileNames.ValidStocks);
            var groupy  = symbols.GroupBy(s => s.Split(':')[0]);

            _allInstruments = groupy.ToDictionary(k => k.Key, v => v.Select(s => s.Split(':')[1]).OrderBy(s => s).ToList());

            Exchanges = _allInstruments.Select(s => s.Key).ToList();
            Exchange  = Exchanges.FirstOrDefault();
        }
Пример #31
0
 public object Get(Exchanges request)
 {
     return request.UserIds.IsEmpty()
                ? Repository.GetAll()
                : Repository.GetByUserIds(request.UserIds);
 }