public GetTradeHistoryInfo GetAndSendTradeHistoryInfoData(TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, short OrderType, short IsPop = 0) { try { //var OrderHistoryList = _frontTrnRepository.GetTradeHistory(0, "", "", "", 0, 0, Newtransaction.Id); GetTradeHistoryInfo model = new GetTradeHistoryInfo(); model.TrnNo = NewTradeTransaction.TrnNo; model.Type = (NewTradeTransaction.TrnType == 4) ? "BUY" : "SELL"; model.Price = (NewTradeTransaction.BidPrice == 0) ? NewTradeTransaction.AskPrice : (NewTradeTransaction.AskPrice == 0) ? NewTradeTransaction.BidPrice : NewTradeTransaction.BidPrice; model.Amount = (NewTradeTransaction.TrnType == 4) ? NewTradeTransaction.SettledBuyQty : NewTradeTransaction.SettledSellQty; model.Total = model.Type == "BUY" ? ((model.Price * model.Amount) - model.ChargeRs) : ((model.Price * model.Amount)); model.DateTime = Convert.ToDateTime(NewTradeTransaction.SettledDate); model.Status = NewTradeTransaction.Status; model.StatusText = Enum.GetName(typeof(enTransactionStatus), model.Status); model.PairName = NewTradeTransaction.PairName; model.ChargeRs = Convert.ToDecimal(Newtransaction.ChargeRs); model.IsCancel = NewTradeTransaction.IsCancelled; model.OrderType = Enum.GetName(typeof(enTransactionMarketType), OrderType); return(model); } catch (Exception ex) { HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); //throw ex; return(null); } }
public void TradeHistory(GetTradeHistoryInfo Data, string Token) { try { SignalRComm <GetTradeHistoryInfo> CommonData = new SignalRComm <GetTradeHistoryInfo>(); CommonData.EventType = Enum.GetName(typeof(enSignalREventType), enSignalREventType.Channel); CommonData.Method = Enum.GetName(typeof(enMethodName), enMethodName.TradeHistory); CommonData.ReturnMethod = Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveTradeHistory); CommonData.Subscription = Enum.GetName(typeof(enSubscriptionType), enSubscriptionType.OneToOne); CommonData.ParamType = Enum.GetName(typeof(enSignalRParmType), enSignalRParmType.AccessToken); CommonData.Data = Data; CommonData.Parameter = null; SignalRData SendData = new SignalRData(); SendData.Method = enMethodName.TradeHistory; SendData.Parameter = Token; SendData.DataObj = JsonConvert.SerializeObject(CommonData); _mediator.Send(SendData); } catch (Exception ex) { _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); //throw ex; } }
public void OnStatusSuccess(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType) { try { GetTradeHistoryInfo historyInfo = new GetTradeHistoryInfo(); GetBuySellBook BuySellmodel = new GetBuySellBook(); //update Recent Order //pop OpenOrder //add tradehistory //add orderhistory //pop buyer/seller book; //HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "Call ---- TransactionQueue :" + JsonConvert.SerializeObject(Newtransaction) + " TradeTransactionQueue :" + JsonConvert.SerializeObject(NewTradeTransaction)); if (string.IsNullOrEmpty(Token)) { Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString()); } if (!string.IsNullOrEmpty(Token)) { BuySellmodel.Amount = 0; BuySellmodel.OrderId = new Guid(); BuySellmodel.RecordCount = 0; if (NewTradeTransaction.TrnType == 4)//Buy { BuySellmodel.Price = NewTradeTransaction.BidPrice; BuyerBook(BuySellmodel, NewTradeTransaction.PairName); HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "BuyerBook call TRNNO:" + Newtransaction.Id); } else//Sell { BuySellmodel.Price = NewTradeTransaction.AskPrice; SellerBook(BuySellmodel, NewTradeTransaction.PairName); HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, "SellerBook call TRNNO:" + Newtransaction.Id); } GetAndSendRecentOrderData(Newtransaction, NewTradeTransaction, Token, OrderType); //Update Recent HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Recent Order Socket call TRNNO:" + Newtransaction.Id); GetAndSendOpenOrderData(Newtransaction, NewTradeTransaction, Token, OrderType, 1); //update OpenOrder HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Open Order Socket call TRNNO:" + Newtransaction.Id); historyInfo = GetAndSendTradeHistoryInfoData(Newtransaction, NewTradeTransaction, OrderType); OrderHistory(historyInfo, historyInfo.PairName); //Order HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Order History Socket call : TRNNO:" + Newtransaction.Id); TradeHistory(historyInfo, Token); //TradeHistory HelperForLog.WriteLogIntoFile("OnStatusSuccess", ControllerName, " Aftre Trade History Socket call : TRNNO:" + Newtransaction.Id); var msg = EnResponseMessage.SignalRTrnSuccessfullySettled; msg = msg.Replace("#Price#", historyInfo.Price.ToString()); msg = msg.Replace("#Qty#", historyInfo.Amount.ToString()); msg = msg.Replace("#Total#", historyInfo.Total.ToString()); ActivityNotification(msg, Token); } } catch (Exception ex) { HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); //throw ex; } }
public void OnStatusCancel(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType) { try { GetTradeHistoryInfo historyInfo = new GetTradeHistoryInfo(); //pop from OpenOrder //update Recent order //add Trade history //HelperForLog.WriteLogIntoFile("OnStatusCancel", ControllerName, " TransactionQueue :" + JsonConvert.SerializeObject(Newtransaction) + " TradeTransactionQueue :" + JsonConvert.SerializeObject(NewTradeTransaction)); if (string.IsNullOrEmpty(Token)) { Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString()); } if (!string.IsNullOrEmpty(Token)) { GetAndSendOpenOrderData(Newtransaction, NewTradeTransaction, Token, OrderType, 1); //with amount 0, remove from OpenOrder HelperForLog.WriteLogIntoFile("OnStatusCancel", ControllerName, " Aftre Open Order Socket call : TRNNO:" + Newtransaction.Id); GetAndSendRecentOrderData(Newtransaction, NewTradeTransaction, Token, OrderType); //Update Recent HelperForLog.WriteLogIntoFile("OnStatusCancel", ControllerName, " Aftre Recent Order Socket call : TRNNO:" + Newtransaction.Id); historyInfo = GetAndSendTradeHistoryInfoData(Newtransaction, NewTradeTransaction, OrderType); TradeHistory(historyInfo, Token);//TradeHistory HelperForLog.WriteLogIntoFile("OnStatusCancel", ControllerName, " Aftre Trade History Socket call : TRNNO:" + Newtransaction.Id); } } catch (Exception ex) { _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); //throw ex; } //public void OnWalletBalChangeByUserID(WalletMasterResponse Data, string WalletTypeName, long UserID) //{ // try // { // //string str = "clientId=cleanarchitecture&grant_type=password&[email protected]&password=P@ssw0rd!&scope=openid profile email offline_access client_id roles phone"; // //str = str.Replace("=","\":\""); // //str = str.Replace("&", "\",\""); // //str = "{\"" + str + "\"}"; // //var obj = JsonConvert.DeserializeObject(str); // //var jsonData= JsonConvert.SerializeObject(obj); // var Redis = new RadisServices<ConnetedClientToken>(this._fact); // string AccessToken = Redis.GetHashData("Tokens:" + UserID.ToString(), "Token"); // Token = AccessToken; // BuyerSideWalletBal(Data, WalletTypeName, Token); // SellerSideWalletBal(Data, WalletTypeName, Token); // } // catch (Exception ex) // { // HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); // //throw ex; // } }
public async Task <IActionResult> TradeHistory(string Data) { string ReciveMethod = ""; try { var accessToken = await HttpContext.GetTokenAsync("access_token"); GetTradeHistoryInfo model = new GetTradeHistoryInfo(); model.TrnNo = 90; model.Type = "SELL"; model.Price = 1400; model.Amount = 1000; model.Total = 140000; model.DateTime = DateTime.UtcNow; model.Status = 1; model.StatusText = "Success"; model.PairName = "INR_BTC"; model.ChargeRs = 10; model.IsCancel = 0; GetTradeHistoryInfo temp = JsonConvert.DeserializeObject <GetTradeHistoryInfo>(Data); SignalRComm <GetTradeHistoryInfo> CommonData = new SignalRComm <GetTradeHistoryInfo>(); CommonData.EventType = Enum.GetName(typeof(enSignalREventType), enSignalREventType.Channel); CommonData.Method = Enum.GetName(typeof(enMethodName), enMethodName.TradeHistory); CommonData.ReturnMethod = Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveTradeHistory); CommonData.Subscription = Enum.GetName(typeof(enSubscriptionType), enSubscriptionType.OneToOne); CommonData.ParamType = Enum.GetName(typeof(enSignalRParmType), enSignalRParmType.AccessToken); CommonData.Data = temp; CommonData.Parameter = null; SignalRData SendData = new SignalRData(); SendData.Method = enMethodName.TradeHistory; SendData.Parameter = accessToken;// CommonData.Parameter; SendData.DataObj = JsonConvert.SerializeObject(CommonData); await _mediator.Send(SendData); ReciveMethod = CommonData.ReturnMethod; return(Ok(new { ReciveMethod = ReciveMethod })); } catch (Exception ex) { _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error); return(Ok()); } }
public void OnStatusHold(short Status, TransactionQueue Newtransaction, TradeTransactionQueue NewTradeTransaction, string Token, short OrderType) { try { GetTradeHistoryInfo historyInfo = new GetTradeHistoryInfo(); GetBuySellBook BuySellmodel = new GetBuySellBook(); //add buyer/seller book //add OpenOrder //add recent order // HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " TransactionQueue :" ); if (string.IsNullOrEmpty(Token)) { Token = GetTokenByUserID(NewTradeTransaction.MemberID.ToString()); } List <GetBuySellBook> list = new List <GetBuySellBook>(); if (!string.IsNullOrEmpty(Token)) { if (NewTradeTransaction.TrnType == 4)//Buy { list = _frontTrnRepository.GetBuyerBook(NewTradeTransaction.PairID, NewTradeTransaction.BidPrice); foreach (var model in list) { BuySellmodel = model; break; } if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000") { BuyerBook(BuySellmodel, NewTradeTransaction.PairName); HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, "BuyerBook call TRNNO:" + Newtransaction.Id + " Pair :" + NewTradeTransaction.PairName); } } else//Sell { list = _frontTrnRepository.GetSellerBook(NewTradeTransaction.PairID, NewTradeTransaction.AskPrice); foreach (var model in list) { BuySellmodel = model; break; } if (BuySellmodel.OrderId.ToString() != "00000000-0000-0000-0000-000000000000") { SellerBook(BuySellmodel, NewTradeTransaction.PairName); HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, "SellerBook call TRNNO:" + Newtransaction.Id + " Pair :" + NewTradeTransaction.PairName); } } //var msg = EnResponseMessage.SignalRTrnSuccessfullyCreated; //msg = msg.Replace("#Price#", historyInfo.Price.ToString()); //msg = msg.Replace("#Qty#", historyInfo.Amount.ToString()); //ActivityNotification(msg, Token); GetAndSendOpenOrderData(Newtransaction, NewTradeTransaction, Token, OrderType); HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " Aftre Open Order Socket call TRNNO:" + Newtransaction.Id); GetAndSendRecentOrderData(Newtransaction, NewTradeTransaction, Token, OrderType); HelperForLog.WriteLogIntoFile("OnStatusHold", ControllerName, " Aftre Recent Order Socket call TRNNO:" + Newtransaction.Id); } } catch (Exception ex) { HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex); ////throw ex; } }