コード例 #1
0
ファイル: Account.cs プロジェクト: cuj74/imperatur_market
        public bool SellHoldingFromAccount(int Quantity, string Ticker, ITradeHandlerInterface TradeHandler, string ProcessCode = "Manual")
        {
            //first check that the quantity does not exceed the quantity of the security on the account
            IMoney GAA = GetGAAFromHolding(Quantity, Ticker);
            //calculate revenue from the current ticker
            Quote           HoldingTicker = ImperaturGlobal.Quotes.Where(q => q.Symbol.Equals(Ticker)).First();
            IMoney          oRevenue      = GetRevenueFromHoldingSell(Quantity, Ticker);
            ITradeInterface Trade         = TradeHandler.GetTrade(Ticker, Quantity, DateTime.Now, oRevenue); //minus for sell

            try
            {
                AddTransaction(
                    CreateTransaction(
                        Trade.TradeAmount,
                        GetHouseAccountFromCache().First(),
                        this.Identifier,
                        TransactionType.Sell,
                        Trade,
                        ProcessCode
                        )
                    );
            }
            catch (Exception ex)
            {
                ImperaturGlobal.GetLog().Error(string.Format("Couldn't create transaction for sell on account {0}", this.Identifier), ex);
                LastErrorMessage = ex.Message;
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: Account.cs プロジェクト: cuj74/imperatur_market
        public bool AddHoldingToAccount(int Quantity, string Symbol, ITradeHandlerInterface TradeHandler, string ProcessCode = "Manual")
        {
            ITradeInterface Trade = TradeHandler.GetTrade(Symbol, Quantity);

            try
            {
                AddTransaction(
                    CreateTransaction(
                        Trade.TradeAmount,
                        this.Identifier,
                        GetHouseAccountFromCache().First(),
                        TransactionType.Buy,
                        Trade,
                        ProcessCode
                        )
                    );
            }
            catch (Exception ex)
            {
                ImperaturGlobal.GetLog().Error(string.Format("Couldn't add transaction to account {0}", this.Identifier), ex);
                LastErrorMessage = ex.Message;
                return(false);
            }
            return(true);
        }