Ejemplo n.º 1
0
 public Trade ToDomain(LeagueYear leagueYear, Publisher proposer, Publisher counterParty, IEnumerable <MasterGameYearWithCounterPick> proposerMasterGames,
                       IEnumerable <MasterGameYearWithCounterPick> counterPartyMasterGames, IEnumerable <TradeVote> votes)
 {
     return(new Trade(TradeID, leagueYear, proposer, counterParty, proposerMasterGames, counterPartyMasterGames,
                      ProposerBudgetSendAmount, CounterPartyBudgetSendAmount, Message, ProposedTimestamp, AcceptedTimestamp, CompletedTimestamp,
                      votes, TradeStatus.FromValue(Status)));
 }
Ejemplo n.º 2
0
        private void Throw(TradeStatus status)
        {
            string originalDesc = Tlw.ZPG.Infrastructure.Utils.EnumUtil.GetDescription(this.Status);
            string targetDesc   = Tlw.ZPG.Infrastructure.Utils.EnumUtil.GetDescription(status);

            throw new DomainException(string.Format("不允许设置状态,原状态:{0},目标状态:{1}", originalDesc, targetDesc));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Puts creature into waiting mode.
        /// </summary>
        /// <param name="creature"></param>
        private void Wait(Creature creature)
        {
            this.Status = TradeStatus.NotReady;

            Send.TradeWait(this.Creature1, 4000);
            Send.TradeWait(this.Creature2, 4000);
        }
 public Orderbook(
     int depth,
     List <OrderbookRecord> bids,
     List <OrderbookRecord> asks,
     string figi,
     TradeStatus tradeStatus,
     decimal minPriceIncrement,
     decimal faceValue,
     decimal lastPrice,
     decimal closePrice,
     decimal limitUp,
     decimal limitDown)
 {
     Depth             = depth;
     Bids              = bids;
     Asks              = asks;
     Figi              = figi;
     TradeStatus       = tradeStatus;
     MinPriceIncrement = minPriceIncrement;
     FaceValue         = faceValue;
     LastPrice         = lastPrice;
     ClosePrice        = closePrice;
     LimitUp           = limitUp;
     LimitDown         = limitDown;
 }
Ejemplo n.º 5
0
        public void AddTrade(TradedPair pair, OrderType orderType, TradeStatus status, double size, double?executionPrice,
                             DateTime?executionDate, double?closingPrice, DateTime?closingDate, double?stopLoss, double?takeProfit,
                             ReasonForEntry reason, double?swap, double?commissions, string notes, byte[] image)
        {
            var trade = new Trade
            {
                TradePair      = pair,
                OrderType      = orderType,
                TradeStatus    = status,
                Quantity       = size,
                ExecutionPrice = executionPrice,
                ExecutionDate  = executionDate,
                ClosingPrice   = closingPrice,
                ClosingDate    = closingDate,
                StopLoss       = stopLoss,
                TakeProfit     = takeProfit,
                ReasonForEntry = reason,
                Swap           = swap,
                Commissions    = commissions,
                Notes          = notes,
                Image          = image
            };

            this.tradesDB.Trades.Add(trade);
            this.tradesDB.SaveChanges();
        }
Ejemplo n.º 6
0
        public void EditTrade(string id, TradedPair pair, OrderType orderType, TradeStatus status, double size, double?executionPrice, DateTime?executionDate,
                              double?closingPrice, DateTime?closingDate, double?stopLoss, double?takeProfit, ReasonForEntry reason, double?swap, double?commissions,
                              string notes, byte[] image)
        {
            var trade = this.tradesDB.Trades.FirstOrDefault(t => t.Id == id);

            if (trade == null)
            {
                return;
            }

            trade.Id             = id;
            trade.TradePair      = pair;
            trade.OrderType      = orderType;
            trade.TradeStatus    = status;
            trade.Quantity       = size;
            trade.ExecutionPrice = executionPrice;
            trade.ExecutionDate  = executionDate;
            trade.ClosingPrice   = closingPrice;
            trade.ClosingDate    = closingDate;
            trade.StopLoss       = stopLoss;
            trade.TakeProfit     = takeProfit;
            trade.ReasonForEntry = reason;
            trade.Swap           = swap;
            trade.Commissions    = commissions;
            trade.Notes          = notes;
            trade.Image          = image;

            this.tradesDB.SaveChanges();
        }
Ejemplo n.º 7
0
 public bool CounterTrade(Hero sender, int goldToSend, List <Item> itemsToSend, int goldToReceive, List <Item> itemsToReceive)
 {
     if (sender == hero1 && tradeStatus == TradeStatus.Hero1)
     {
         this.goldToHero1  = goldToReceive;
         this.itemsToHero1 = itemsToReceive;
         this.goldToHero2  = goldToSend;
         this.itemsToHero2 = itemsToSend;
         tradeStatus       = TradeStatus.Hero2;
         return(true);
     }
     else if (sender == hero2 && tradeStatus == TradeStatus.Hero2)
     {
         this.goldToHero1  = goldToSend;
         this.itemsToHero1 = itemsToSend;
         this.goldToHero2  = goldToReceive;
         this.itemsToHero2 = itemsToReceive;
         tradeStatus       = TradeStatus.Hero1;
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 8
0
        private static IReadOnlyCollection <InternalTrade> Map(Order order, bool completed)
        {
            var reports = new List <InternalTrade>();

            for (int i = 0; i < order.Trades.Count; i++)
            {
                Trade trade = order.Trades[i];

                TradeType tradeType = order.Side == OrderSide.Sell
                    ? TradeType.Sell
                    : TradeType.Buy;

                TradeStatus executionStatus = i == order.Trades.Count - 1 && completed
                    ? TradeStatus.Fill
                    : TradeStatus.PartialFill;

                reports.Add(new InternalTrade
                {
                    Id                   = trade.TradeId,
                    AssetPairId          = order.AssetPairId,
                    ExchangeOrderId      = order.Id,
                    LimitOrderId         = order.ExternalId,
                    Status               = executionStatus,
                    Type                 = tradeType,
                    Timestamp            = trade.Timestamp,
                    Price                = decimal.Parse(trade.Price),
                    Volume               = Math.Abs(decimal.Parse(trade.BaseVolume)),
                    OppositeWalletId     = trade.OppositeWalletId,
                    OppositeLimitOrderId = trade.OppositeOrderId,
                    OppositeVolume       = Math.Abs(decimal.Parse(trade.QuotingVolume))
                });
            }

            return(reports);
        }
Ejemplo n.º 9
0
        protected void HandleTradeStatus(InPacket packet)
        {
            if (Behavior.Begger)
            {
                TradeStatus status = (TradeStatus)packet.ReadUInt32();
                switch (status)
                {
                case TradeStatus.BeginTrade:
                    TraderGUID = packet.ReadUInt64();
                    // Stop moving
                    CancelActionsByFlag(ActionFlag.Movement);
                    // Accept trade
                    OutPacket beginTrade = new OutPacket(WorldCommand.CMSG_BEGIN_TRADE);
                    SendPacket(beginTrade);
                    break;

                case TradeStatus.Canceled:
                    EnableActionsByFlag(ActionFlag.Movement);
                    TraderGUID = 0;
                    break;

                case TradeStatus.Accept:
                    OutPacket acceptTrade = new OutPacket(WorldCommand.CMSG_ACCEPT_TRADE);
                    SendPacket(acceptTrade);
                    break;

                case TradeStatus.Tradecomplete:
                    DoSayChat("Thank you!");
                    EnableActionsByFlag(ActionFlag.Movement);
                    HandleTriggerInput(TriggerActionType.TradeCompleted, TraderGUID);
                    TraderGUID = 0;
                    break;
                }
            }
        }
Ejemplo n.º 10
0
        public TradeBotBase(String stockid, string brokerid, string account, ushort BuyQty, Intelligence.QuoteCom quotecom, Smart.TaiFexCom taifexcom, int amountthreshold, BuyMode buymode, StopLossMode stoplossmode, LockGainMode lockgainmode)
        {
            this.stockid   = stockid;
            this.quotecom  = quotecom;
            this.taifexcom = taifexcom;
            this.brokerid  = brokerid;
            this.account   = account;
            this.BuyQty    = BuyQty;
            //this.StopLossRatio = stoplossratio;
            //this.LockGainPrice = lockgainprice;
            this.AmountThreshold = amountthreshold;
            this.buy_mode        = buymode;
            this.stoplossmode    = stoplossmode;
            this.lockgainmode    = lockgainmode;

            this.trade_status = TradeStatus.StandBy;
            OnStatusChange(this.trade_status, stockid + ":待命中");

            //初始化成交明細下載目錄
            this.MatchLogFolder = Path.Combine(Directory.GetCurrentDirectory(), DateTime.Now.ToString("yyyyMMdd"));
            //建立目錄
            if (!Directory.Exists(this.MatchLogFolder))
            {
                Directory.CreateDirectory(this.MatchLogFolder);
            }
        }
Ejemplo n.º 11
0
 public static void SendTradeStatus(IPacketReceiver client, TradeStatus tradeStatus)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS))
     {
         packet.WriteUInt((uint)tradeStatus);
         client.Send(packet, false);
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Sets new status of trade and sends notification about the change to both parties
 /// </summary>
 /// <param name="status">new status</param>
 private void SendStatus(TradeStatus status, bool notifySelf = true)
 {
     if (notifySelf)
     {
         TradeHandler.SendTradeStatus(m_chr.Client, status);
     }
     TradeHandler.SendTradeStatus(OtherWindow.m_chr.Client, status);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Sets new status of trade and sends notification about the change to both parties
 /// </summary>
 /// <param name="status">new status</param>
 private void SendStatus(TradeStatus status, bool notifySelf = true)
 {
     if (notifySelf)
     {
         TradeHandler.SendTradeStatus((IPacketReceiver)this.m_chr.Client, status);
     }
     TradeHandler.SendTradeStatus((IPacketReceiver)this.OtherWindow.m_chr.Client, status);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Sends the notification about the change of trade status and stops the trade
 /// </summary>
 /// <param name="status">new status</param>
 /// <param name="notifySelf">whether to notify the caller himself</param>
 internal void StopTrade(TradeStatus status, bool notifySelf)
 {
     SendStatus(status, notifySelf);
     m_chr.TradeWindow             = null;
     m_chr                         = null;
     OtherWindow.m_chr.TradeWindow = null;
     OtherWindow.m_chr             = null;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Sends the notification about the change of trade status and stops the trade
 /// </summary>
 /// <param name="status">new status</param>
 /// <param name="notifySelf">whether to notify the caller himself</param>
 internal void StopTrade(TradeStatus status, bool notifySelf)
 {
     this.SendStatus(status, notifySelf);
     this.m_chr.TradeWindow             = (TradeWindow)null;
     this.m_chr                         = (Character)null;
     this.OtherWindow.m_chr.TradeWindow = (TradeWindow)null;
     this.OtherWindow.m_chr             = (Character)null;
 }
Ejemplo n.º 16
0
 public TradeOffer(OfferSession session, SteamID partnerSteamdId)
 {
     Items               = new TradeStatus();
     IsOurOffer          = true;
     OfferState          = TradeOfferState.TradeOfferStateUnknown;
     this.Session        = session;
     this.PartnerSteamId = partnerSteamdId;
 }
Ejemplo n.º 17
0
 private void OnFill(Order o)
 {
     if (o.IsTakeProfitOrder /*&& o.BoundTo.ID!=null && o.BoundTo.ID == tradeResult.Id*/)
     {
         tradeStatus = TradeStatus.Allow;
         tradeResult = OperationHandler(PositionSide.Long);
     }
 }
 public Commited(string number, string name, double costPrice, int unit, TradeStatus status)
 {
     this.Number        = number;
     this.Name          = name;
     this.CostPrice     = costPrice;
     this.Unit          = unit;
     this.TradingStatus = status;
 }
Ejemplo n.º 19
0
        /// <inheritdoc />
        public ServerTradeStatusPayload(TradeStatus status)
        {
            if (!Enum.IsDefined(typeof(TradeStatus), status))
            {
                throw new InvalidEnumArgumentException(nameof(status), (int)status, typeof(TradeStatus));
            }

            Status = status;
        }
Ejemplo n.º 20
0
 public GetOrdersResponse Get(string fromCoin, string toCoin, TradeStatus tradeStatus, TradeLevel tradeLevel)
 {
     return
         this.CallMethod<GetOrdersResponse>(
             new RequestBuilder(RequestType.GET, "trades")
             .AddUrlSegment(new CoinsPairSegment(fromCoin, toCoin))
             .AddUrlSegment(tradeStatus)
             .AddUrlSegment(tradeLevel));
 }
Ejemplo n.º 21
0
        public TradeOffer(OfferSession session, Offer offer)
        {
            var myAssets           = new List <TradeStatusUser.TradeAsset>();
            var myMissingAssets    = new List <TradeStatusUser.TradeAsset>();
            var theirAssets        = new List <TradeStatusUser.TradeAsset>();
            var theirMissingAssets = new List <TradeStatusUser.TradeAsset>();

            if (offer.ItemsToGive != null)
            {
                foreach (var asset in offer.ItemsToGive)
                {
                    var tradeAsset = new TradeStatusUser.TradeAsset();
                    //todo: for currency items we need to check descriptions for currency bool and use the appropriate method
                    tradeAsset.CreateItemAsset(Convert.ToInt64(asset.AppId), Convert.ToInt64(asset.ContextId),
                                               Convert.ToInt64(asset.AssetId), Convert.ToInt64(asset.Amount));
                    //todo: for missing assets we should store them somewhere else? if offer state is active we shouldn't be here though
                    if (!asset.IsMissing)
                    {
                        myAssets.Add(tradeAsset);
                    }
                    else
                    {
                        myMissingAssets.Add(tradeAsset);
                    }
                }
            }
            if (offer.ItemsToReceive != null)
            {
                foreach (var asset in offer.ItemsToReceive)
                {
                    var tradeAsset = new TradeStatusUser.TradeAsset();
                    tradeAsset.CreateItemAsset(Convert.ToInt64(asset.AppId), Convert.ToInt64(asset.ContextId),
                                               Convert.ToInt64(asset.AssetId), Convert.ToInt64(asset.Amount));
                    if (!asset.IsMissing)
                    {
                        theirAssets.Add(tradeAsset);
                    }
                    else
                    {
                        theirMissingAssets.Add(tradeAsset);
                    }
                }
            }
            this.Session = session;
            //assume public individual
            PartnerSteamId = new SteamID(Convert.ToUInt32(offer.AccountIdOther), EUniverse.Public, EAccountType.Individual);
            TradeOfferId   = offer.TradeOfferId;
            OfferState     = offer.TradeOfferState;
            IsOurOffer     = offer.IsOurOffer;
            ExpirationTime = offer.ExpirationTime;
            TimeCreated    = offer.TimeCreated;
            TimeUpdated    = offer.TimeUpdated;
            TradeID        = offer.TradeID;
            Message        = offer.Message;
            Items          = new TradeStatus(myAssets, theirAssets);
        }
Ejemplo n.º 22
0
 public Trade(long id, string bank, string ccyPair, TradeStatus status, BuyOrSell buySell, decimal tradePrice, int amount)
 {
     EntityId     = $"{id}";
     Customer     = bank;
     CurrencyPair = ccyPair;
     Status       = status;
     BuyOrSell    = buySell;
     MarketPrice  = TradePrice = tradePrice;
     Amount       = amount;
 }
        /// <inheritdoc />
        public SMSG_TRADE_STATUS_Payload(TradeStatus status)
            : this()
        {
            if (!Enum.IsDefined(typeof(TradeStatus), status))
            {
                throw new InvalidEnumArgumentException(nameof(status), (int)status, typeof(TradeStatus));
            }

            Status = status;
        }
Ejemplo n.º 24
0
        private Models.ITradeStatus GetStatus()
        {
            ProductType   productType = Utils.GetProductType(this.Currency);
            ProductTicker ticker      = client.GetProductTickerSync(productType);

            TradeStatus status = new TradeStatus();

            status.Price = ticker.Price;
            return(status);
        }
Ejemplo n.º 25
0
 public Trade(Trade trade, TradeStatus closed)
 {
     EntityId     = trade.EntityId;
     Customer     = trade.Customer;
     CurrencyPair = trade.CurrencyPair;
     Status       = closed;
     BuyOrSell    = trade.BuyOrSell;
     MarketPrice  = TradePrice = trade.TradePrice;
     Amount       = trade.Amount;
     MarketPrice  = trade.MarketPrice;
 }
Ejemplo n.º 26
0
 public Trade(Trade trade, TradeStatus status)
 {
     Id           = trade.Id;
     Customer     = trade.Customer;
     CurrencyPair = trade.CurrencyPair;
     Status       = status;
     MarketPrice  = trade.MarketPrice;
     TradePrice   = trade.TradePrice;
     Amount       = trade.Amount;
     Timestamp    = DateTime.Now;
 }
Ejemplo n.º 27
0
 public Trade(Guid id, DateTime date, string counterparty, string asset, TradeStatus status, TradeWay way, double price, double volume)
 {
     _id           = id;
     _date         = date;
     _counterparty = counterparty;
     _asset        = asset;
     _status       = status;
     _way          = way;
     _price        = price;
     _volume       = volume;
 }
Ejemplo n.º 28
0
 public Trade(TradeOffers tradeOffers, SteamID partnerId, SteamWeb steamWeb)
 {
     this.TradeOffers       = tradeOffers;
     this.partnerId         = partnerId;
     this.steamWeb          = steamWeb;
     tradeStatus            = new TradeStatus();
     tradeStatus.version    = 1;
     tradeStatus.newversion = true;
     tradeStatus.me         = new TradeStatusUser(ref tradeStatus);
     tradeStatus.them       = new TradeStatusUser(ref tradeStatus);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// This updates the trade.  This is called at an interval of a
        /// default of 800ms, not including the execution time of the
        /// method itself.
        /// </summary>
        /// <returns><c>true</c> if the other trade partner performed an action; otherwise <c>false</c>.</returns>
        public bool Poll()
        {
            if (!TradeStarted)
            {
                TradeStarted = true;

                // since there is no feedback to let us know that the trade
                // is fully initialized we assume that it is when we start polling.
                if (OnAfterInit != null)
                {
                    OnAfterInit();
                }
            }

            TradeStatus status = RetryWebRequest(session.GetStatus);

            if (status == null)
            {
                return(false);
            }

            TradeStatusType tradeStatusType = (TradeStatusType)status.trade_status;

            switch (tradeStatusType)
            {
            // Nothing happened. i.e. trade hasn't closed yet.
            case TradeStatusType.OnGoing:
                return(HandleTradeOngoing(status));

            // Successful trade
            case TradeStatusType.CompletedSuccessfully:
                HasTradeCompletedOk = true;
                return(false);

            // Email/mobile confirmation
            case TradeStatusType.PendingConfirmation:
                IsTradeAwaitingConfirmation = true;
                tradeOfferID = long.Parse(status.tradeid);
                return(false);

            //On a status of 2, the Steam web code attempts the request two more times
            case TradeStatusType.Empty:
                numUnknownStatusUpdates++;
                if (numUnknownStatusUpdates < 3)
                {
                    return(false);
                }
                break;
            }

            FireOnStatusErrorEvent(tradeStatusType);
            OtherUserCancelled = true;
            return(false);
        }
Ejemplo n.º 30
0
 public Trade(long id, string customer, string currencyPair, TradeStatus status, decimal tradePrice, decimal amount, decimal marketPrice = 0, DateTime?timeStamp = null)
 {
     Id           = id;
     Customer     = customer;
     CurrencyPair = currencyPair;
     Status       = status;
     MarketPrice  = marketPrice;
     TradePrice   = tradePrice;
     Amount       = amount;
     Timestamp    = timeStamp.HasValue ? timeStamp.Value : DateTime.Now;
 }
Ejemplo n.º 31
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="ticker">The stock ticker symbol</param>
 /// <param name="shares">The number of shares to trade</param>
 /// <param name="tradeTradeType">TradeType.Buy or TradeType.Sell</param>
 /// <param name="tradeStatus">
 ///     A TradeStatus enum that describes the status of the
 ///     Trade
 /// </param>
 /// <param name="tadingSessionId">
 ///     Each trading session is given a unique identifier of type, Guid.
 ///     Either create a TradingSessionId if you are starting a trade. Or pass in the existing
 ///     TradingSessionId if you are part of a trade.
 /// </param>
 /// <param name="message">An arbitrary message</param>
 protected AbstractTrade(string ticker, int shares, TradeType tradeTradeType, TradeStatus tradeStatus,
     Guid tadingSessionId, string message = null)
 {
     Ticker = ticker;
     Shares = shares;
     TradeType = tradeTradeType;
     TadingSessionId = tadingSessionId;
     CreateTime = DateTime.UtcNow;
     TradeStatus = tradeStatus;
     Message = message;
 }
Ejemplo n.º 32
0
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="ticker">The stock ticker symbol</param>
 /// <param name="shares">The number of shares to trade</param>
 /// <param name="tradeTradeType">TradeType.Buy or TradeType.Sell</param>
 /// <param name="tradeStatus">
 ///     A TradeStatus enum that describes the status of the
 ///     Trade
 /// </param>
 /// <param name="tadingSessionId">
 ///     Each trading session is given a unique identifier of type, Guid.
 ///     Either create a TradingSessionId if you are starting a trade. Or pass in the existing
 ///     TradingSessionId if you are part of a trade.
 /// </param>
 /// <param name="message">An arbitrary message</param>
 protected AbstractTrade(string ticker, int shares, TradeType tradeTradeType, TradeStatus tradeStatus,
                         Guid tadingSessionId, string message = null)
 {
     Ticker          = ticker;
     Shares          = shares;
     TradeType       = tradeTradeType;
     TadingSessionId = tadingSessionId;
     CreateTime      = DateTime.UtcNow;
     TradeStatus     = tradeStatus;
     Message         = message;
 }
Ejemplo n.º 33
0
 public Trade(string currencyPair, Direction direction, long notional, string dealtCurrency, decimal spotRate, TradeStatus tradeStatus, DateTime tradeDate, long tradeId, string traderName, DateTime valueDate)
 {
     CurrencyPair = currencyPair;
     Direction = direction;
     Notional = notional;
     SpotRate = spotRate;
     TradeStatus = tradeStatus;
     TradeDate = tradeDate;
     TradeId = tradeId;
     TraderName = traderName;
     ValueDate = valueDate;
     DealtCurrency = dealtCurrency;
 }
Ejemplo n.º 34
0
 public Trade(TradeOffers tradeOffers, SteamID partnerId, SteamWeb steamWeb)
 {
     _tradeOffers = tradeOffers;
     _partnerId = partnerId;
     _steamWeb = steamWeb;
     tradeStatus = new TradeStatus
     {
         version = 1,
         newversion = true
     };
     tradeStatus.me = new TradeStatusUser(ref tradeStatus);
     tradeStatus.them = new TradeStatusUser(ref tradeStatus);
 }
Ejemplo n.º 35
0
 /// <summary>
 ///     设置交易状态
 /// </summary>
 /// <param name="status">交易状态</param>
 public void SetStatus(TradeStatus status)
 {
     switch (status)
     {
         case TradeStatus.开始:
             Status = TradeStatus.开始;
             break;
         case TradeStatus.进行中:
             Status = TradeStatus.进行中;
             break;
         case TradeStatus.撤销:
             Status = TradeStatus.撤销;
             IsClosed = true;
             CloseDate = DateTime.Now;
             break;
         case TradeStatus.完成:
             Status = TradeStatus.完成;
             IsClosed = true;
             CloseDate = DateTime.Now;
             break;
         default:
             throw new ArgumentOutOfRangeException("status");
     }
 }
 /// <summary>
 /// 取得成交後的漲幅狀態。
 /// </summary>
 /// <param name="latestTradePrice">最新成交價</param>
 /// <param name="lastTradePrice">上一個成交價</param>
 /// <param name="lastTradeStatus">上一個成交後的漲幅狀態</param>
 /// <returns></returns>
 public static TradeStatus GetTradeStatus(float latestTradePrice, float lastTradePrice, TradeStatus lastTradeStatus)
 {
     if (latestTradePrice == lastTradePrice)
         return lastTradeStatus;
     else if (latestTradePrice > lastTradePrice)
         return TradeStatus.Rise;
     else if (latestTradePrice < lastTradePrice)
         return TradeStatus.Fall;
     else
         return TradeStatus.Opening;
 }
Ejemplo n.º 37
0
 public Trade(string ticker, int shares, TradeType tradeTradeType, TradeStatus tradeStatus, Guid tadingSessionId,
     string message = null) : base(ticker, shares, tradeTradeType, tradeStatus, tadingSessionId, message)
 {
 }
Ejemplo n.º 38
0
 /// <summary>
 /// 获取三个月内交易状态的所有订单
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="status">交易状态</param>
 /// <param name="error">如果出错,则储存错误信息,否则为空。</param>
 /// <param name="trades">如果成功,返回未发货订单的list。否则为null</param>
 /// <returns>如果操作成功,则返回true。否则为false。</returns>
 public static bool GetTrades(string sessionKey, TradeStatus status, out List<Trade> trades)
 {
     return GetTrades(sessionKey, status, DateTime.Now.AddMonths(-3), DateTime.Now, null, null, out trades);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Cancels the trade
 /// </summary>
 public void Cancel(TradeStatus status = TradeStatus.Cancelled)
 {
     StopTrade(status, true);
 }
Ejemplo n.º 40
0
		/// <summary>
		/// Sets new status of trade and sends notification about the change to both parties
		/// </summary>
		/// <param name="status">new status</param>
		private void SetTradeStatus(TradeStatus status)
		{
			Other.m_status = m_status = status;

			if (m_chr != null)
				TradeHandler.SendTradeStatus(m_chr.Client, m_status);

			if (Other.m_chr != null)
				TradeHandler.SendTradeStatus(Other.m_chr.Client, m_status);
		}
Ejemplo n.º 41
0
		public static void SendTradeStatus(IPacketReceiver client, TradeStatus tradeStatus)
		{
			using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS))
			{
				pkt.WriteUInt((uint)tradeStatus);

				client.Send(pkt);
			}
		}
Ejemplo n.º 42
0
        void HandleTradeVersionChange(TradeStatus status)
        {
            CopyNewAssets(OtherOfferedItems, status.them.GetAssets());

            CopyNewAssets(steamMyOfferedItems, status.me.GetAssets());
        }
Ejemplo n.º 43
0
 private void Throw(TradeStatus status)
 {
     string originalDesc = Tlw.ZPG.Infrastructure.Utils.EnumUtil.GetDescription(this.Status);
     string targetDesc = Tlw.ZPG.Infrastructure.Utils.EnumUtil.GetDescription(status);
     throw new DomainException(string.Format("����������״̬��ԭ״̬��{0}��Ŀ��״̬��{1}", originalDesc, targetDesc));
 }
Ejemplo n.º 44
0
 /// <summary>
 /// 根据条件获取交易列表
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="status">交易状态</param>
 /// <param name="startDateTime">开始时间</param>
 /// <param name="endDateTime">结束时间</param>
 /// <param name="pageSize">每页数量</param>
 /// <param name="pageNum">页数(第几页)</param>
 /// <param name="error">如果出错,则储存错误信息,否则为空。</param>
 /// <param name="trades">如果成功,返回未发货订单的list。否则为null</param>
 /// <returns>如果操作成功,则返回true。否则为false。</returns>
 public static bool GetTrades(string sessionKey, TradeStatus status, DateTime startDateTime, DateTime endDateTime, long? pageSize, long? pageNum, out List<Trade> trades)
 {
     bool isSuccess = false;
     trades = null;
     try
     {
         ITopClient client = new DefaultTopClient(Constants.ApiUrl, Constants.AppKey, Constants.AppSecret);
         TradesSoldGetRequest req = new TradesSoldGetRequest();
         req.Fields = "tid,buyer_nick,receiver_state,receiver_city,receiver_address,receiver_mobile";
         req.Status = Enum.GetName(typeof(TradeStatus), status);
         req.StartCreated = startDateTime;
         req.EndCreated = endDateTime;
         req.EndCreated = DateTime.Now;
         req.PageNo = pageNum;
         req.PageSize = pageSize;
         TradesSoldGetResponse rsp = client.Execute(req, sessionKey);
         trades = rsp.Trades;
         isSuccess = true;
     }
     catch (Exception ex)
     {
         errorMsg = ex.Message;
     }
     return isSuccess;
 }
Ejemplo n.º 45
0
 public Trade(TradeOffers tradeOffers, SteamID partnerId, SteamWeb steamWeb)
 {
     this.TradeOffers = tradeOffers;
     this.partnerId = partnerId;
     this.steamWeb = steamWeb;
     tradeStatus = new TradeStatus();
     tradeStatus.version = 1;
     tradeStatus.newversion = true;
     tradeStatus.me = new TradeStatusUser(ref tradeStatus);
     tradeStatus.them = new TradeStatusUser(ref tradeStatus);
 }
Ejemplo n.º 46
0
		/// <summary>
		/// Puts creature into waiting mode.
		/// </summary>
		/// <param name="creature"></param>
		private void Wait(Creature creature)
		{
			this.Status = TradeStatus.NotReady;

			Send.TradeWait(this.Creature1, 4000);
			Send.TradeWait(this.Creature2, 4000);
		}
Ejemplo n.º 47
0
 /// <summary>
 /// 获取某个时间段内交易状态的所有订单
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="status">交易状态</param>
 /// <param name="startDateTime">开始时间</param>
 /// <param name="endDateTime">结束时间</param>
 /// <param name="error">如果出错,则储存错误信息,否则为空。</param>
 /// <param name="trades">如果成功,返回未发货订单的list。否则为null</param>
 /// <returns>如果操作成功,则返回true。否则为false。</returns>
 public static bool GetTrades(string sessionKey, TradeStatus status, DateTime startDateTime, DateTime endDateTime, out List<Trade> trades)
 {
     return GetTrades(sessionKey, status, startDateTime, endDateTime, null, null, out trades);
 }
Ejemplo n.º 48
0
		/// <summary>
		/// Sends the notification about the change of trade status and stops the trade
		/// </summary>
		/// <param name="status">new status</param>
		/// <param name="notifySelf">whether to notify the caller himself</param>
		private void StopTrade(TradeStatus status, bool notifySelf)
		{
			Other.Status = m_status = status;

			if (m_chr != null)
			{
				if (notifySelf)
					TradeHandler.SendTradeStatus(m_chr.Client, m_status);

				m_chr.TradeInfo = null;
			}

			if (Other.m_chr != null)
			{
				TradeHandler.SendTradeStatus(Other.m_chr.Client, m_status);
				Other.m_chr.TradeInfo = null;
			}
		}
Ejemplo n.º 49
0
 private void SetStatus(TradeStatus status)
 {
     this.PrevStatus = this.Status;
     this.StatusTime = DateTime.Now;
     this.Status = status;
 }
Ejemplo n.º 50
0
 public TradeStatusUser(ref TradeStatus tradeStatus)
 {
     this.tradeStatus = tradeStatus;
     ready = false;
     assets = new List<TradeAsset>();
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Sets new status of trade and sends notification about the change to both parties
 /// </summary>
 /// <param name="status">new status</param>
 private void SendStatus(TradeStatus status, bool notifySelf = true)
 {
     if (notifySelf)
     {
         TradeHandler.SendTradeStatus(m_chr.Client, status);
     }
     TradeHandler.SendTradeStatus(OtherWindow.m_chr.Client, status);
 }
Ejemplo n.º 52
0
        /// <summary>
        /// Sends the notification about the change of trade status and stops the trade
        /// </summary>
        /// <param name="status">new status</param>
        /// <param name="notifySelf">whether to notify the caller himself</param>
        internal void StopTrade(TradeStatus status, bool notifySelf)
        {
            SendStatus(status, notifySelf);

            m_chr.TradeWindow = null;
            m_chr = null;

            OtherWindow.m_chr.TradeWindow = null;
            OtherWindow.m_chr = null;
        }
Ejemplo n.º 53
0
 /// <summary>
 /// 获取三个月内交易状态的部分订单(按页显示)
 /// </summary>
 /// <param name="sessionKey"></param>
 /// <param name="status">交易状态</param>
 /// <param name="startDateTime">开始时间</param>
 /// <param name="endDateTime">结束时间</param>
 /// <param name="error">如果出错,则储存错误信息,否则为空。</param>
 /// <param name="trades">如果成功,返回未发货订单的list。否则为null</param>
 /// <returns>如果操作成功,则返回true。否则为false。</returns>
 public static bool GetTrades(string sessionKey, TradeStatus status, long? pageSize, long? pageNum, out List<Trade> trades)
 {
     return GetTrades(sessionKey, status, DateTime.Now.AddMonths(-3), DateTime.Now,pageSize,pageNum, out trades);
 }