• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Trade类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Trade的典型用法代码示例。如果您正苦于以下问题:C# Trade类的具体用法?C# Trade怎么用?C# Trade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Trade类属于命名空间,在下文中一共展示了Trade类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetAllTrades

        public Trade[] GetAllTrades(QueryRule query, IList<string> filterOutTrades)
        {
            var allTrades = TradeRepository.GetAllTrades(query);

            if (allTrades != null && allTrades.Length > 0 && 
                filterOutTrades != null && filterOutTrades.Count > 0)
            {                
                var tempMapper = new Dictionary<string, Trade>();
                foreach(var item in allTrades)
                {
                    tempMapper[item.Id] = item; 
                }

                foreach(var item in filterOutTrades)
                {
                    tempMapper.Remove(item);
                }

                var values = tempMapper.Values;

                allTrades = new Trade[values.Count];
                values.CopyTo(allTrades, 0);
            }

            return allTrades;
        }
开发者ID:UGuest,项目名称:UGuestNotification,代码行数:26,代码来源:TradeService.cs


示例2: GetClearingID

        protected string GetClearingID(Trade trade, string name)
        {
            // find which allocation number we are
            var allocNo = GetAllocationNo(trade);

            // there are number of entries for each allocation, need to find the one with clearing ID
            int entryNo = 1;
            bool found = true;
            do
            {
                var eventProperty = String.Format("{0}:{1}:{2}", sConfirmRegReportingEvent, allocNo, entryNo);
                var typeProperty = String.Format("{0}:{1}:{2}", sConfirmRegReportingType, allocNo, entryNo);
                if(!trade.Properties.ContainsKey(eventProperty) || !trade.Properties.ContainsKey(typeProperty))
                {
                    found = false;
                }
                else
                {
                    var eventValue = trade.GetProperty(eventProperty);
                    var typeValue = trade.GetProperty(typeProperty);
                    if(eventValue == "2" && typeValue == "0")
                    {
                        // this is it, Event = Clearing, Type = Current
                        var propertyToRetrieve = String.Format("{0}:{1}:{2}", name, allocNo, entryNo);
                        return trade.GetProperty(propertyToRetrieve);
                    }
                }
                entryNo++;
            } while (found);
            return String.Empty;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:31,代码来源:SymmetrySEFClearingTradeImportExport.cs


示例3: GotFill

 public override void GotFill(Trade fill)
 {
     // make sure fills are tracked as positions
     pt.Adjust(fill);
     // send profit order for this new position
     sendoffset(fill.symbol);
 }
开发者ID:antonywu,项目名称:tradelink,代码行数:7,代码来源:OpenCancel.cs


示例4: GetPayerReceiver

 /* 
  * Copied from Orchestrade TradeBlotterData.cs
  * Changed signatures, etc. slightly to fit into this class
  * Required because Orchestrade did not want us to use the TradeBlotter API directly for exports
  * 
  */
 public static String GetPayerReceiver(Trade trade)
 {
     if (trade.Product == null) return null;
     if (trade.Product is Swap) return ((Swap)trade.Product).PayLeg.IsFixedRate ? "Payer" : "Receiver";
     if (trade.Product is InflationSwap) return ((InflationSwap)trade.Product).IsPay ? "Payer" : "Receiver";
     if (trade.Product is Swaption)
     {
         var sw = trade.Product as Swaption;
         return sw.OptionType == OptionType.Call ? "Receiver" : "Payer";
     }
     if (trade.Product is CapFloor)
     {
         var cf = trade.Product as CapFloor;
         return cf.Leg.IsPay ? "Payer" : "Receiver";
     }
     if (trade.Product is FRA)
     {
         var cf = trade.Product as FRA;
         return cf.IsPay ? "Payer" : "Receiver";
     }
     if (trade.Product is VarSwap)
     {
         var cf = trade.Product as VarSwap;
         return cf.IsBuy ? "Payer" : "Receiver";
     }
     return null;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:33,代码来源:TradeHelper.cs


示例5: ClosePT

 // these are for calculating closed pl
 // they do not adjust positions themselves
 /// <summary>
 /// Gets the closed PL on a per-share basis, ignoring how many shares are held.
 /// </summary>
 /// <param name="existing">The existing position.</param>
 /// <param name="closing">The portion of the position that's being closed/changed.</param>
 /// <returns></returns>
 public static decimal ClosePT(Position existing, Trade adjust)
 {
     if (!existing.isValid || !adjust.isValid) 
         throw new Exception("Invalid position provided. (existing:" + existing.ToString() + " adjustment:" + adjust.ToString());
     if (existing.isFlat) return 0; // nothing to close
     if (existing.isLong == adjust.side) return 0; // if we're adding, nothing to close
     return existing.isLong ? adjust.xprice- existing.AvgPrice: existing.AvgPrice- adjust.xprice;
 }
开发者ID:antonywu,项目名称:tradelink,代码行数:16,代码来源:Calc.cs


示例6: GotFill

 public void GotFill(Trade fill)
 {
     D("fill: "+fill.ToString());
     pt.Adjust(fill);
     decimal openpl = Calc.OpenPL(pairs.Aprice, pt[pairs.Asym]) + Calc.OpenPL(pairs.Bprice, pt[pairs.Bsym]);
     if ((openpl > 200) || (openpl< -100))
         shutdown();
 }
开发者ID:antonywu,项目名称:tradelink,代码行数:8,代码来源:PairsResponse.cs


示例7: TestMinimumAmounts

 public void TestMinimumAmounts()
 {
     Trade sale = new Trade(sunshine, 10.0f, 100, 60);
     Transaction t1 = new Transaction(p1, sale);
     // Quantity
     // Cost
     // Volume
 }
开发者ID:spiffydudex,项目名称:navbot,代码行数:8,代码来源:TransactionTest.cs


示例8: GotFill

 /// <summary>
 /// pass fills through here
 /// </summary>
 /// <param name="t"></param>
 public void GotFill(Trade t)
 {
     if (SendLatency == null) return;
     // see if we know this message
     long start = 0;
     if (!_otime.TryGetValue(t.id, out start)) return;
     double lat = new System.DateTime(gettime()).Subtract(new System.DateTime(start)).TotalMilliseconds;
     report(MessageTypes.EXECUTENOTIFY, t.id, lat);
 }
开发者ID:bluejack2000,项目名称:core,代码行数:13,代码来源:LatencyTracker.cs


示例9: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     sunshine = new ItemType(1, "Sunshine", 1.0f);
     cheap = new Trade(sunshine, 1.0f, 1000);
     expensive = new Trade(sunshine, 1000.0f, 1000);
     oneCheap = new Trade(sunshine, 1.0f, 1);
     oneExpensive = new Trade(sunshine, 1000.0f, 1);
     zero = new Trade(null, 0.0f, 0);
 }
开发者ID:spiffydudex,项目名称:navbot,代码行数:9,代码来源:TradeListTest.cs


示例10: TestConstructor

 public void TestConstructor()
 {
     Trade trade = new Trade(sunshine, 100.0f, 100);
     TransactionItem t1 = new TransactionItem(trade);
     TransactionItem t2 = new TransactionItem(trade, 50);
     TransactionItem t3 = new TransactionItem(trade, 150);
     Assert.AreEqual(100, t1.Quantity);
     Assert.AreEqual(50, t2.Quantity);
     Assert.AreEqual(100, t3.Quantity);
 }
开发者ID:spiffydudex,项目名称:navbot,代码行数:10,代码来源:TransactionItemTest.cs


示例11: GetNominal

 public static double GetNominal(Trade trade)
 {
     if (trade.Product != null)
     {
         if (trade.Product.IsMultiplyTraded) return trade.Quantity * trade.Product.Nominal;
         string ss = trade.Product.GetBuySell(trade);
         if (ss == null) return trade.Product.Nominal;
         return ss.Equals("Sell") ? Math.Abs(trade.Product.Nominal) * -1 : Math.Abs(trade.Product.Nominal);
     }
     return 0;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:11,代码来源:TradeHelper.cs


示例12: Adjust

 /// <summary>
 /// Adjust an existing position, or create new one if none exists.
 /// </summary>
 /// <param name="fill"></param>
 /// <returns>any closed PL for adjustment</returns>
 public decimal Adjust(Trade fill)
 {
     Position p;
     decimal cpl = 0;
     if (posdict.TryGetValue(fill.symbol, out p))
         cpl += posdict[fill.symbol].Adjust(fill);
     else
         posdict.Add(fill.symbol, new PositionImpl(fill));
     _totalclosedpl += cpl;
     return cpl;
 }
开发者ID:antonywu,项目名称:tradelink,代码行数:16,代码来源:PositionTracker.cs


示例13: IsExcluded

 public override bool IsExcluded(ProductEvent pevent, Trade trade, Market market)
 {
     var isExcluded = base.IsExcluded(pevent, trade, market);
     if (isExcluded) return true;
     if (trade.Product is Swap)
     {
         var swap = trade.Product as Swap;
         if (swap.PayLeg.IsFixedRate && swap.ReceiveLeg.IsFixedRate) return true;
     }
     return false;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:11,代码来源:SymmetrySEFIrsTradeImportExport.cs


示例14: Main

		static void Main()
		{
			// creating AAPL security
			var security = new Security
			{
				Id = "[email protected]",
				PriceStep = 0.1m,
				Decimals = 1,
			};

			var trades = new List<Trade>();

			// generation 1000 random ticks
			//

			for (var i = 0; i < 1000; i++)
			{
				var t = new Trade
				{
					Time = DateTime.Today + TimeSpan.FromMinutes(i),
					Id = i + 1,
					Security = security,
					Volume = RandomGen.GetInt(1, 10),
					Price = RandomGen.GetInt(1, 100) * security.PriceStep ?? 1m + 99
				};

				trades.Add(t);
			}

			using (var drive = new LocalMarketDataDrive())
			{
				// get AAPL storage
				var aaplStorage = drive.GetSecurityDrive(security);

				// get tick storage
				var tradeStorage = (IMarketDataStorage<Trade>)aaplStorage.GetTickStorage(new CsvMarketDataSerializer<ExecutionMessage>());

				// saving ticks
				tradeStorage.Save(trades);

				// loading ticks
				var loadedTrades = tradeStorage.Load(DateTime.Today, DateTime.Today + TimeSpan.FromMinutes(1000));

				foreach (var trade in loadedTrades)
				{
					Console.WriteLine(LocalizedStrings.Str2968Params, trade.Id, trade);
				}

				Console.ReadLine();

				// deleting ticks (and removing file)
				tradeStorage.Delete(DateTime.Today, DateTime.Today + TimeSpan.FromMinutes(1000));	
			}
		}
开发者ID:hbwjz,项目名称:StockSharp,代码行数:54,代码来源:Program.cs


示例15: EmitNewTradeEvent

 private void EmitNewTradeEvent(IFIXInstrument instrument, Trade trade)
 {
     if (NewTrade != null)
     {
         NewTrade(this, new TradeEventArgs(trade, instrument, this));
     }
     if (factory != null)
     {
         factory.OnNewTrade(instrument, trade);
     }
 }
开发者ID:jjgeneral,项目名称:OpenQuant-CTP,代码行数:11,代码来源:CTPProvider.MarketDataProvider.QD.cs


示例16: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     sunshine = new ItemType(1, "Sunshine", 1.5f);
     p1 = new Trade(sunshine, 1.0f, 100);
     p2 = new Trade(sunshine, 10.0f, 10);
     s1 = new Trade(sunshine, 5.0f, 100);
     s2 = new Trade(sunshine, 50.0f, 100);
     pt1 = new TransactionItem(p1);
     pt2 = new TransactionItem(p2);
     st1 = new TransactionItem(s1);
     st2 = new TransactionItem(s2);
 }
开发者ID:spiffydudex,项目名称:navbot,代码行数:12,代码来源:TransactionTest.cs


示例17: Check

        public bool Check(Trade trade)
        {
            Boolean result = true;
            var entity = Env.Current.StaticData.GetPartyById(trade.EntityId).Code;

            if (entity.Equals("SMF") && trade.Product.ProcessingType.Equals("FX") && trade.Product.UnderlierInfo.Equals("FX:USD:IDR"))
            {
                trade.SetProperty("OverridePB", "CGMI_PB_FI");
            }

            return result;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:12,代码来源:ScriptTestValidator3.cs


示例18: NewTrade

 public static AccountActivity NewTrade(Trade f, Position p)
 {
     var aa = new AccountActivity();
     aa.CurrentPos = p;
     aa.symbol = f.symbol;
     aa.side = f.xsize > 0;
     aa.id = f.id;
     aa.price = f.xprice;
     aa.size = f.xsize;
     aa.type = ActivityType.Fill;
     return aa;
 }
开发者ID:antonywu,项目名称:tradelink,代码行数:12,代码来源:AccountActivity.cs


示例19: Main

		static void Main()
		{
			// создаем тестовый инструмент
			var security = new Security
			{
				Id = "TestId",
				PriceStep = 0.1m,
				Decimals = 1,
			};

			var trades = new List<Trade>();

			// генерируем 1000 произвольных сделок
			//

			for (var i = 0; i < 1000; i++)
			{
				var t = new Trade
				{
					Time = DateTime.Today + TimeSpan.FromMinutes(i),
					Id = i + 1,
					Security = security,
					Volume = RandomGen.GetInt(1, 10),
					Price = RandomGen.GetInt(1, 100) * security.PriceStep ?? 1m + 99
				};

				trades.Add(t);
			}

			var storage = new StorageRegistry();

			// получаем хранилище для тиковых сделок
			var tradeStorage = storage.GetTradeStorage(security);

			// сохраняем сделки
			tradeStorage.Save(trades);

			// загружаем сделки
			var loadedTrades = tradeStorage.Load(DateTime.Today, DateTime.Today + TimeSpan.FromMinutes(1000));

			foreach (var trade in loadedTrades)
			{
				Console.WriteLine(LocalizedStrings.Str2968Params, trade.Id, trade);
			}

			Console.ReadLine();

			// удаляем сделки (очищаем файл)
			tradeStorage.Delete(DateTime.Today, DateTime.Today + TimeSpan.FromMinutes(1000));
		}
开发者ID:reddream,项目名称:StockSharp,代码行数:50,代码来源:Program.cs


示例20: Reconcile

 public override bool Reconcile(Trade otTrade, Trade externalTrade, Market market, bool fullMatch, DateTime reconciliationDate, IList<Exception> exceps)
 {
     var unmatchReason = string.Empty;
     var ref1 = otTrade.GetProperty(ReconcileTaskExecutor.Reconciled);
     if (ref1 != null && ref1.ToLowerInvariant().Equals("true")) return false;
     var ref2 = externalTrade.GetProperty(ReconcileTaskExecutor.Reconciled);
     if (ref2 != null && ref2.ToLowerInvariant().Equals("true")) return false;
     if (!(otTrade.Product.GetType() == externalTrade.Product.GetType())) return false;
     if (otTrade.BookId != externalTrade.BookId) return false;
     if (otTrade.PrimeBrokerId != externalTrade.PrimeBrokerId &&
         otTrade.ClearerId != externalTrade.ClearerId)
     {
         if (fullMatch) return false;
         unmatchReason += "Account ";
     }
     var prod1 = otTrade.Product;
     var prod2 = externalTrade.Product;
     var fut1 = prod1 as Future;
     var fut2 = prod2 as Future;
     if (fut1 != null && fut2 != null)
     {
         var ticker1 = fut1.Ticker;
         var ticker2 = fut2.Ticker;
         if (!string.IsNullOrEmpty(ticker1) && !string.IsNullOrEmpty(ticker2))
         {
             if (!ticker1.Equals(ticker2)) return false;
         }               
     }
     var fx1 = prod1 as FX;
     var fx2 = prod2 as FX;
     if (fx1 != null && fx2 != null)
     {
         if (!fx1.CurrencyPair.Equals(fx2.CurrencyPair)) return false;
         if (fullMatch)
         {
             if (Math.Abs(fx1.PrimaryAmount - fx2.PrimaryAmount) > Utilities.Epsilon) return false;
             if (Math.Abs(fx1.QuotingAmount - fx2.QuotingAmount) > Utilities.Epsilon) return false;
         }
         return true;
     }
     if (prod1 is Bond || prod1 is Equity)
     {
         if (prod1.Id != prod2.Id) return false;
     }
     if (fullMatch)
     {
         if (Math.Abs(otTrade.Quantity - externalTrade.Quantity) > Utilities.Epsilon) return false;
     }
     return true;
 }
开发者ID:heimanhon,项目名称:researchwork,代码行数:50,代码来源:ImaginePositionRecon.cs



注:本文中的Trade类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TradeBars类代码示例发布时间:2022-05-24
下一篇:
C# TrackingUniverseOrigin类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap