本文整理汇总了C#中Trade类的典型用法代码示例。如果您正苦于以下问题:C# Trade类的具体用法?C# Trade怎么用?C# Trade使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Trade类属于命名空间,在下文中一共展示了Trade类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例7: TestMinimumAmounts
public void TestMinimumAmounts()
{
Trade sale = new Trade(sunshine, 10.0f, 100, 60);
Transaction t1 = new Transaction(p1, sale);
// Quantity
// Cost
// Volume
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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);
}
}