public void Update(string instrument, decimal price, char buySell, int amount, long extId, long tradeNo, string tradeDate, string tradeTime, long micosecs, decimal fee) { //CBotPos botPos = new CBotPos { Instrument = instrument, _onlineDetector.Update(); DateTime moment = CASTSConv.ASTSDateAndTimeToDateAndTime(tradeDate, tradeTime); int milisec = Convert.ToInt16((double)micosecs / 1000); moment = moment.AddMilliseconds(milisec); CRawUserDeal rd = new CRawUserDeal { Instrument = instrument, Amount = amount, Dir = (sbyte)(buySell == 'B' ? OrderDirection.Buy : OrderDirection.Sell), Ext_id_buy = buySell == 'B' ? extId : 0, Ext_id_sell = buySell == 'S' ? extId : 0, Price = price, ReplId = tradeNo, Moment = moment, Fee_buy = buySell == 'B' ? fee : 0, Fee_sell = buySell == 'S' ? fee : 0 }; //TODO chek if we already processed deal CalculateBotsPos(rd, isOnlineASTSCalc: true); UserDealsPosBoxClient.UpdateGUIDealCollection(rd); }
//deprecated brunch remove if not need public void Update(string instrument, decimal price, EnmOrderDir dir, int amount, long extId, DateTime moment, long mtsCreate, decimal fee) { CRawUserDeal rd = new CRawUserDeal { Instrument = instrument, Amount = amount, Dir = (sbyte)dir, Ext_id_buy = dir == EnmOrderDir.Buy ? extId : 0, Ext_id_sell = dir == EnmOrderDir.Sell ? extId : 0, Price = price, ReplId = GetBotDealId(extId, mtsCreate), Moment = moment, Fee_buy = 0, Fee_sell = 0 }; //TODO chek if we already processed deal CalculateBotsPos(rd, isOnlineASTSCalc: true); UserDealsPosBoxClient.UpdateGUIDealCollection(rd); }
/// <summary> /// On update deal. /// /// Call from: /// 1) CCryptoDealingServer.UpdateUserDeals - when "te" recieved /// 2) CCryptoDealingServer.UpdateUserDeals - when "tu" recieved /// /// </summary> public void Update(long dealId, long orderId, string instrument, EnmOrderDir dir, decimal amount, int botId, decimal price, DateTime moment, long mtsCreate, decimal fee) { Log(string.Format("[Update] botId={0} dealId={1} orderId={2} instrument={3} dir={4} amount={5} price={6} moment={7} mtsCreate={8} fee={9})", botId, //0 dealId, //1 orderId, //2 instrument, //3 dir, //4 amount, //5 price, //6 moment, //7 mtsCreate, //8 fee //9 )); CRawUserDeal rd = new CRawUserDeal { Id_Deal = dealId, Instrument = instrument, Amount = Math.Abs(amount), Dir = (sbyte)dir, Ext_id_buy = dir == EnmOrderDir.Buy ? botId : 0, Ext_id_sell = dir == EnmOrderDir.Sell ? botId : 0, Price = price, ReplId = GetBotDealId(botId, mtsCreate), Moment = moment, Fee_buy = dir == EnmOrderDir.Buy ? Math.Abs(fee) : 0, Fee_sell = dir == EnmOrderDir.Sell ? Math.Abs(fee) : 0 }; CalculateBotsPos(rd, isOnlineASTSCalc: true); //2018-05-24 //In case we recieve fee data in deal //do trigger fee calculation. This is //seldom case, when we where not able to process //"Update" deal from "te" (because orderId-botId recieved later). //and process deal from "tu" //Usually we recieve "te" with no fee, and then "tu" with fee if (fee != 0) { Log("Update fee from [Update]"); //2018-06-16 TODO remove all orderdir to dealDir UpdateFee(botId, instrument, dealId, Math.Abs(fee), (EnmDealDir)dir); } UserDealsPosBoxClient.UpdateGUIDealCollection(rd); }
/// <summary> /// Entry point of CUserDealsPosBox /// /// Call from Plaza2Connector\Plaza2Listener.ProcessUserDeal /// </summary> /// <param name="deal"></param> public void Update(USER_DEAL.user_deal deal) { try { if (deal.nosystem != 0) { Error("No system user deal."); } //drop already-processed deals (with the same id) foreach (CRawUserDeal rud in m_listRawUserDeal) { if (rud.ReplId == deal.replID) { //mxListRawUserDeal.ReleaseMutex(); return; //note: could be duplicate. Nothing to do with it. } } string instrument = UserDealsPosBoxClient.GetTicker(deal.isin_id); m_listRawUserDeal.Add(new CRawUserDeal(deal, instrument)); CalculateBotsPos(new CRawUserDeal(deal, instrument)); UserDealsPosBoxClient.UpdateGUIDealCollection(new CRawUserDeal(deal, instrument)); } catch (Exception e) { m_logger.Log("Error update " + e.Message + " " + e.StackTrace); Error("CUserDealsBox.Update", e); } finally { } }