void OnTrade(ITrade trade)
        {
            Console.WriteLine("WatchNotification: trade made");                 

            var boughtOrSold = trade.Direction == Direction.BUY ? "bought" : "sold";

            var currencyOne = trade.CurrencyPair.Substring(0, 3);
            var currencyTwo = trade.CurrencyPair.Substring(3, 3);
            var currentyPair = _currenyPairs[trade.CurrencyPair];

            var userInfo = new NSMutableDictionary
            {
                { (NSString)"trade", trade.ToNSString() },
                { WormHoleConstants.CurrencyPairKey, currentyPair.ToNSString() },
                { (NSString)"baseCurrency", (NSString)currencyOne },
                { (NSString)"counterCurrency", (NSString)currencyTwo }
            };

            var notification = new UILocalNotification
            {
                AlertBody = $"'{trade.TraderName}' {boughtOrSold} {trade.Notional:n0} {trade.DealtCurrency} vs {currencyTwo} at {trade.SpotRate}",
                Category = "trade",
                UserInfo = userInfo,
                AlertTitle = "Trade Executed",
                AlertAction = $"Show {currencyOne} / {currencyTwo}",
                HasAction = true,
                SoundName = UILocalNotification.DefaultSoundName
            };
            
            Console.WriteLine("WatchNotification: sending from iPhone " + notification.AlertBody);                 
            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
Exemple #2
0
        /// <summary>
        /// Prices the specified stock trade.
        /// </summary>
        /// <param name="trade">The stock trade.</param>
        /// <param name="market">The market.</param>
        /// <param name="result">The result.</param>
        public void Price(ITrade trade, IMarketData market, IResult result)
        {
            var stock = (Stock)trade;

            result.AddValue(stock.Amount * market.StockPrice);
            result.AddDelta(stock.Amount);
        }
Exemple #3
0
        void OnTrade(ITrade trade)
        {
            Console.WriteLine("WatchNotification: trade made");

            var boughtOrSold = trade.Direction == Direction.BUY ? "bought" : "sold";

            var currencyOne  = trade.CurrencyPair.Substring(0, 3);
            var currencyTwo  = trade.CurrencyPair.Substring(3, 3);
            var currentyPair = _currenyPairs[trade.CurrencyPair];

            var userInfo = new NSMutableDictionary
            {
                { (NSString)"trade", trade.ToNSString() },
                { WormHoleConstants.CurrencyPairKey, currentyPair.ToNSString() },
                { (NSString)"baseCurrency", (NSString)currencyOne },
                { (NSString)"counterCurrency", (NSString)currencyTwo }
            };

            var notification = new UILocalNotification
            {
                AlertBody   = $"'{trade.TraderName}' {boughtOrSold} {trade.Notional:n0} {trade.DealtCurrency} vs {currencyTwo} at {trade.SpotRate}",
                Category    = "trade",
                UserInfo    = userInfo,
                AlertTitle  = "Trade Executed",
                AlertAction = $"Show {currencyOne} / {currencyTwo}",
                HasAction   = true,
                SoundName   = UILocalNotification.DefaultSoundName
            };

            Console.WriteLine("WatchNotification: sending from iPhone " + notification.AlertBody);
            UIApplication.SharedApplication.PresentLocalNotificationNow(notification);
        }
        public SpotTileAffirmationViewModel(ITrade trade, ISpotTileViewModel parent)
        {
            _trade = trade;
            _parent = parent;

            _dismissCommand = new DelegateCommand(OnDismissExecute);
        }
        void SetupWormholePriceStream(ITrade trade)
        {
            if (trade == null)
            {
                throw new ArgumentNullException("trade");
            }

            _priceSubject.Dispose();
            _priceSubject = new Subject <PriceDto>();

            var wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory);

            wormhole.PassMessage(WormHoleConstants.StartUpdates, trade.CurrencyPair);
            wormhole.ListenForMessage <PriceDto>(
                WormHoleConstants.CurrencyUpdate,
                price =>
            {
                if (price == null)
                {
                    Console.WriteLine("Watch: wormhole price is null!");
                    return;
                }

                Console.WriteLine("Watch: got PriceDto: " + price.Bid + " / " + price.Ask);
                _priceSubject.OnNext(price);
            }
                );

            _wormhole = wormhole;
        }
Exemple #6
0
        public string GetCategory(ITrade trade)
        {
            List <string> tradeCategories = new List <string> {
                "LOWRISK", "MEDIUMRISK", "HIGHRISK", "NOTCALCULATEDRISK"
            };
            string result = tradeCategories[3];

            if (trade.ClientSector != "")
            {
                if (trade.ClientSector == "Public")
                {
                    result = trade.Value < 1000000
                           ? tradeCategories[0]
                           : tradeCategories[1];
                }
                else
                {
                    result = trade.Value > 1000000
                            ? tradeCategories[2]
                            : tradeCategories[3];
                }
            }

            return(result);
        }
        public static NSAttributedString ToAttributedString(this ITrade trade)
        {
            var currency = trade.CurrencyPair.Replace(trade.DealtCurrency, "");
            var sold     = trade.Direction == Direction.BUY ? "Bought" : "Sold";

            var  text       = new NSMutableAttributedString();
            bool successful = trade.TradeStatus == TradeStatus.Done;

            if (successful)
            {
                text.Append($"{sold} ", _grey);
            }
            else
            {
                text.Append($"TRADE REJECTED ", _rejected);
            }

            var normal    = successful ? _normal : _rejectedNormal;
            var grey      = successful ? _grey : _rejectedGrey;
            var small     = successful ? _small : _rejectedSmall;
            var smallGrey = successful ? _smallGrey : _rejectedSmallGrey;

            text.Append($"{trade.DealtCurrency} {trade.Notional:n0}", normal);
            text.Append("\n vs ", grey);
            text.Append(currency, normal);
            text.Append("\n at ", grey);
            text.Append(trade.SpotRate.ToString(), normal);
            text.Append("\n", normal);
            text.Append("\nTrade ID: ", smallGrey);
            text.Append(trade.TradeId.ToString(), small);
            return(text);
        }
Exemple #8
0
        // This is a generic method for testing buy/sell.
        private void Trade_Test(Action <ITradeService, IStock, Decimal, Int32, DateTime> action, TradeIndicator indicator, Decimal expectedPrice, Int32 expectedQuantity)
        {
            Moq.Mock <ITradeRepository> mockTradeRepo = new Moq.Mock <ITradeRepository>();
            Moq.Mock <IStock>           mockStock     = new Moq.Mock <IStock>();
            mockStock.Setup(mock => mock.Symbol).Returns("ABC");

            ITrade   actualTrade       = null;
            IStock   expectedStock     = mockStock.Object;
            DateTime expectedTimestamp = DateTime.UtcNow;

            // Setup our mock dependency to listen for what we expect to happen and capture the trade created
            // so we can verify it.
            mockTradeRepo
            .Setup(mock => mock.Save(Moq.It.IsAny <ITrade>()))
            .Callback <ITrade>(trade =>
            {
                actualTrade = trade;     // Copy to unit test scope.
            })
            .Verifiable();

            // Run the action.
            ITradeService tradeService = new TradeService(mockTradeRepo.Object);

            action(tradeService, expectedStock, expectedPrice, expectedQuantity, expectedTimestamp);

            // Verify
            mockTradeRepo.Verify(x => x.Save(Moq.It.IsAny <ITrade>()), Moq.Times.Once);
            Assert.IsNotNull(actualTrade);
            Assert.AreEqual(expectedPrice, actualTrade.Price);
            Assert.AreEqual(expectedQuantity, actualTrade.Quantity);
            Assert.AreEqual(expectedTimestamp, actualTrade.TimeStamp);
            Assert.AreEqual(indicator, actualTrade.Indicator);
            Assert.ReferenceEquals(expectedStock, actualTrade.StockInformation);
        }
        /// <summary>
        /// Closes the trade if price crosses the upper/lower bollinger band.
        /// </summary>
        /// <param name="candles">candle history</param>
        /// <param name="bar">currentcandle</param>
        /// <param name="tradeManager">tradeManager</param>
        private void CloseTradeIfPossible(List <MarketCandle> candles, int bar, ITradeManager tradeManager)
        {
            var candle = candles[bar];
            var bbands = new BollingerBands(candles, bar);

            // for long we close the trade if price  gets above the upper bollinger bands
            if (_trade.TradeType == TradeType.Long && candle.HighPrice > bbands.Upper)
            {
                if (tradeManager.Close(_trade, candle.HighPrice))
                {
                    _state = StrategyState.Scanning;
                    _trade = null;
                    return;
                }
            }

            // for short we close the trade if price  gets below the lowe bollinger bands
            if (_trade.TradeType == TradeType.Short && candle.LowPrice < bbands.Lower)
            {
                if (tradeManager.Close(_trade, candle.LowPrice))
                {
                    _state = StrategyState.Scanning;
                    _trade = null;
                    return;
                }
            }
        }
        public SpotTileAffirmationViewModel(ITrade trade, ISpotTileViewModel parent)
        {
            _trade  = trade;
            _parent = parent;

            _dismissCommand = new DelegateCommand(OnDismissExecute);
        }
Exemple #11
0
        public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
        {
            // accept if convert extras to needed and opponent < 7 points
            List <Resource> extras = new List <Resource>();

            foreach (Resource r in Enum.GetValues(typeof(Resource)))
            {
                int extra = state.GetOwnResources().Count(res => res == r) - 1;
                for (int i = 0; i < extra; i++)
                {
                    extras.Add(r);
                }
            }

            // good offer?
            var valid = offer.Give.Where(o => o.All(r => o.Count(cur => cur == r) <= extras.Count(e => e == r)));

            if (valid.Count() == 0)
            {
                return(offer.Decline());
            }

            // take the one with least cards to give, and then by most duplicates
            List <Resource> bestGive = valid.OrderBy(o => o.Count)
                                       .ThenByDescending(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                                       .First();

            // find best "take" (cards we get) kind of the opposite of above
            List <Resource> bestTake = offer.Take.OrderBy(o => o.Count)
                                       .ThenBy(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                                       .First();

            return(offer.Respond(bestGive, bestTake));
        }
Exemple #12
0
        public Risk(ITrade trade)
        {
            if (trade.Value < 1000000)
            {
                if (trade.ClientSector == "Public")
                {
                    this._risk = new LowRisk();
                }
            }
            else if (trade.Value > 1000000)
            {
                if (trade.ClientSector == "Public")
                {
                    this._risk = new MediumRisk();
                }
                else
                {
                    this._risk = new HighRisk();
                }
            }

            if (this._risk == null)
            {
                this._risk = new NoFoundRisk();
            }
        }
Exemple #13
0
        public static double GetPut(ITrade trade, CalcOptionParameters parameters)
        {
            var time = (trade.Expiry.Date.ToOADate() - parameters.CurrentDate.Date.ToOADate()) / 365;
            var put  = PutOption(parameters.CurrentSpotPrice, trade.StrikePrice, time, parameters.CurrentRisk, parameters.Volatility, parameters.Divident);

            return(put);
        }
Exemple #14
0
        static bool CreateAndOpenTrade15()
        {
            //创建 ITrade
            // char* path 指 xxx.exe 同级子目录中的 xxx.dll 文件
            int err = -1;

            trade = ITradeApi.XFinApi_CreateTradeApi("XTA_W32/Api/CTP_v6.3.15_20190220/XFinApi.CTPTradeApiSE.dll", out err);

            if (err > 0 || trade == null)
            {
                Console.WriteLine(string.Format("* Trade XFinApiCreateError={0};", StrCreateErrors[err]));
                return(false);
            }

            //注册事件
            tradeEvent = new TradeEvent();
            trade.SetListener(tradeEvent);

            //连接服务器
            OpenParams openParams = new OpenParams();

            openParams.HostAddress = CfgSE.TradeAddress;
            openParams.BrokerID    = CfgSE.BrokerID;
            openParams.UserID      = CfgSE.UserName;
            openParams.Password    = CfgSE.Password;
            openParams.Configs.Add("AppID", CfgSE.AppID);
            openParams.Configs.Add("AuthCode", CfgSE.AuthCode);
            openParams.IsUTF8 = false;
            trade.Open(openParams);

            return(true);
        }
Exemple #15
0
        private ITrade FindMinWeightedCoveringTrade(IPortfolio portfolio, HashSet <string> nonCoveredDependencies, Dictionary <string, int> tradeCosts, out int minTradeCost)
        {
            double minTradeCostFactor = int.MaxValue;
            int    minTradeIndex      = -1;

            for (int i = 0; i < portfolio.Trades.Count; i++)
            {
                ITrade trade     = portfolio.Trades[i];
                int    tradeCost = tradeCosts[trade.TCN];

                int dependenciesCoveredByThisTrade = nonCoveredDependencies.Intersect(trade.MarketDependencies).Count();
                if (dependenciesCoveredByThisTrade > 0)
                {
                    double costFactor = tradeCost / dependenciesCoveredByThisTrade;
                    if (costFactor < minTradeCostFactor)
                    {
                        minTradeCostFactor = costFactor;
                        minTradeIndex      = i;
                    }
                }
            }

            minTradeCost = tradeCosts[portfolio.Trades[minTradeIndex].TCN];
            return(portfolio.Trades[minTradeIndex]);
        }
Exemple #16
0
        public void Add(ISymbolInfo symbol, ITrade trade)
        {
            var data = GetOrAddData(symbol);

            data.Add(trade);
            _Trades.Add(trade);
        }
        void SetupWormholePriceStream(ITrade trade)
        {
            if (trade == null)
            {
                throw new ArgumentNullException("trade");
            }

            _priceSubject.Dispose();
            _priceSubject = new Subject<PriceDto>();

            var wormhole = new Wormhole(WormHoleConstants.AppGroup, WormHoleConstants.Directory);
            wormhole.PassMessage(WormHoleConstants.StartUpdates, trade.CurrencyPair);
            wormhole.ListenForMessage<PriceDto>(
                WormHoleConstants.CurrencyUpdate,
                price => 
                {
                    if (price == null)
                    {
                        Console.WriteLine("Watch: wormhole price is null!");
                        return;
                    }

                    Console.WriteLine("Watch: got PriceDto: " + price.Bid + " / " + price.Ask);
                    _priceSubject.OnNext(price);
                }
            );

            _wormhole = wormhole;
        }
Exemple #18
0
        public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
        {
            // accept if convert extras to needed and opponent < 7 points
            List<Resource> extras = new List<Resource>();
            foreach (Resource r in Enum.GetValues(typeof(Resource)))
            {
                int extra = state.GetOwnResources().Count(res => res == r) - 1;
                for (int i = 0; i < extra; i++) extras.Add(r);
            }

            // good offer?
            var valid = offer.Give.Where(o => o.All(r => o.Count(cur => cur == r) <= extras.Count(e => e == r)));

            if (valid.Count() == 0) return offer.Decline();

            // take the one with least cards to give, and then by most duplicates
            List<Resource> bestGive = valid.OrderBy(o => o.Count)
                .ThenByDescending(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                .First();

            // find best "take" (cards we get) kind of the opposite of above
            List<Resource> bestTake = offer.Take.OrderBy(o => o.Count)
                .ThenBy(o => state.GetOwnResources().Sum(r => state.GetOwnResources().Count(res => res == r)))
                .First();

            return offer.Respond(bestGive, bestTake);
        }
Exemple #19
0
        protected override void DrawLegend(int barNumber, ChartProperty property)
        {
            int       iDecimals    = this.AxisY.Decimals;
            Rectangle cRectY       = this.AxisY.AxisRectangle;
            IntPtr    cOldFont     = __cGDI.SelectFont(__cLegendFont);
            Size      cFontMetrics = __cGDI.MeasureString("0");

            __cGDI.BeginRopDraw();

            List <ITrade> cTrades = __cTrades.GetTradeObject(barNumber);
            int           iRow = 0, iCount = cTrades.Count;

            for (int i = 0; i < iCount; i++)
            {
                ITrade      cTrade      = cTrades[i];
                ITradeOrder cEntry      = cTrade.EntryOrder;
                string      sEntryOrder = string.Format("#{0} {1,-10} {2} at {3} {4}", cEntry.Ticket, cEntry.Action, cEntry.Contracts, Math.Round(cEntry.Price, iDecimals), cEntry.Time.ToString("yyyy-MM-dd HH:mm:ss"));
                __cGDI.DrawRopString(sEntryOrder, this.ChartSetting.LegendColor, cRectY.X - (sEntryOrder.Length * cFontMetrics.Width) - 4, cRectY.Top + ((iRow++ *cFontMetrics.Height) + 2));

                ITradeOrder cExit = cTrade.ExitOrder;
                if (cExit != null)
                {
                    string sExitOrder = string.Format("#{0} {1,-10} {2} at {3} {4}", cExit.Ticket, cExit.Action, cExit.Contracts, Math.Round(cExit.Price, iDecimals), cExit.Time.ToString("yyyy-MM-dd HH:mm:ss"));
                    __cGDI.DrawRopString(sExitOrder, this.ChartSetting.LegendColor, cRectY.X - (sExitOrder.Length * cFontMetrics.Width) - 4, cRectY.Top + ((iRow++ *cFontMetrics.Height) + 2));
                }
            }
            __cGDI.EndRopDraw();
            __cGDI.RemoveObject(__cGDI.SelectFont(cOldFont));
        }
Exemple #20
0
        public Transaction(ICommodity commodity, ITrade trade)
        {
            TxCommodity = commodity;
            TxTrade     = trade;

            TxProfitValidator = new ProfitValidator(TxCommodity, TxTrade);
            TxTradeValidator  = new TradeValidator(TxTrade);
        }
Exemple #21
0
 public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
 {
     if (!silent)
     {
         Console.WriteLine(id + ": Handling trade");
     }
     return(offer);
 }
Exemple #22
0
 private void ProcessTrades(FootPrint.FpBar bar, IEnumerable <ITrade> trades)
 {
     foreach (var trade in trades)
     {
         ProcessTrade(bar, trade);
         m_lastTrade = trade;
     }
 }
 public Task AddAsync(IOrderHistory order, ITrade trade)
 {
     return(TransactionWrapperExtensions.RunInTransactionAsync(
                (conn, transaction) => DoAdd(conn, transaction, order, trade),
                _connectionString,
                RollbackExceptionHandler,
                commitException => CommitExceptionHandler(commitException, order, trade)));
 }
        public string GetClientCategoty(ITrade trade)
        {
            string category;

            if (trade.Value < 1_000_000 && trade.ClientSector == ClientSetorEnum.PUBLIC.RecuperaDescricaoDoEnum())
            {
                category = CategoryEnum.LOWRISK.RecuperaDescricaoDoEnum();
            }
        public bool VerifyRisk(DateTime referenceDate, ITrade trade)
        {
            TimeSpan differenceTimeSpan = referenceDate - trade.NextPaymentDate;

            var differenceDays = (int)differenceTimeSpan.TotalDays;

            return(differenceDays > 30);
        }
        public CategorizeEnum Categorize(DateTime dateReference, ITrade trade)
        {
            if ((dateReference - trade.NextPaymentDate).TotalDays > delayOfDays)
            {
                return(CategorizeEnum.Defaulted);
            }

            return(0);
        }
        public TradeRisk Risk(ITrade trade)
        {
            if (trade.Value > 1000000)
            {
                return(TradeRisk.HIGHRISK);
            }

            return(TradeRisk.UNDEFINED);
        }
        public CategorizeEnum Categorize(DateTime dateReference, ITrade trade)
        {
            if (trade.Value > 1000000 && trade.ClientSector == "Public")
            {
                return(CategorizeEnum.MediumRisk);
            }

            return(0);
        }
        public static NSAttributedString ToAttributedStringLine1(this ITrade trade)
        {
            var sold = trade.Direction == Direction.BUY ? "Bought" : "Sold";
            var text = new NSMutableAttributedString();

            text.Append($"{sold} ", _grey);
            text.Append($"{trade.DealtCurrency} {trade.Notional:n0}\n", _normal);
            return(text);
        }
Exemple #30
0
        public Task AddAsync(IOrderHistory order, ITrade trade)
        {
            var entity = OrderHistoryEntity.Create(order);

            // ReSharper disable once RedundantArgumentDefaultValue
            //TODO: use event datetime
            return(_tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(entity,
                                                                        DateTime.UtcNow, RowKeyDateTimeFormat.Iso));
        }
Exemple #31
0
 public static void AssertSensibleValue(ITrade trade)
 {
     Assert.NotNull(trade);
     Assert.NotNull(trade.UniqueId);
     Assert.NotNull(trade.Counterparty);
     Assert.NotNull(trade.Counterparty.ExternalId);
     Assert.NotEqual(default(DateTimeOffset), trade.TradeDate);
     AssertSensibleValue(trade.SecurityKey);
 }
Exemple #32
0
 public AcceptTradeCommand(IPlayer player, ITrade trade)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (trade == null)
         throw new ArgumentNullException(nameof(trade));
     Player = player;
     this.trade = trade;
 }
        public TradeRisk Risk(ITrade trade)
        {
            if (trade.Value < 1000000)
            {
                return(TradeRisk.LOWRISK);
            }

            return(TradeRisk.MEDIUMRISK);
        }
Exemple #34
0
        public static TradeLogEntity Create(ITrade src)
        {
            var entity = CreateNew(src);

            entity.PartitionKey = GeneratePartitionKey(src.AssetPairId);
            entity.RowKey       = GenerateRowKey(src.DateTime, src.Index);

            return(entity);
        }
 public bool Apply(IPortfolio p, ITrade t)
 {
     IPosition pos = p.Positions.Where(x => x.symbol.name == t.symbol.name).FirstOrDefault();
     if (pos == null) return false;
     if ((t.value + pos.price) / p.Value > MaxAllocation)
     {
         throw new AllocationViolation();
     }
     return true;
 }
Exemple #36
0
 public EuropianTradeOption(ITrade trade,
                            CalcOptionParameters parameters,
                            Func <ITrade, CalcOptionParameters, double> getPut,
                            Func <ITrade, CalcOptionParameters, double> getCall)
 {
     Init(trade);
     _getPut    = getPut;
     _getCall   = getCall;
     Parameters = parameters;
 }
Exemple #37
0
        public void OpenTrade(ITrade trade)
        {
            if (trade == null)
                throw new ArgumentNullException(nameof(trade));
            if (trade.State != TradeState.Open)
                throw new ArgumentException("Can't open trade on the market, if the trade is not in an open state");
            trades.Add(trade);

            logger.Info($"Trade opened");
        }
Exemple #38
0
 public CancelTradeCommand(IPlayer player, ITrade trade)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (trade == null)
         throw new ArgumentNullException(nameof(trade));
     if (trade.Owner != player)
         throw new ArgumentException("Executing player should be the owner of the trade");
     Player = player;
     this.trade = trade;
 }
Exemple #39
0
 public OpenTradeCommand(IPlayer player, IMarket market, ITrade trade)
 {
     if (player == null)
         throw new ArgumentNullException(nameof(player));
     if (market == null)
         throw new ArgumentNullException(nameof(market));
     if (trade == null)
         throw new ArgumentNullException(nameof(trade));
     Player = player;
     this.market = market;
     this.trade = trade;
 }
 public bool Apply(IPortfolio p, ITrade t)
 {
     if (t.type != tradeTypes.Buy) return true;
     if (t.price * t.quantity > p.Cash)
     {
         InsufficientFunds ex = new InsufficientFunds();
         ex.Data.Add("AvailableFunds", p.Cash);
         ex.Data.Add("TransactionAmount", t.price * t.quantity);
         throw ex;
     }
     return true;
 }
 public TradeViewModel(ITrade trade, bool isStowTrade)
 {
     _isStowTrade = isStowTrade;
     TradeId = trade.TradeId.ToString(CultureInfo.InvariantCulture);
     CurrencyPair = trade.CurrencyPair.Substring(0, 3) + " / " + trade.CurrencyPair.Substring(3, 3);
     Direction = trade.Direction;
     Notional = trade.Notional.ToString("N0", CultureInfo.InvariantCulture) + " " + trade.DealtCurrency;
     SpotRate = trade.SpotRate;
     TradeDate = trade.TradeDate;
     TradeStatus = trade.TradeStatus == Domain.Models.Execution.TradeStatus.Done ? "Done" : "REJECTED";
     TraderName = trade.TraderName;
     ValueDate = trade.ValueDate;
     DealtCurrency = trade.DealtCurrency;
 }
 public TradeMessage(ITrade trade)
     : this()
 {
     TradeId = trade.TradeId;
     SymbolName = trade.symbol.name;
     Price = trade.price;
     Quantity = trade.quantity;
     InitialQuantity = trade.InitialQuantity;
     Timestamp = trade.timestamp;
     Type = trade.type;
     Status = trade.Status;
     PaidCommission = trade.PaidCommission;
     TransactionId = trade.TransactionId;
     RelatedTradeId = trade.RelatedTradeId;
 }
        public override void Awake(NSObject context)
        {
            base.Awake(context);

            if (context == null)
            {
                Console.WriteLine("Error: null context passed to TradeConfirmController Awake");
                return;
            }

            var tradeId = ((NSNumber)context).LongValue;
            var trade = Trades.Shared[tradeId];

            if (trade == null)
            {
                Console.WriteLine("Error: couldn't find trade in TradeConfirmController Awake");
            }

            _trade = trade;
        }
        public static bool TryParseTrade(string[] cells,out ITrade resTrade )
        {
            resTrade = null;
            int id;
            if (false == int.TryParse(cells[0],out id))
            {
                return false;
            }

            var trade = new Trade()
            {
                Id = int.Parse(cells[0]),
                MktPrice = double.Parse(cells[1]),
                Notional = double.Parse(cells[2]),
                Quantity = int.Parse(cells[3]),
                TradeDate = DateTime.Parse(cells[4]),
                TradeType = cells[5]

            };
            resTrade = trade;
            return true;
        }
Exemple #45
0
 public void ExpectConstructionIfFailOnNullParameter(IPlayer player, IMarket market, ITrade trade)
 {
     Assert.Throws<ArgumentNullException>(() => new OpenTradeCommand(player, market, trade));
 }
Exemple #46
0
 /// <summary>
 /// 构造实物商品url
 /// </summary>
 /// <param name="normalGoods">实特商品信息</param>
 /// <param name="key">账户的交易安全校验码(key)</param>
 /// <returns></returns>
 public string CreateNormalGoodsTradeUrl(ITrade _goods)
 {
     DigitalTrade normalGoods = (NormalTrade)_goods;
     string tradeUrl = ""; //未进行UrlEncode编码的链接参数串
     string encodeUrl = "";//进行UrlEncode编码的链接参数串
     string[] urlParamArray = GetUrlParam(normalGoods);
     //排序参数
     QuickSort(urlParamArray, 0, urlParamArray.Length - 1);
     tradeUrl = CreateTradeUrl(urlParamArray);
     encodeUrl = CreateEncodeUrl(urlParamArray);
     return PayUrl + encodeUrl + string.Format("&sign_type={0}", normalGoods.Sign_Type);
 }
 public void OnTrade(ITrade trade)
 {
 }
 public void OnTrade(ITrade trade)
 {
     _parent.OnTrade(trade);
 }
Exemple #49
0
 public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
 {
     Console.WriteLine("You were asked if you wanted to trade.");
     Console.WriteLine("This is not yet implemented, so you declined.");
     return offer.Decline();
 }
		public TradeDoneModel (ITrade trade)
		{
			Trade = trade;
		}
Exemple #51
0
 public ITrade HandleTrade(IGameState state, ITrade offer, int proposingPlayerId)
 {
     if (!silent)
         Console.WriteLine(id + ": Handling trade");
     return offer;
 }
 void SetupInterface(ITrade trade)
 {
     _tradeDetailsLabel1.SetText(trade.ToAttributedStringLine1());
     _tradeDetailsLabel2.SetText(trade.ToAttributedStringLine2());
 }
 /// <summary>
 /// 构造虚拟商品url
 /// </summary>
 /// <param name="digitalGoods">虚拟商品信息</param>
 /// <param name="key">账户的交易安全校验码(key)</param>
 /// <returns></returns>
 public string CreateDigitalGoodsTradeUrl(ITrade _goods)
 {
     DigitalTrade digitalGoods = (DigitalTrade)_goods;
     string tradeUrl = ""; //未进行UrlEncode编码的链接参数串
     string encodeUrl = "";//进行UrlEncode编码的链接参数串
     string[] urlParamArray = GetUrlParam(digitalGoods);
     //排序参数
     QuickSort(urlParamArray, 0, urlParamArray.Length - 1);
     tradeUrl = CreateTradeUrl(urlParamArray);
     encodeUrl = CreateEncodeUrl(urlParamArray);
     return string.Format("{0}{1}&sign={2}&sign_type={3}", PayUrl, encodeUrl, GetMD5(tradeUrl + Config.GeneralConfigs.GetConfig().Alipaypartnercheckkey, "utf-8"), digitalGoods.Sign_Type);
 }
Exemple #54
0
 public void CantConstructWithNullParameters(IPlayer player, ITrade trade)
 {
     Assert.Throws<ArgumentNullException>(() => new AcceptTradeCommand(player, trade));
 }
Exemple #55
0
		internal _TradeInfo(ITrade trade, string symbolId) {
			__cTrade = trade;
			__cOrder = trade.EntryOrder;
			__sSymbolId = symbolId;
		}
Exemple #56
0
 public void updatePosition(ITrade trade)
 {
     throw new NotImplementedException();
 }
 public void OnTrade(ITrade trade)
 {
     Affirmation = _affirmationFactory(trade, this);
     State = TileState.Affirmation;
     Error = null;
 }
Exemple #58
0
 public void ConstructionFailsWithNullParameter(IPlayer player, ITrade trade)
 {
     Assert.Throws<ArgumentNullException>(() => new CancelTradeCommand(player, trade));
 }
Exemple #59
0
		/// <summary>
		/// Initializes a new instance of the <see cref="ZyGames.Framework.Game.Com.Mall.MallController"/> class.
		/// </summary>
		/// <param name="tradeStrategy">Trade strategy.</param>
        protected MallController(ITrade tradeStrategy)
        {
            _tradeStrategy = tradeStrategy;
        }
        void ShowConfirmation(ITrade trade)
        {
            if (trade == null)
            {
                throw new ArgumentNullException("trade");
            }

            Trades.Shared[trade.TradeId] = trade;
                 
            InvokeOnMainThread(() => 
                PresentController(TradeConfirmController.Name, new NSNumber(trade.TradeId))
            );
        }