本文整理汇总了C#中Trade.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Trade.ToString方法的具体用法?C# Trade.ToString怎么用?C# Trade.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trade
的用法示例。
在下文中一共展示了Trade.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: SimBroker_GotFill
void SimBroker_GotFill(Trade t)
{
FillCount++;
try {
args.Response.GotFill(t);
}
catch (Exception ex) { debug("on fill: "+t.ToString()+" response threw exception: " + ex.Message); }
}
示例4: GotFill
public virtual void GotFill(Trade f)
{
if (f.id == 0)
{
debug(f.symbol + " can't track order with blank id!: " + f.ToString());
return;
}
int idx = sent.getindex(f.id.ToString());
if (idx < 0)
{
debug("unknown fillid: " + f.id);
return;
}
filled[idx] += (f.side ? 1 : -1) *Math.Abs(f.xsize);
v(f.symbol + " filled size: " + filled[idx] + " after: " + f.ToString());
}
示例5: tl_gotFill
void tl_gotFill(Trade t)
{
debug("fill: " + t.ToString());
if (InvokeRequired)
Invoke(new FillDelegate(tl_gotFill), new object[] { t });
else
{
if (!t.isValid) return;
int oidx = orderidx(t.id); // get order id for this order
if (oidx != -1)
{
int osign = (t.side ? 1 : -1);
int signedtsize = t.xsize * osign;
int signedosize = (int)ordergrid["osize", oidx].Value;
if (signedosize == signedtsize) // if sizes are same whole order was filled, remove
ordergrid.Rows.RemoveAt(oidx);
else // otherwise remove portion that was filled and leave rest on order
ordergrid["osize", oidx].Value = Math.Abs(signedosize - signedtsize) * osign;
}
pt.Adjust(t);
UpdateSymbolTrade(GetSymbolRows(t.Sec.FullName),t);
UpdateSymbolTrade(GetSymbolRows(t.Sec.Symbol),t);
TradesView.Rows.Add(t.xdate, t.xtime, t.symbol, (t.side ? "BUY" : "SELL"), t.xsize, t.xprice.ToString(_dispdecpointformat), t.comment, t.Account.ToString()); // if we accept trade, add it to list
}
}
示例6: fill
void fill(Trade fill, long id)
{
if (fill.id == 0)
{
debug("no id on fill: " + fill.ToString());
fill.id = (id!=0) ? id : ot.Ids.AssignId;
}
bool hit = false;
for (int i = profits.Count - 1; i >= 0; i--)
if ((profits[i].id == fill.id) && (profits[i].UnsignedSize==fill.UnsignedSize))
{
debug("filled profit: " + fill.id);
hit = true;
profits.RemoveAt(i);
}
for (int i = stops.Count - 1; i >= 0; i--)
if ((stops[i].id == fill.id) && (stops[i].UnsignedSize==fill.UnsignedSize))
{
debug("filled stop: " + fill.id);
hit = true;
stops.RemoveAt(i);
}
ot.Adjust(fill);
}
示例7: Adjust
/// <summary>
/// this must be called once per position tracker, for each position update.
/// if you are using your own position tracker with this trailing stop(eg from offset tracker, or somewhere else)
/// you MUST call TrailTrackers Adjust and NOT call your position tracker's adjust
/// </summary>
/// <param name="fill"></param>
public void Adjust(Trade fill)
{
// get index for symbol
int idx = symidx(fill.symbol);
// only do following if we're tracking trail for this symbol
if (idx != NOSYM)
{
// get current position size
int psize = _pt[fill.symbol].UnsignedSize;
// get trailing information
OffsetInfo trail = _trail[idx];
// get actual position size after change
int asize = psize - fill.UnsignedSize;
// if expected and actual match, mark pending as false
if (esize[idx] == asize)
{
D(fill.symbol+" trailing stop completely filled with: " + fill.ToString());
_pendingfill[idx] = false;
}
else
v(fill.symbol + " trail partial fill: "+fill.ToString()+" e: " + esize[idx] + " != a: " + asize);
}
else
v(fill.symbol + " fill: "+fill.ToString()+" ignored while trail disabled.");
_pt.Adjust(fill);
// if we're flat now, make sure ref price is reset
if (_pt[fill.symbol].isFlat)
{
_ref[idx] = 0;
v(fill.symbol + " flat, reset trail reference price.");
}
}
示例8: GotFill
public virtual void GotFill(Trade f)
{
if (f.id == 0)
{
debug(f.symbol + " can't track order with blank id!: " + f.ToString());
return;
}
int idx = sent.getindex(f.id.ToString());
if (idx < 0)
{
debug("unknown fillid: " + f.id);
return;
}
filled[idx] += f.xsize;
}
示例9: _bf_gotFill
void _bf_gotFill(Trade t)
{
if (RewriteSecuritySymbols)
{
Security sec;
if (allbaskets.TryGetSecurityAnySymbol(t.symbol, out sec))
{
t.symbol = sec.FullName;
}
}
debug(t.symbol+ " fill: " + t.ToString());
if (actfill!= null)
actfill.GotFill(t);
if (rfill != null)
{
try
{
rfill.GotFill(t);
}
catch (Exception ex)
{
debug(rname + " got fill error: " + ex.Message + ex.StackTrace + " on fill : " + t.ToString());
status(rname + " fill error, see debug for details.");
}
}
}
示例10: GotFill
public override 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 > _profit) || (openpl< _loss))
shutdown();
if (pt[Asym].isFlat && pt[Bsym].isFlat)
{
entrysignal = false;
exitsignal = false;
}
}
示例11: tl_gotFill
void tl_gotFill(Trade t)
{
// track results
_rs.GotFill(t);
// keep track of position
_pt.Adjust(t);
// send trade notification to any valid requesting responses
for (int i = 0; i < _reslist.Count; i++)
{
if (handleresponseexception)
{
if ((_reslist[i] == null) || !_reslist[i].isValid)
continue;
else
{
try
{
_reslist[i].GotFill(t);
}
catch (Exception ex)
{
notifyresponseexception(i, t.xtime, t.ToString(), ex);
}
}
}
else
_reslist[i].GotFill(t);
}
}
示例12: newFill
public void newFill(Trade trade, bool allclients)
{
// make sure our trade is filled and initialized properly
if (!trade.isValid)
{
debug("invalid trade: " + trade.ToString());
return;
}
for (int i = 0; i < client.Count; i++) // send tick to each client that has subscribed to tick's stock
if ((client[i] != null) && (allclients || (stocks[i].Contains(trade.symbol))))
TLSend(TradeImpl.Serialize(trade), MessageTypes.EXECUTENOTIFY, i);
}
示例13: GotFill
public virtual void GotFill(Trade f)
{
if (f.id == 0)
{
debug(f.symbol + " can't track order with blank id!: " + f.ToString());
return;
}
int idx = sent.getindex(f.id.ToString());
if (idx < 0)
{
debug("no existing order found with fillid: " + f.id);
idx = orders.addindex(f.id.ToString(), new OrderImpl());
unknownsent[idx] = true;
}
filled[idx] += (f.side ? 1 : -1) *Math.Abs(f.xsize);
if (FixSentSizeOnUnknown && unknownsent[idx])
sent[idx] = filled[idx];
v(f.symbol + " filled size: " + filled[idx] + " after: " + f.ToString());
}