本文整理汇总了C#中TradeLink.Common.TickImpl类的典型用法代码示例。如果您正苦于以下问题:C# TickImpl类的具体用法?C# TickImpl怎么用?C# TickImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TickImpl类属于TradeLink.Common命名空间,在下文中一共展示了TickImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: parseline
// here is where a line is converted
public static Tick parseline(string line, string sym)
{
// split line
string[] r = line.Split(',');
// create tick for this symbol
Tick k = new TickImpl(sym);
// setup temp vars
int iv = 0;
decimal dv = 0;
DateTime date;
// parse date
if (DateTime.TryParse(r[DATE], out date))
k.date = Util.ToTLDate(date);
// parse time
if (int.TryParse(r[TIME], out iv))
k.time = iv * 100;
// parse close as trade price
if (decimal.TryParse(r[CLOSE], out dv))
k.trade = dv;
// parse volume (up and down); up = trade volume at prior ask; down = trade volume at prior bid
int volumeAtAsk = 0, volumeAtBid = 0;
if (int.TryParse(r[UP], out volumeAtAsk) && int.TryParse(r[DOWN], out volumeAtBid))
k.size = volumeAtAsk + volumeAtBid;
// return tick
return k;
}
示例2: parseline
// here is where a line is converted
public static Tick parseline(string line, string sym, int defaultsize)
{
// split line
string[] r = line.Split(',');
// create tick for this symbol
Tick k = new TickImpl(sym);
// setup temp vars
int iv = 0;
decimal dv = 0;
DateTime date;
// parse date
if (DateTime.TryParse(r[DATE], out date))
k.date = Util.ToTLDate(date);
// parse time
if (int.TryParse(r[TIME], out iv))
k.time = iv * 100;
// parse close as trade price
if (decimal.TryParse(r[CLOSE], out dv))
{
k.trade = dv;
k.size = defaultsize;
}
// return tick
return k;
}
示例3: rs_LevelOneStreaming_TickWithArgs
void rs_LevelOneStreaming_TickWithArgs(DateTime time, AmeritradeBrokerAPI.ATradeArgument args)
{
if (args.FunctionType != AmeritradeBrokerAPI.RequestState.AsyncType.LevelOneStreaming) return;
Tick t = new TickImpl();
/* don't understand the time format provided here
int date = 0;
int ttime = 0;
if (int.TryParse(args.oLevelOneData[0].quotedate, out date))
t.date = date;
if (int.TryParse(args.oLevelOneData[0].quotetime, out ttime))
t.time = ttime;
*/
t.date = Util.ToTLDate(DateTime.Now);
t.time = Util.DT2FT(DateTime.Now);
t.symbol = args.oLevelOneData[0].stock;
t.bid = Convert.ToDecimal(args.oLevelOneData[0].bid);
t.ask = Convert.ToDecimal(args.oLevelOneData[0].ask);
t.ex = args.oLevelOneData[0].exchange;
t.trade = Convert.ToDecimal(args.oLevelOneData[0].last);
t.size = Convert.ToInt32(args.oLevelOneData[0].lastsize) * 100;
t.bs = Convert.ToInt32(args.oLevelOneData[0].bid_size);
t.os = Convert.ToInt32(args.oLevelOneData[0].ask_size);
tl.newTick(t);
}
示例4: parseline
// here is where a line is converted
public static Tick parseline(string line, string sym)
{
// split line
string[] r = line.Split(',');
// create tick for this symbol
Tick k = new TickImpl(sym);
// setup temp vars
int iv = 0;
decimal dv = 0;
DateTime date;
// parse date
if (DateTime.TryParse(r[DATE], out date))
k.date = Util.ToTLDate(date);
// parse time - remove colons to give format HHMMSS
if (int.TryParse(r[TIME].Replace(":", ""), out iv))
k.time = iv;
// trade price
if (decimal.TryParse(r[PRICE], out dv))
k.trade = dv;
// size of trade
if (int.TryParse(r[VOLUME], out iv))
k.size = iv;
// return tick
return k;
}
示例5: fromApp
public void fromApp(QuickFix.Message message, SessionID sessionID)
{
// receiving messages
Symbol sym = new Symbol();
message.getField(sym);
Tick k = new TickImpl(sym.getValue());
{
// bid
BidPx bp = new BidPx();
BidSize bs = new BidSize();
k.bid = (decimal)bp.getValue();
k.bs = (int)message.getField(bs).getValue();
}
{
// ask
OfferPx op = new OfferPx();
OfferSize os = new OfferSize();
k.ask = (decimal)op.getValue();
k.os = (int)message.getField(os).getValue();
}
{
// last
Price price = new Price();
message.getField(price);
k.trade = (decimal)price.getValue();
}
tl.newTick(k);
//ClOrdID clOrdID = new ClOrdID();
//message.getField(clOrdID);
}
示例6: parseline
// here is where a line is converted
public static Tick parseline(string line, int defaultsize, int decimalplaces )
{
// split line
string[] r = line.Split(',');
// create tick for this symbol
Tick k = new TickImpl(r[SYM]);
// setup temp vars
int iv = 0;
decimal dv = 0;
// parse date
if (int.TryParse(r[DATE], out iv))
k.date = iv;
// parse time
if (int.TryParse(r[TIME], out iv))
k.time = iv * 100;
// parse close as trade price
if (decimal.TryParse(r[TRADE], out dv))
{
decimal divisor = (decimal)( Math.Pow( 10, decimalplaces ) );
// k.trade = (decimal)dv / 100;
k.trade = (decimal) dv / divisor;
k.size = defaultsize;
}
// return tick
return k;
}
示例7: Hours
public void Hours()
{
System.IO.StreamReader sr = new System.IO.StreamReader("TestWAG.txt");
sr.ReadLine();
sr.ReadLine();
BarListImpl bl = new BarListImpl(BarInterval.Hour, "WAG");
Tick k = new TickImpl();
int tickcount = 0;
while (!sr.EndOfStream)
{
k = eSigTick.FromStream(bl.Symbol, sr);
if (tickcount == 0)
{
Assert.IsTrue(k.isValid);
Assert.AreEqual(20070926041502, k.datetime);
Assert.AreEqual(20070926, k.date);
Assert.AreEqual(041502, k.time);
Assert.AreEqual(43.81m, k.bid);
Assert.AreEqual(51.2m, k.ask);
Assert.AreEqual(1, k.bs);
Assert.AreEqual(1, k.os);
Assert.IsTrue(k.be.Contains("PSE"));
Assert.IsTrue(k.oe.Contains("PSE"));
}
tickcount++;
bl.newTick(k);
}
// hour is what we asked for
Assert.AreEqual(BarInterval.Hour,bl.DefaultInterval);
// there are 4 trades on hour intervals, 6/7/8/9
Assert.AreEqual(4,bl.Count);
}
示例8: parseline
public static Tick parseline(string line, string sym)
{
int decimalplaces = 5;
string[] r = line.Split(',');
var t = new TickImpl(sym);
if(sym.Contains("JPY"))
decimalplaces = 3;
DateTime dt;
if (DateTime.TryParseExact(r[DATETIME], "yyyyMMdd HH:mm:ss.fff", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
{
t.date = Util.ToTLDate(dt.Date);
t.time = Util.ToTLTime(dt);
}
decimal b, a;
if (decimal.TryParse(r[BID], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out b))
t.bid = b;
if (decimal.TryParse(r[ASK], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out a))
t.ask = a;
//simulate bid/offer midpoint trade-tick
decimal px = Math.Round((a + b) / 2, decimalplaces);
t.trade = px;
//there is no size information in the data
//assume bid/offer size of 500K basecurrency units
//simulated midpoint trade of 1 BCU, for compatibility only
t.bs = 500000; t.os = 500000; t.size = 1;
return t;
}
示例9: parseline
// here is where a line is converted
public static Tick parseline(string line, string sym, int date)
{
// split line
string[] r = line.Split(',');
// create tick for this symbol
Tick k = new TickImpl(sym);
k.date = date;
char type = 'z';
long mtime = 0;
if(long.TryParse(r[TIME], out mtime))
{
int hr = (int) mtime / 3600000;
int min = (int) (mtime % 3600000) / 60000;
int sec = (int) (mtime % 60000) / 1000;
int ftime = Util.TL2FT(hr, min, sec);
k.time = ftime;
}
int size = 0;
if (int.TryParse(r[SHARES], out size))
k.size = size;
decimal price = 0.0M;
if(decimal.TryParse(r[PRICE], out price))
k.trade = price / 10000;
return k;
}
示例10: 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;
}
示例11: parseline
// here is where a line is converted
public static Tick[] parseline(string line, string sym)
{
// split line
string[] r = line.Split(',');
sym = r[SYMBOL];
// 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;
if (long.TryParse(r[DATETIME], out dt))
{
open.datetime = dt;
high.datetime = dt;
low.datetime = dt;
close.datetime = dt;
open.date = (int)(dt/10000);
high.date = (int)(dt/10000);
low.date = (int)(dt/10000);
close.date = (int)(dt/10000);
open.time = ((int)open.datetime - open.date * 10000)*100;
close.time = ((int)close.datetime - close.date * 10000)*100;
high.time = ((int)high.datetime - high.date * 10000)*100;
low.time = ((int)low.datetime - low.date * 10000)*100;
}
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;
}
示例12: parseline
// here is where a line is converted
public static Tick parseline(string line, int defaultsize, int decimalplaces)
{
// split line
string[] r;
if (line.Contains(","))
r = line.Split(','); // optional CQG format
else
r = line.Split(' '); // standard CQG format
// create tick for this symbol
string symbol = r[SYM];
Tick k = new TickImpl(symbol);
// setup temp vars
int iv = 0;
decimal dv = 0;
// parse date
if (int.TryParse(r[DATE], out iv))
k.date = iv;
// parse time
if (int.TryParse(r[TIME], out iv))
k.time = iv * 100;
// parse price
if (decimal.TryParse(r[PRICE], out dv))
{
decimal divisor = (decimal)(Math.Pow(10, decimalplaces));
dv = (decimal)dv / divisor;
string type = r[TYPE];
if (type == "T") // trade
{
k.trade = dv;
k.size = defaultsize;
}
else if (type == "B") // bid
{
k.bid = dv;
k.bs = defaultsize;
}
else if (type == "A") // ask
{
k.ask = dv;
k.os = defaultsize;
}
}
// return tick
return k;
}
示例13: FromStream
/// <summary>
/// Loads a tick straight from an EPF file in the form of a StreamReader
/// </summary>
/// <param name="symbol">The symbol.</param>
/// <param name="sr">The sr.</param>
/// <returns></returns>
public static Tick FromStream(string symbol,StreamReader sr)
{
TickImpl t = new TickImpl();
string line = "";
try
{
line = sr.ReadLine();
}
catch (Exception) { return t; }
if (line == null) return t; // blank line
string[] r = line.Split(',');
if (r.Length < 6) return t;
decimal td = 0;
int ti = 0;
if (r[(int)Q.TYPE] == TRADE)
{
if (decimal.TryParse(r[(int)T.PRICE], out td))
t.trade = td;
if (int.TryParse(r[(int)T.SIZE], out ti))
t.size = ti;
t.ex = r[(int)T.EXCH];
}
else
{
if (r.Length < 9) return t;
if (decimal.TryParse(r[(int)Q.BID], out td))
t.bid = td;
if (decimal.TryParse(r[(int)Q.ASK], out td))
t.ask = td;
if (int.TryParse(r[(int)Q.BIDSIZE], out ti))
t.bs = ti;
if (int.TryParse(r[(int)Q.ASKSIZE], out ti))
t.os = ti;
t.be = r[(int)Q.BIDEX];
t.oe = r[(int)Q.ASKEX];
}
t.symbol = symbol;
if (int.TryParse(r[(int)Q.TIME], out ti))
{
t.time = ti;
}
if (int.TryParse(r[(int)Q.DATE], out ti))
t.date = ti + 20000000;
t.datetime = ((long)t.date * 1000000) + (long)t.time;
return t;
}
示例14: Basics
public void Basics()
{
const string sym = "TST";
const int d = 20080509;
const int t = 93500;
const string x = "NYSE";
TickImpl[] ticklist = new TickImpl[] {
TickImpl.NewTrade(sym,d,t,10,100,x),
TickImpl.NewTrade(sym,d,t+100,10,100,x),
TickImpl.NewTrade(sym,d,t+200,10,100,x),
TickImpl.NewTrade(sym,d,t+300,10,100,x),
TickImpl.NewTrade(sym,d,t+400,15,100,x), // blade up
TickImpl.NewTrade(sym,d,t+500,16,100,x), // new bar (blades reset)
TickImpl.NewTrade(sym,d,t+600,16,100,x),
TickImpl.NewTrade(sym,d,t+700,10,100,x), // blade down
TickImpl.NewTrade(sym,d,t+700,10,100,x), // still a blade down (same bar)
TickImpl.NewTrade(sym,d,t+800,15,100,x),
TickImpl.NewTrade(sym,d,t+1500,15,800,x), // volume spike
TickImpl.NewTrade(sym,d,t+2000,15,100,x),
TickImpl.NewTrade(sym,d,t+2500,15,100,x),
};
BarListImpl bl = new BarListImpl(BarInterval.FiveMin,sym);
Blade b = new Blade();
Assert.That(b.BladePercentage != 0);
b = new Blade(.2m); // 20 percent move is a blade
int up=0,down=0,newbar=0,bigvol=0;
foreach (TickImpl k in ticklist)
{
bl.newTick(k);
b.newBar(bl);
if (bl.NewBar) newbar++;
if (b.isBladeUP) up++;
if (b.isBladeDOWN) down++;
if (b.isBigVolume) bigvol++;
}
Assert.AreEqual(1, up);
Assert.AreEqual(2,down);
Assert.AreEqual(5, newbar);
Assert.AreEqual(1,bigvol);
}
示例15: Copy
public static TickImpl Copy(Tick c)
{
TickImpl k = new TickImpl();
if (c.symbol != "") k.symbol = c.symbol;
k.time = c.time;
k.date = c.date;
k.datetime = c.datetime;
k.size = c.size;
k.depth = c.depth;
k.trade = c.trade;
k.bid = c.bid;
k.ask = c.ask;
k.bs = c.bs;
k.os = c.os;
k.be = c.be;
k.oe = c.oe;
k.ex = c.ex;
return k;
}