private void CreateConnection(CurrencyName instrument) { var config = (BotcoinConfigSection)ConfigurationManager.GetSection("botcoin"); var connection = config.FindConnectionElement("RestScheduler"); var strAddr = String.Format(connection.DomainName, instrument.ToString().ToLower()); var ipAddr = Dns.GetHostEntry(strAddr).AddressList.Where(a => a.AddressFamily == AddressFamily.InterNetwork).First(); _log.WriteInfo(String.Format("{0} subscribed", instrument.ToString())); _connections.Add(new Tuple <CurrencyName, IPEndPoint>(instrument, new IPEndPoint(ipAddr, connection.Port))); }
public BudgetInfo(DateTime period, double amount, CurrencyName currency, double percentage) { Period = string.Format("{0:MM/yyyy}", period); Amount = Math.Round(amount, 2); Currency = currency.ToString(); Percentage = Math.Round(percentage, 2); }
public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit) { QuadrigaOrderResponse response = null; string path = side == OrderSide.BID ? "buy" : "sell"; string book = currency.ToString().ToLower() + "_cad"; if (type == TradeOrderType.Limit) { response = _client.PlaceLimitOrder(path, amount, book, price); } else if (type == TradeOrderType.Market) { response = _client.PlaceMarketOrder(path, amount, book, price); } else { throw new ArgumentException("Invalid order type"); } return(response.Error == null ? new OrderResponse(response.Datetime, response.OrderId) : new OrderResponse() { ErrorReason = response.Error.Message }); }
public override OrderResponse PlaceOrder(double price, double amount, CurrencyName inst, OrderSide side, TradeOrderType type = TradeOrderType.Limit) { BitstampOrderResponse response = null; var symbol = inst.ToString().ToLower() + "usd"; if (type == TradeOrderType.Limit) { response = Client.PlaceLimitOrder(side == OrderSide.BID ? "buy" : "sell", symbol, amount, price); } else { throw new ArgumentException("[Bitstamp] Invalid order type"); } if (String.Compare(response.Status, "error", true) != 0) { return(new OrderResponse(response.Datetime, response.OrderId)); } var str = new StringBuilder("[Bitstamp] PlaceOrder"); foreach (var error in response.Reason.All) { str.AppendFormat(" {0}", error); } return(new OrderResponse() { ErrorReason = str.ToString() }); }
public void SubscribeTrade(CurrencyName instrument1, EventHandler <TradeEventArgs> handler = null, CurrencyName instrument2 = CurrencyName.USDT) { if (handler != null) { if (instrument1 == CurrencyName.BTC) { _btcTradeHandler += handler; } if (instrument1 == CurrencyName.BCH) { _bchTradeHandler += handler; } if (instrument1 == CurrencyName.LTC) { _ltcTradeHandler += handler; } if (instrument1 == CurrencyName.ETH) { _ethTradeHandler += handler; } if (instrument1 == CurrencyName.XRP) { _xrpTradeHandler += handler; } } var channelName = String.Format(TradeChannel, instrument1.ToString().ToLower(), instrument2.ToString().ToLower()); SendMessage(c => c.Send("{'event':'addChannel'," + channelName + "}")); }
private void UnsubscribeTrade(CurrencyName instrument1, EventHandler <TradeEventArgs> handler, CurrencyName instrument2 = CurrencyName.USDT) { if (instrument1 == CurrencyName.BTC) { _btcTradeHandler -= handler; } if (instrument1 == CurrencyName.BCH) { _bchTradeHandler -= handler; } if (instrument1 == CurrencyName.LTC) { _ltcTradeHandler -= handler; } if (instrument1 == CurrencyName.ETH) { _ethTradeHandler -= handler; } if (instrument1 == CurrencyName.XRP) { _xrpTradeHandler -= handler; } var channelName = String.Format(TradeChannel, instrument1.ToString().ToLower(), instrument2.ToString().ToLower()); SendMessage(c => c.Send("{'event':'removeChannel'," + channelName + "}")); }
public void SubscribeOrderBook(CurrencyName instrument1, EventHandler <OrderBookEventArgs> handler = null, CurrencyName instrument2 = CurrencyName.USDT) { string channelName = null; if (handler != null) { if (instrument1 == CurrencyName.BTC) { _btcOrderBookHandler += handler; } else if (instrument1 == CurrencyName.BCH) { _bchOrderBookHandler += handler; } else if (instrument1 == CurrencyName.LTC) { _ltcOrderBookHandler += handler; } else if (instrument1 == CurrencyName.ETH) { _ethOrderBookHandler += handler; } else if (instrument1 == CurrencyName.IOTA) { _iotaOrderBookHandler += handler; } } channelName = String.Format(OrderBookChannel, instrument1.ToString(), instrument2.ToString()).ToLower(); SendMessage(c => c.Send("{'event':'addChannel'," + channelName + "}")); }
public void UnsubscribeOrderBook(CurrencyName instrument1, EventHandler <OrderBookEventArgs> handler, CurrencyName instrument2 = CurrencyName.USDT) { if (instrument1 == CurrencyName.BTC) { _btcOrderBookHandler -= handler; } if (instrument1 == CurrencyName.BCH) { _bchOrderBookHandler -= handler; } if (instrument1 == CurrencyName.LTC) { _ltcOrderBookHandler -= handler; } if (instrument1 == CurrencyName.ETH) { _ethOrderBookHandler -= handler; } if (instrument1 == CurrencyName.IOTA) { _iotaOrderBookHandler -= handler; } var channelName = String.Format(OrderBookChannel, instrument1.ToString().ToLower(), instrument2.ToString().ToLower()); SendMessage(c => c.Send("{'event':'removeChannel'," + channelName + "}")); }
public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, DataType.OrderSide orderSide, TradeOrderType type = TradeOrderType.Limit) { if (!(currency == CurrencyName.BTC || currency == CurrencyName.BCH || currency == CurrencyName.ETH || currency == CurrencyName.LTC)) { return(new OrderResponse { ErrorReason = "Invalid instrument" }); } var currencyName = currency.ToString(); if (currency == CurrencyName.BCH) { currencyName = "BCC"; } var symbol = currencyName + "USDT"; var side = orderSide == DataType.OrderSide.BID ? Binance.Net.Objects.OrderSide.Buy : Binance.Net.Objects.OrderSide.Sell; //"LIMIT", "LIMIT_MAKER", "MARKET", "STOP_LOSS_LIMIT", "TAKE_PROFIT_LIMIT" var result = _client.PlaceOrder(symbol, side, OrderType.Limit, TimeInForce.GoodTillCancel, amount, price); return(result.Success ? new OrderResponse(result.Data.TransactTime, result.Data.OrderId.ToString()) : new OrderResponse { ErrorReason = result.Error.Message, ErrorCode = result.Error.Code }); }
private void CreateConnection(CurrencyName instrument) { var config = (BotcoinConfigSection)ConfigurationManager.GetSection("botcoin"); var connection = config.FindConnectionElement("RestScheduler"); #if true var subDomainName = instrument.ToString().ToLower(); if (Dns.Resolve(Dns.GetHostName()).AddressList[0].ToString() == "185.226.113.60") { subDomainName += "-test"; } #endif var strAddr = String.Format("{0}.{1}", subDomainName, connection.DomainName); var ipAddr = Dns.GetHostEntry(strAddr).AddressList.Where(a => a.AddressFamily == AddressFamily.InterNetwork).First(); _log.WriteInfo(String.Format("{0} subscribed", instrument.ToString())); _connections.Add(new Tuple <CurrencyName, IPEndPoint>(instrument, new IPEndPoint(ipAddr, connection.Port))); }
public override OrderResponse PlaceOrder(double price, double amount, CurrencyName currency, OrderSide side, TradeOrderType type = TradeOrderType.Limit) { string market = currency.ToString().ToLower() + "uah"; var order = _client.PlaceOrder(market, side == OrderSide.BID ? "buy" : "sell", amount, price); return(order.Error == null ? new OrderResponse(order.CreatedAt, order.Id) : new OrderResponse { ErrorReason = order.Error.Message }); }
public KunaOrdersHistory[] GetOrdersHistory(CurrencyName inst) { var args = CreateSignHeaders("trades/my", "GET", new SortedDictionary <string, string> { { "market", inst.ToString().ToLower() + "uah" } }); var response = UserQuery("trades/my", HttpMethod.Get, null, UrlEncode(args)); return(JsonConvert.DeserializeObject <KunaOrdersHistory[]>(response.Content)); }
public OrderBook GetOrderBook(CurrencyName ins) { string insName = ins.ToString(); if (ins == CurrencyName.BCH) { insName = "BCC"; } if (ins == CurrencyName.DSH) { insName = "DASH"; } var json = GetQuery(String.Format("{0}public/getorderbook?market=USDT-{1}&type=both", BaseUri, insName)); var response = JsonConvert.DeserializeObject <BittrexOrderBook>(json); var orderBook = new OrderBook { Currency = ins }; int askLen = response.Result.Sell.Length; if (askLen > OrderBookLimit) { askLen = OrderBookLimit; } orderBook.Asks = new Order[askLen]; for (int i = 0; i < orderBook.Asks.Length; i++) { var ask = response.Result.Sell[i]; orderBook.Asks[i] = new Order { Price = ask.Rate, Amount = ask.Quantity }; } int bidLen = response.Result.Buy.Length; if (bidLen > OrderBookLimit) { bidLen = OrderBookLimit; } orderBook.Bids = new Order[bidLen]; for (int i = 0; i < orderBook.Bids.Length; i++) { var bid = response.Result.Buy[i]; orderBook.Bids[i] = new Order { Price = bid.Rate, Amount = bid.Quantity }; } return(orderBook); }
public OrderBook GetOrderBook(CurrencyName currency, CurrencyName instrument) { string instrumentName = instrument.ToString().ToLower(); if (instrument == CurrencyName.BCH) { instrumentName = "bcc"; } if (instrument == CurrencyName.DSH) { instrumentName = "dash"; } var json = GetQuery(String.Format("{0}PUBLIC/{1}{2}/orderbook.json", BaseUri, instrumentName, currency.ToString().ToLower())); var response = JsonConvert.DeserializeObject <BitbayOrderBook>(json); var orderBook = new OrderBook { Currency = currency }; var count = response.Asks.Length; if (count > OrderBookLimit) { count = OrderBookLimit; } orderBook.Asks = new Order[count]; count = response.Bids.Length; if (count > OrderBookLimit) { count = OrderBookLimit; } orderBook.Bids = new Order[count]; for (int i = 0; i < orderBook.Asks.Length; i++) { orderBook.Asks[i] = new Order { Price = response.Asks[i][0], Amount = response.Asks[i][1] } } ; for (int i = 0; i < orderBook.Bids.Length; i++) { orderBook.Bids[i] = new Order { Price = response.Bids[i][0], Amount = response.Bids[i][1] } } ; return(orderBook); }
private void UnsubscribeOrderBook(CurrencyName currency) { SendMessage(c => c.Send(JsonConvert.SerializeObject(new XBtcUnsubscribeRequest { Id = DateTime.Now.Ticks.ToString(), Request = "FeedSubscribe", Params = new XBtcUnsubscribeRequestArgs { Unsubscribe = new string[1] { currency.ToString() + "USD" } } }))); }
private CategoryStatistics GetCategoryStatistics(IEnumerable <Operation> operations, CurrencyName currency) { var statistics = new CategoryStatistics(); var info = new List <CategoryInfo>(); var categories = operations.UsedCategories(); foreach (var category in categories) { info.Add(GetCategoryInfo(operations, category, currency)); } statistics.Currency = currency.ToString(); statistics.Info = info.OrderByDescending(x => x.Persentage); return(statistics); }
private void SubscribeOrderBook(CurrencyName currency) { SendMessage(c => c.Send(JsonConvert.SerializeObject(new XBtcSubscribeRequest { Id = DateTime.Now.Ticks.ToString(), Request = "FeedSubscribe", Params = new XBtcSubscribeRequestArgs { Subscribe = new XBtcRequestItem[1] { new XBtcRequestItem { Symbol = currency.ToString() + "USD", BookDepth = 10 } } } }))); }
private CategoryInfo GetCategoryInfo(IEnumerable <Operation> operations, OperationCategory category, CurrencyName currency) { var categorized = operations.ByCategory(category); var amountTotal = operations.ByType(category.Type).Sum(x => x.Amount); var amountCategorized = categorized.Sum(x => x.Amount); var iterations = categorized.Count(); var persentage = amountTotal > 0 ? amountCategorized * 100 / amountTotal : 0; return(new CategoryInfo() { Name = category.Name, Amount = amountCategorized, Iterations = iterations, Persentage = Math.Round(persentage, 1), BaseCurrency = currency.ToString() }); }
public void Disconnect(CurrencyName instrument) { if (!_started) { return; } _counter = 0; TimerAction(false); lock (_obj) { var connection = _connections.Where(p => p.Item1 == instrument).SingleOrDefault(); _connections.Remove(connection); _log.WriteInfo(String.Format("{0} unsubscribed", instrument.ToString())); TimerAction(_connections.Count > 0); } }
public BitBayPlaceOrder PlaceOrder(string type, CurrencyName instrument, double amount, CurrencyName currency, double price) { string message; var headers = CreateHeaders(new Dictionary <string, string>() { { "type", type }, { "currency", instrument.ToString() }, { "amount", amount.ToString(CultureInfo.InvariantCulture) }, { "payment_currency", currency.ToString() }, { "rate", price.ToString(CultureInfo.InvariantCulture) }, { "method", "trade" }, { "moment", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString() } }, out message); var response = UserQuery("Trading/tradingApi.php", HttpMethod.Post, headers, message); return(JsonConvert.DeserializeObject <BitBayPlaceOrder>(response.Content)); }
private void UnsubscribeOrderBook(CurrencyName currency) { var name = currency.ToString(); if (currency == CurrencyName.DSH) { name = "DASH"; } SendMessage(c => c.Send(JsonConvert.SerializeObject(new CexOrderBookRequest { e = "order-book-unsubscribe", data = new CexOrderBookRequest.CexOrderBookData { pair = new string[] { name, "USD" } }, oid = "1435927928274_4_order-book-unsubscribe" }))); }
public override OrderResponse PlaceOrder(double price, double amount, CurrencyName inst, OrderSide side, TradeOrderType type = TradeOrderType.Limit) { OkExOrderResponse response = null; var symbol = inst.ToString().ToLower() + "_usd"; if (type == TradeOrderType.Limit) { response = _client.PlaceLimitOrder(side == OrderSide.BID ? "buy" : "sell", symbol, amount, price); } else { throw new ArgumentException("Invalid order type"); } return(response.Result ? new OrderResponse(DateTime.UtcNow, response.OrderId) : new OrderResponse() { ErrorReason = String.Format("[OkEx] {0}", response.ErrorCode) }); }
public Models.CustomerResponse Deposit([FromBody] Models.WithdrawRequest withdrawRequest) { Models.CustomerResponse res = new CustomerResponse(); Chilindo.BAL.BALModels.ProcessedResponse result = new BAL.BALModels.ProcessedResponse(); try { Chilindo.BAL.CustomerAccountManager objAccountDetails = new BAL.CustomerAccountManager(); APICurrency = ConfigurationManager.AppSettings["APICURRENCY"]; CurrencyName curr = (CurrencyName)Enum.Parse(typeof(CurrencyName), withdrawRequest.Currency.ToString()); result = objAccountDetails.Deposit(withdrawRequest.AccountNumber, withdrawRequest.Amount, APICurrency, curr.ToString()); res = new CustomerResponse { AccountNumber = result.AccountNumber, Balance = result.Balance, Currency = result.Currency, Message = result.Message, Successful = true }; } catch (Exception ex) { res = new CustomerResponse { AccountNumber = result.AccountNumber, Balance = result.Balance, Currency = result.Currency, Message = string.Format("API Error :{0} / Stack Trace {1}", result.Message, ex.StackTrace), Successful = true }; } return(res); }
public override OrderResponse[] GetActiveOrders(CurrencyName currency = CurrencyName.Undefined) { var currencyPair = currency.ToString().ToLower() + "usd"; return(Client.GetActiveOrders(currencyPair).Select(o => new OrderResponse(o)).ToArray()); }
public OrderBook GetOrderBook(CurrencyName instrument, CurrencyName currency) { var json = GetQuery(String.Format("{0}order_book?book={1}_{2}", BaseUri, instrument.ToString().ToLower(), currency.ToString().ToLower())); var response = JsonConvert.DeserializeObject <QuadrigaOrderBook>(json); if (response.Error != null) { throw new System.Net.WebException(response.Error.Message); } var orderBook = new OrderBook { Currency = currency, Timestamp = response.Timestamp }; orderBook.Asks = new Order[response.Asks.Length]; orderBook.Bids = new Order[response.Bids.Length]; for (int i = 0; i < orderBook.Asks.Length; i++) { orderBook.Asks[i] = new Order { Price = response.Asks[i][0], Amount = response.Asks[i][1] } } ; for (int i = 0; i < orderBook.Bids.Length; i++) { orderBook.Bids[i] = new Order { Price = response.Bids[i][0], Amount = response.Bids[i][1] } } ; return(orderBook); }
public OrderBook GetOrderBook(CurrencyName instrument, CurrencyName currency) { var json = GetQuery(String.Format("{0}depth.do?symbol={1}_{2}", BaseUri, instrument.ToString().ToLower(), currency.ToString().ToLower())); var response = JsonConvert.DeserializeObject <OrderBook>(json); SortAsks(response); return(response); }
public override OrderResponse[] GetActiveOrders(CurrencyName currency = CurrencyName.Undefined) { var orders = _client.GetActiveOrders(currency.ToString().ToLower() + "_cad"); return(orders.Select(o => new OrderResponse(o)).ToArray()); }
public override string ToString() { var sb = new StringBuilder("PaidCallCurrencyExchangeRate("); bool __first = true; if (CurrencyCode != null && __isset.currencyCode) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("CurrencyCode: "); CurrencyCode.ToString(sb); } if (CurrencyName != null && __isset.currencyName) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("CurrencyName: "); CurrencyName.ToString(sb); } if (CurrencySign != null && __isset.currencySign) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("CurrencySign: "); CurrencySign.ToString(sb); } if (__isset.preferred) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("Preferred: "); Preferred.ToString(sb); } if (CoinRate != null && __isset.coinRate) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("CoinRate: "); CoinRate.ToString(sb); } if (CreditRate != null && __isset.creditRate) { if (!__first) { sb.Append(", "); } __first = false; sb.Append("CreditRate: "); CreditRate.ToString(sb); } sb.Append(")"); return(sb.ToString()); }
public BudgetSummary(CurrencyName currency, IEnumerable <BudgetInfo> items) { Currency = currency.ToString(); Items = items; }
public double MinOrderSize(CurrencyName currency) { int index = MinimumOrder.IndexOf(currency.ToString()); return(Double.Parse(MinimumOrder.Substring(0, index).Trim())); }