本文整理汇总了C#中Tick类的典型用法代码示例。如果您正苦于以下问题:C# Tick类的具体用法?C# Tick怎么用?C# Tick使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tick类属于命名空间,在下文中一共展示了Tick类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestGetIndex
public void TestGetIndex()
{
var ts = new TickSeries("test");
for (int i = 0; i < 10; ++i)
ts.Add(new Tick { DateTime = new DateTime(2000, 1, 1, 10, i, 30) });
var firstDt = new DateTime(2000, 1, 1, 10, 3, 30);
var firstTick = new Tick { DateTime = firstDt };
var lastDt = new DateTime(2000, 1, 1, 10, 9, 30);
var lastTick = new Tick { DateTime = lastDt };
// DateTime is in the middle;
Assert.Equal(3, ts.GetIndex(firstDt, IndexOption.Null));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 25), IndexOption.Null));
Assert.Equal(4, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 30), IndexOption.Null));
Assert.Equal(4, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 30), IndexOption.Prev));
Assert.Equal(4, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 30), IndexOption.Next));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 25), IndexOption.Null));
Assert.Equal(3, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 25), IndexOption.Prev));
Assert.Equal(4, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 25), IndexOption.Next));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 40), IndexOption.Null));
Assert.Equal(4, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 40), IndexOption.Prev));
Assert.Equal(5, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 40), IndexOption.Next));
// DateTime > LastDateTime
Assert.Equal(5, ts.GetIndex(new DateTime(2000, 1, 1, 10, 4, 40), IndexOption.Next));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 10, 11, 30), IndexOption.Null));
Assert.Equal(9, ts.GetIndex(new DateTime(2000, 1, 1, 10, 11, 30), IndexOption.Prev));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 10, 11, 30), IndexOption.Next));
// DateTime < FirstDateTime
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 9, 31, 30), IndexOption.Null));
Assert.Equal(-1, ts.GetIndex(new DateTime(2000, 1, 1, 9, 31, 30), IndexOption.Prev));
Assert.Equal(0, ts.GetIndex(new DateTime(2000, 1, 1, 9, 31, 30), IndexOption.Next));
}
开发者ID:fastquant,项目名称:fastquant.dll,代码行数:32,代码来源:TickSeriesTest.cs
示例2: newTick
/// <summary>
/// passes ticks from a response to the form GUI elements, so user
/// can see the tick
/// </summary>
/// <param name="k"></param>
public void newTick(Tick k)
{
// update the screen with the tick
// if arriving from background thread,
// windows makes us update GUI elements by 'invoking'
// from the GUI's thread. so we test for this when performing the update.
if (InvokeRequired)
{
try
{
Invoke(new TickDelegate(newTick), new object[] { k });
}
catch (ObjectDisposedException) { return; }
}
else
{
// make sure tick matches symbol we requested
if (k.symbol != _sym.Text) return;
// put data in the form
if (k.hasAsk)
_ask.Text = k.ask.ToString("N2");
if (k.hasBid)
_bid.Text = k.bid.ToString("N2");
if (k.isTrade)
_last.Text = k.trade.ToString("N2");
// refresh form's screen area
Invalidate(true);
}
}
开发者ID:antonywu,项目名称:tradelink,代码行数:34,代码来源:Quotelet.cs
示例3: OnRenderFrame
protected override void OnRenderFrame(FrameEventArgs e)
{
Tick tick = new Tick();
base.OnRenderFrame(e);
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
m_camera.UpdateCameraView();
List<CoordinateEngine.RelativisticObject> ros = universe.GetNPCs();
lock (ros) {
foreach (CoordinateEngine.RelativisticObject ro in ros) {
DrawRelativisticObject (ro);
}
}
lock(universe.bro){
m_camera.camera_position = CoordinateEngine.toVector3(universe.bro.x);//Loses accuracy in this...
}
//DrawRelativisticObject(universe.bro, false);//Don't draw bro if the camera is at bro.
DrawHUD();
stats.AddValue(FPS_TAG, tick.Tock());
this.SwapBuffers();
Thread.Sleep(1);
}
开发者ID:tstein,项目名称:rope,代码行数:28,代码来源:canvas.cs
示例4: StockQuote
public StockQuote(string symbol, double price, DateTime date, Tick tick)
{
_symbol = symbol;
_price = price;
_date = date;
_tick = tick;
}
开发者ID:xyicheng,项目名称:Stocks,代码行数:7,代码来源:StockQuote.cs
示例5: newTick
/// <summary>
/// if new ticks are passed to this ticket, ticket will automatically update the price of limit and stops orders for opposing side.
/// </summary>
/// <param name="tick"></param>
public void newTick(Tick tick)
{
if (this.InvokeRequired)
{
try
{
Invoke(new TickDelegate(newTick), new object[] { tick });
}
catch (ObjectDisposedException) { return; }
}
else
{
if ((tick == null) || (tick.symbol != work.symbol)) return;
if (touched) return;
decimal changedval = obuybut.Checked ? (limitbut.Checked ? tick.ask : tick.bid) : (limitbut.Checked ? tick.bid : tick.ask);
if (changedval != 0)
{
if (this.oprice.InvokeRequired)
{
this.Invoke(new TickDelegate(newTick), new object[] { tick });
}
else oprice.Value = (decimal)changedval;
}
}
}
开发者ID:bluejack2000,项目名称:core,代码行数:30,代码来源:Ticket.cs
示例6: GotTick
public void GotTick(Tick tick)
{
// we want to see if this trade is one of the top 10 biggest
// get symbol from first tick if we haven't gotten one yet
if (sym == "") sym = tick.symbol;
else if (tick.symbol != sym) return;
// ignore it if it's not a trade
if (!tick.isTrade) return;
// if we don't have 10 trades yet, add it
if (dt.Rows.Count < 10)
{
dt.Rows.Add(tick.time, tick.trade, tick.size, tick.ex);
ui.dg.Invalidate(true); // update the grid
return;
}
// otherwise, go through list and check to see if it's bigger
for (int i = 0; i < dt.Rows.Count; i++)
if ((int)dt.Rows[i]["TradeSize"] < tick.size)
{
dt.Rows[i].ItemArray = new object[] { tick.time, tick.trade, tick.size, tick.ex };
ui.dg.InvalidateRow(i); // update the grid
return;
}
}
开发者ID:antonywu,项目名称:tradelink,代码行数:28,代码来源:BigTrades.cs
示例7: GotTick
public override void GotTick(Tick tick)
{
// create bars from ticks
_blt.newTick(tick);
// make sure we have enough bars our indicator
if (!_blt[tick.symbol].Has(MINBARS)) return;
// get highs from our bar
decimal[] highs = _blt[tick.symbol].High();
// get lows
decimal[] lows = _blt[tick.symbol].Low();
// compute high low ranges
decimal[] hlrange = Calc.Subtract(highs, lows);
// compute average range
decimal avghl = Calc.Avg(hlrange);
// ignore volatile symbols
if (avghl > MAXVOL) return;
// compute MA
decimal ma = Calc.Avg(_blt[tick.symbol].Close());
// trading rule
if (_pt[tick.symbol].isFlat && (_blt[tick.symbol].RecentBar.Close > ma))
sendorder(new BuyMarket(tick.symbol, 100));
// exit rule
if (_pt[tick.symbol].isLong && (_blt[tick.symbol].RecentBar.Close < ma))
sendorder(new MarketOrderFlat(_pt[tick.symbol]));
}
开发者ID:antonywu,项目名称:tradelink,代码行数:26,代码来源:LessonTradingRules.cs
示例8: newTick
public bool newTick(Tick t)
{
if ((t.symbol==null) || (t.symbol=="")) return false;
TikWriter tw;
if (filedict.TryGetValue(t.symbol, out tw))
{
try
{
tw.newTick(t);
}
catch (IOException) { return false; }
}
else
{
try
{
tw = new TikWriter(_path, t.symbol, t.date);
tw.newTick(t);
filedict.Add(t.symbol, tw);
}
catch (IOException) { return false; }
catch (Exception) { return false; }
}
return true;
}
开发者ID:antonywu,项目名称:tradelink,代码行数:26,代码来源:TickArchiver.cs
示例9: GotTick
public override void GotTick(Tick tick)
{
// track order ids
_orderid.addindex(tick.symbol,0);
// track ticks
_kt.newTick(tick);
// see if we need to send an order
if (_orderid[tick.symbol] == 0)
{
// get complete last tick for this symbol
Tick k = _kt[tick.symbol];
// see if we have proper info to place order
if ((Side && k.hasBid) || (!Side && k.hasAsk))
{
_orderid[tick.symbol] = _idt.NextId;
D(tick.symbol + " sending limit order: " + _orderid[tick.symbol]);
sendorder(new LimitOrder(tick.symbol, Side, Ordersize, Side ? k.bid - Distance : k.ask + Distance, _idt.AssignId));
}
}
else // otherwise increment counter
_tickcounter[tick.symbol]++;
// see if we need to cancel
if (_tickcounter[tick.symbol] > Frequency)
{
D(tick.symbol + " hit frequency, canceling: " + _orderid[tick.symbol]);
sendcancel(_orderid[tick.symbol]);
}
}
开发者ID:antonywu,项目名称:tradelink,代码行数:28,代码来源:LimitCancel.cs
示例10: OnTick
public override void OnTick(Tick tick)
{
// if pre-market tick, don't do anything
if (tick.Time < new TimeSpan(9, 30, 00))
return;
// send the market order; this should get filled immediately
Order value;
if (!Markets.TryGetValue(tick.Symbol, out value))
{
Order MktOrder = new Order(OrderSide.Buy, OrderType.Market, tick.Symbol, 100);
Markets.Add(tick.Symbol, MktOrder);
PlaceOrder(MktOrder);
log.DebugFormat("{0} {1}: Sent market order from within Strategy. Price: {2} Size: {3}",
MktOrder.Timestamp, MktOrder.Symbol, MktOrder.Price, MktOrder.Size);
}
// send the limit order; this should be expensive enough that it never gets filled
if(!Limits.TryGetValue(tick.Symbol, out value))
{
Order LimitOrder = new Order(OrderSide.Sell, OrderType.Limit, tick.Symbol, 100, 500);
Limits.Add(tick.Symbol, LimitOrder);
PlaceOrder(LimitOrder);
log.DebugFormat("{0} {1}: Sent limit order from within Strategy. Price: {2} Size: {3}",
LimitOrder.Timestamp, LimitOrder.Symbol, LimitOrder.Price, LimitOrder.Size);
}
}
开发者ID:Jack-coastal,项目名称:strategy,代码行数:29,代码来源:ManagingOrders.cs
示例11: GotTick
// GotTick is called everytime a new quote or trade occurs
public override void GotTick(Tick tick)
{
// make sure every tick has bars
blt.newTick(tick);
// if we don't have enough bars, wait for more ticks
if (!blt[tick.symbol].Has(BarsBack)) return;
// if we don't have a trade, wait to calculate indicators here
if (!tick.isTrade) return;
// this is a grey box that manages exits, so wait until we have a position
if (!pt[tick.symbol].isFlat) return;
// calculate the MA from closing bars
decimal MA = Calc.Avg(Calc.Closes(blt[tick.symbol], BarsBack));
// if we're short, a cross is when market moves above MA
// if we're long, cross is when market goes below MA
bool cross = pt[tick.symbol].isShort ? (tick.trade > MA) : (tick.trade < MA);
// if we have a cross, then flat us for the requested size
if (cross)
sendorder(new MarketOrderFlat(pt[tick.symbol],exitpercent));
// notify gauntlet and kadina about our moving average and cross
sendindicators(new string[] { MA.ToString(), cross.ToString() } );
}
开发者ID:antonywu,项目名称:tradelink,代码行数:30,代码来源:GreyExit.cs
示例12: ToEPF
/// <summary>
/// Converts the tick to a string-equivalent that can be written to an EPF file.
/// </summary>
/// <param name="t">The t.</param>
/// <returns></returns>
public static string ToEPF(Tick t)
{
string s = "";
if (!t.isTrade) s = "Q," + epfdate(t.date) + "," + epftime(t.time) + "," + t.bid + "," + t.ask + "," + t.bs + "," + t.os + "," + t.be + "," + t.oe;
else s = "T," + epfdate(t.date) + "," + epftime(t.time) + "," + t.trade + "," + (t.size) + "," + t.ex;
return s;
}
开发者ID:antonywu,项目名称:tradelink,代码行数:12,代码来源:eSigTick.cs
示例13: OnTick
/// <summary>
/// 收到tick事件,在这里添加策略逻辑。我们简单的每10个tick开仓/平仓,以最新价下单。
/// </summary>
/// <param name="tick"></param>
public override void OnTick(Tick tick)
{
Console.WriteLine(
"tick {0}: time={1} symbol={2} last_price={3} :",
HGStaUtil.getTickZF(tick),
tick.utc_time,
tick.sec_id,
tick.last_price);
double cutZf = 0;
//大盘涨幅达到1的时候买入头寸
if (HGStaUtil.isSHTick(tick) && HGStaUtil.getTickZF(tick) >= 1 && !buyFlag)
{
cutZf = HGStaUtil.getTickZFFrmLastBuy(tick, lastDpZf);
if (lastDpZs == 0 || cutZf >= 1)
{
buyFlag = true;
Console.WriteLine("lastDpZs {0} cutZf {1}:", lastDpZs, cutZf);
}
}
else if (!HGStaUtil.isSHTick(tick) && buyFlag)
{
Console.WriteLine("buyFlag {0} buycode {1}:", buyFlag, tick.sec_id);
OpenLong(tick.exchange, tick.sec_id, tick.last_price, 100); //最新价开仓一手
buyFlag = false;
}
lastDpZs = tick.last_price;
}
开发者ID:wsjiabao,项目名称:autodz,代码行数:34,代码来源:StrategySimple.cs
示例14: GotTick
public void GotTick(Tick k)
{
// ignore trades
if (k.isTrade) return;
// make sure depth is valid for this book
if ((k.depth < 0) || (k.depth >= maxbook)) return;
if (Sym == null)
Sym = k.symbol;
// make sure symbol matches
if (k.symbol != Sym) return;
// if depth is zero, must be a new book
if (k.depth == 0) Reset();
// update buy book
if (k.hasBid)
{
bidprice[k.depth] = k.bid;
bidsize[k.depth] = k.BidSize;
bidex[k.depth] = k.be;
if (k.depth > ActualDepth)
ActualDepth = k.depth;
}
// update sell book
if (k.hasAsk)
{
askprice[k.depth] = k.ask;
asksize[k.depth] = k.AskSize;
askex[k.depth] = k.oe;
if (k.depth > ActualDepth)
ActualDepth = k.depth;
}
}
开发者ID:bluejack2000,项目名称:core,代码行数:31,代码来源:Book.cs
示例15: GotTick
public override void GotTick(Tick k)
{
// update offsets
ot.newTick(k);
// build bars from ticks
blt.newTick(k);
}
开发者ID:antonywu,项目名称:tradelink,代码行数:7,代码来源:LessonTrackerOverview.cs
示例16: parseline
// here is where a line is converted
public static Tick[] parseline(string line, string sym)
{
// split line
line=line.Remove(8, 1);
line=line.Insert(8, ";");
string[] r = line.Split(';');
// create tick for this symbol
Tick[] result = new Tick[4];
Tick high = new TickImpl(sym);
Tick low = new TickImpl(sym);
Tick open = new TickImpl(sym);
Tick close = new TickImpl(sym);
long dt = 0;
int tt;
if (long.TryParse(r[DATE], out dt))
{
open.date = (int)(dt);
high.date = (int)(dt);
low.date = (int)(dt);
close.date = (int)(dt);
}
//r[TIME]=r[TIME].Substring(0, 4);
if (int.TryParse(r[TIME], out tt))
{
if (tt < 040000) tt += 120000;
open.time = tt;
close.time = tt;
high.time = tt;
low.time = tt;
open.datetime = dt * 1000000 + tt;
high.datetime = dt * 1000000 + tt;
low.datetime = dt * 1000000 + tt;
close.datetime = dt * 1000000 + tt;
}
int size = 0;
if (int.TryParse(r[VOL], out size))
{
high.size = Math.Max(1, size / 4);
low.size = Math.Max(1, size / 4);
open.size = Math.Max(1, size / 4);
close.size = Math.Max(1, size/4);
}
decimal price = 0.0M;
if (decimal.TryParse(r[HIGH], out price))
high.trade = price;
if (decimal.TryParse(r[OPEN], out price))
open.trade = price;
if (decimal.TryParse(r[LOW], out price))
low.trade = price;
if (decimal.TryParse(r[CLOSE], out price))
close.trade = price;
result[0] = open;
result[1] = high;
result[2] = low;
result[3] = close;
return result;
}
开发者ID:bluejack2000,项目名称:core,代码行数:60,代码来源:Drolles.cs
示例17: newTick
public void newTick(Tick k)
{
if (k.time > _lasttime)
{
_lasttime = k.time;
checktifs();
}
}
开发者ID:antonywu,项目名称:tradelink,代码行数:8,代码来源:OrderTIFTracker.cs
示例18: Quote
public Quote(string symbol, double price, int volume, DateTime date, Tick tick)
{
_symbol = symbol;
_price = price;
_volume = volume;
_date = date;
_tick = tick;
}
开发者ID:gclaret,项目名称:WPF-Unleashed,代码行数:8,代码来源:Quote.cs
示例19: getTickZFFrmLastBuy
/// <summary>
/// 上次买入后的涨幅
/// </summary>
/// <param name="gp"></param>
/// <returns></returns>
public static double getTickZFFrmLastBuy(Tick gp, double lastBuy)
{
if (lastBuy > 0)
{
return Math.Round(((gp.last_price - lastBuy) / lastBuy) * 100, 2); //涨幅
}
return 0;
}
开发者ID:wsjiabao,项目名称:autodz,代码行数:14,代码来源:HGStaUtil.cs
示例20: GotTick
public override void GotTick(Tick k)
{
// get index from symbol, add if it doesn't exist
int idx = PRIMARY.addindex(k.symbol,k.symbol);
// build bars
blt.newTick(k);
// update whether entries are allowed
entryok[idx] = expectedsize[idx] == pt[idx].Size;
}
开发者ID:antonywu,项目名称:tradelink,代码行数:9,代码来源:LessonGenericTrackers.cs
注:本文中的Tick类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论