public static InstrInfo[] ConvertOptSymToInstrInfo(string optSym) { string[] arr = optSym.Split(' '); InstrInfo[] instr = new InstrInfo[1]; instr[0] = new InstrInfo(); if (arr.Length == 1) { instr[0].type = InstrInfo.EType.EQUITY; instr[0].sym = arr[0]; } else { string sym = arr[0]; int mat = DecodeExpiration(arr[1]); float strk = float.Parse(arr[2]); string type = arr[3]; instr[0].type = InstrInfo.EType.OPTION; instr[0].sym = sym; instr[0].maturity = mat; instr[0].strike = strk; if (type == "C") { instr[0].callput = InstrInfo.ECallPut.CALL; } else { instr[0].callput = InstrInfo.ECallPut.PUT; } } return(instr); }
// map back "trace[start, start + to.size - 1]" through this transformation. // // tinfo is the parent // transformation info for the whole program -- it is used for recursively // calling the mapBack procedure on callee traces public ErrorTraceInstr mapBackTrace(List <ErrorTraceInstr> trace, int start, ModifyTrans tinfo) { Debug.Assert(start >= 0); Debug.Assert(start + to.Count - 1 < trace.Count); // Find the "info" for "from". It is obtained from the // corresponding instruction, if one is provided. Else // we search through "to" to find (any) valid info. InstrInfo info = null; if (correspondingInstr >= 0) { info = trace[start + correspondingInstr].info; } else { // Default info (invalid) info = new InstrInfo(); for (int i = start; i < start + to.Count; i++) { if (trace[i].info.isValid) { info = trace[i].info; break; } } } Debug.Assert(info != null); ErrorTraceInstr ret = null; if (from.type == InstrTypeEnum.CALL || from.type == InstrTypeEnum.ASYNC) { // check if the corresponding instruction is also a call if (correspondingInstr >= 0 && trace[start + correspondingInstr].isCall()) { var calleeTrace = (trace[start + correspondingInstr] as CallInstr).calleeTrace; if (calleeTrace != null) { // Recurse on the callee trace calleeTrace = tinfo.mapBackTrace(calleeTrace); } ret = new CallInstr(from.callee, calleeTrace, (from.type == InstrTypeEnum.ASYNC ? true : false), info); } else { // no corresponding callee trace ret = new CallInstr(from.callee, null, (from.type == InstrTypeEnum.ASYNC ? true : false), info); } } else { ret = new IntraInstr(info); } Debug.Assert(ret != null); return(ret); }
public static ConcurrentQueue<equity> queue = new ConcurrentQueue<equity>();//equity quote public static void dobkUnderhndlr(InstrInfo instr, uint ts, byte partid, int mod, byte numbid, byte numask, byte[] bidexch, byte[] askexch, Quote[] bidbk, Quote[] askbk) { lock (respFlow.locker2) { try { output x; reqFlow._queue.TryDequeue(out x); equity q = new equity { Instr = instr, Ts = ts, Bidexch = bidexch, Askexch = askexch, Bidbk = bidbk, Askbk = askbk, x = x }; queue.Enqueue(q); Console.WriteLine("response: " + x.under + x.callput + " " + instr.sym); } catch (Exception e) { Console.WriteLine(e.Message); } } }
public static InstrInfo DecodeOCCtoInstrInfo(string option) { InstrInfo instr = new InstrInfo(); int splitPt = 0; for (int i = option.Length - 1; i >= 0; i--) { if (option[i] == 'P' || option[i] == 'C') { if (option[i] == 'P') { instr.callput = InstrInfo.ECallPut.PUT; } else if (option[i] == 'C') { instr.callput = InstrInfo.ECallPut.CALL; } splitPt = i; break; } } string pre = option.Substring(0, splitPt); string post = option.Substring(splitPt + 1); instr.type = InstrInfo.EType.OPTION; instr.strike = (float)Convert.ToDouble(post.Substring(0, 5) + "." + post.Substring(5)); instr.maturity = Convert.ToInt32(pre.Substring(pre.Length - 6)); instr.sym = pre.Substring(0, pre.Length - 6); return(instr); }
private static void fetchInfo(InstrInfo info, out int k, out int tid) { Debug.Assert(info.executionContext >= 0); Debug.Assert(info.tid >= 0); k = info.executionContext; tid = info.tid; }
public static ConcurrentQueue<quote> queue = new ConcurrentQueue<quote>();//surrounding quote public static void depofbkhndlr(InstrInfo instr, uint ts, byte partid, int mod, byte numbid, byte numask, byte[] bidexch, byte[] askexch, Quote[] bidbk, Quote[] askbk) { lock (respFlow2.locker0) { //System.Diagnostics.Debug.WriteLine("111 " + ((ConcurrentQueue<output>)_Dict[0][1]).Count); try { output x; reqFlow2._queue.TryDequeue(out x); quote q = new quote { Instr = instr, Ts = ts, Bidexch = bidexch, Askexch = askexch, Bidbk = bidbk, Askbk = askbk, x = x, }; queue.Enqueue(q); } catch (Exception e) { Console.WriteLine(e.Message); } } }
public static InstrInfo[] CreateEquityInstrument(string symbol) { InstrInfo[] info = new InstrInfo[1]; info[0] = new InstrInfo(); info[0].type = InstrInfo.EType.EQUITY; info[0].sym = symbol; return(info); }
public Logger(string pathname, InstrInfo inst) { instrument = inst; _pathname = pathname; sBuilder = new StringBuilder(); writer = new StreamWriter(pathname); }
static string GetCpuid(InstrInfo info) { if ((info.Flags & InstrInfoFlags.AVX2_Check) != 0) { return("AVX (reg,mem) or AVX2 (reg,reg)"); } return(string.Join(" and ", info.Cpuid.Select(a => GetCpuid(a)))); }
private InstrInfo[] GetInstrInfo() { InstrInfo[] instrs = new InstrInfo[_instBinding.Count]; for (int i = 0; i < _instBinding.Count; i++) { instrs[i] = _instBinding[i].ToInstrInfo(); } return(instrs); }
public InstTableObj(InstrInfo i) { Symbol = i.sym; Maturity = i.maturity; Strike = i.strike; CallPut = i.callput == InstrInfo.ECallPut.CALL ? 'C' : 'P'; Side = i.side == OrdInfo.ESide.BUY ? 'B' : 'S'; Ratio = i.ratio; Type = (int)i.type; }
public static string InstrToStr(InstrInfo instr) { switch (instr.type) { case InstrInfo.EType.OPTION: return($"{instr.sym} {instr.strike} {instr.callput} {instr.maturity.ToString("0000-00-00")}"); case InstrInfo.EType.EQUITY: return(instr.sym); } return(""); }
public static int EncodeInstrInfoFromStr(string sym, ref InstrInfo[] instrinfo) { int rc = -1; instrinfo = null; if (sym.Length > 0) { string[] strArr = sym.Split('_'); instrinfo = new InstrInfo[strArr.Count()]; bool sprd = (strArr.Count() > 1); List <string> instrList = new List <string>(strArr); List <OrdInfo.ESide> sideList = null; List <int> ratioList = null; if (sprd) { instrList.Sort(); DecodeMLegInfo(ref instrList, ref sideList, ref ratioList); } bool done = false; int i = 0; while (!done && i < strArr.Count()) { if (EncodeInstrInfoFromStr(instrList[i], ref instrinfo[i]) != 0) { done = true; } else { if (sprd && i < Math.Min(instrinfo.Length, sideList.Count)) { instrinfo[i].side = sideList[i]; instrinfo[i].ratio = ratioList[i]; } ++i; } } if (i == strArr.Count()) { rc = 0; } } return(rc); }
public static string EncodeNormalizedStrFromInstrInfo(InstrInfo[] instrinfo) { string infoString = ""; InstrInfo[] info = new InstrInfo[instrinfo.Length]; instrinfo.CopyTo(info, 0); List <InstrInfo> list = info.ToList(); list.Sort(); return(DecodeInstrInfoArrToStr(list.ToArray())); }
public static InstrInfo CreateOptionInstrument(string symbol, int expiration, InstrInfo.ECallPut callOrPut, float strike, OrdInfo.ESide side) { InstrInfo newInstr = new InstrInfo(); newInstr.callput = callOrPut; newInstr.maturity = expiration; newInstr.ratio = 1; newInstr.side = side; newInstr.strike = strike; newInstr.sym = symbol; newInstr.type = InstrInfo.EType.OPTION; return(newInstr); }
public InstrInfo ToInstrInfo() { InstrInfo i = new InstrInfo(); i.sym = Symbol; i.maturity = Maturity; i.strike = Strike; i.callput = CallPut == 'C' ? InstrInfo.ECallPut.CALL : InstrInfo.ECallPut.PUT; i.side = Side == 'B' ? OrdInfo.ESide.BUY : OrdInfo.ESide.SELL; i.ratio = Ratio; i.type = (InstrInfo.EType)Type; return(i); }
public InstructionDef(int opCount, EnumValue mnemonic, EnumValue mem, EnumValue bcst, OpCodeInfo opCodeInfo, InstrInfo instrInfo) { if (opCodeInfo.Code != instrInfo.Code) { throw new InvalidOperationException(); } OpCount = opCount; Mnemonic = mnemonic; Mem = mem; Bcst = bcst; OpCodeInfo = opCodeInfo; InstrInfo = instrInfo; }
public QuoteBookStruct(bool initialize) { Instr = new InstrInfo[2]; BidBk = new QuoteInfo[10]; AskBk = new QuoteInfo[10]; AskExch = new byte[10]; BidExch = new byte[10]; NumAsk = 10; NumBid = 10; TS = 0; PartID = 0; Mod = 0; TEST_TIMESTAMP_TICKS = DateTime.Now.Ticks; InstrumentName = ""; }
public static int EncodeInstrInfoFromStr(string sym, ref InstrInfo instrinfo) { int rc = -1; instrinfo = null; int length = sym.Length; float strike = 0.0f; int xp = 0; if (length > 0 && sym[0] >= 'A' && sym[0] <= 'Z') { int idx = Math.Max(sym.LastIndexOf('C'), sym.LastIndexOf('P')); if (idx >= 0 && idx < length - 1 && Char.IsDigit(sym[idx + 1]) && (strike = float.Parse(sym.Substring(idx + 1))) > 0.0f && idx > 8 && (xp = DecodeExpiration(sym.Substring(idx - 8, 8))) > 0 ) { instrinfo = new InstrInfo(); instrinfo.type = InstrInfo.EType.OPTION; instrinfo.sym = sym.Substring(0, idx - 8); instrinfo.maturity = xp; instrinfo.strike = strike; instrinfo.callput = (sym[idx] == 'C' ? InstrInfo.ECallPut.CALL : InstrInfo.ECallPut.PUT); instrinfo.ratio = 1; rc = 0; } else if (sym.All(Char.IsLetterOrDigit)) { instrinfo = new InstrInfo(); instrinfo.type = InstrInfo.EType.EQUITY; instrinfo.sym = sym; rc = 0; } } return(rc); }
public static string DecodeInstrInfoToStrWithSideRatio(InstrInfo instrinfo) { string val = ""; if (instrinfo.type == InstrInfo.EType.EQUITY) { val = string.Format("{0}{1}{2}", instrinfo.sym, instrinfo.side == OrdInfo.ESide.BUY ? "B" : "S", instrinfo.ratio); } else if (instrinfo.type == InstrInfo.EType.OPTION) { val = string.Format("{0}{1}{2}{3}{4}{5}", instrinfo.sym, instrinfo.maturity, instrinfo.callput.ToString().Substring(0, 1), instrinfo.strike.ToString("0.00"), instrinfo.side == OrdInfo.ESide.BUY ? "B" : "S", instrinfo.ratio); } return(val); }
public static InstrInfo GenerateRandomInstrument(InstrInfo.EType type) { InstrInfo randomInstr = new InstrInfo(); randomInstr.type = type; randomInstr.sym = highCapSymbols[numGenerator.Next(0, highCapSymbols.Length - 1)]; if (type == InstrInfo.EType.OPTION) { int maturityYear = numGenerator.Next(2018, 2020); int maturityMonth = numGenerator.Next(1, 13); int maturityDay = numGenerator.Next(1, 29); randomInstr.maturity = maturityYear * 10000 + maturityMonth * 100 + maturityDay; randomInstr.strike = numGenerator.Next(10, 101); randomInstr.callput = maturityYear % 2 == 0 ? InstrInfo.ECallPut.CALL : InstrInfo.ECallPut.PUT; } return(randomInstr); }
public static InstrInfo[] CreateInstrInfo(string under, string exp, double strike, string callput) { InstrInfo[] _instr; if (!string.IsNullOrEmpty(under) && (exp != null) && (strike > 0) && !string.IsNullOrEmpty(callput)) { _instr = new InstrInfo[1]; _instr[0] = new InstrInfo { sym = under, maturity = convertExpirationToInt(exp), strike = (float)strike, type = InstrInfo.EType.OPTION }; _instr[0].callput = callput == "Call" ? _instr[0].callput = InstrInfo.ECallPut.CALL : _instr[0].callput = InstrInfo.ECallPut.PUT; return(_instr); } return(null); }
public static string SpreadLegToString(InstrInfo leg) { string temp = string.Empty; try { if (leg.type == InstrInfo.EType.OPTION) { temp = leg.sym + " " + leg.maturity.ToString() + " " + leg.callput + " " + leg.strike.ToString() + " " + leg.side.ToString().Substring(0, 1) + leg.ratio.ToString(); } else if (leg.type == InstrInfo.EType.EQUITY) { temp = leg.sym + " " + leg.side.ToString().Substring(0, 1) + leg.ratio.ToString(); } } catch (Exception ex) { Console.WriteLine("Translation error."); } return(temp); }
public InstrInfo GetInstrInfo() { InstrInfo i = new InstrInfo(); i.sym = textEditSymbol.Text; if (radioGroupType.SelectedIndex == 0) { i.type = InstrInfo.EType.OPTION; if (radioGroupCallPut.SelectedIndex == 0) { i.callput = InstrInfo.ECallPut.CALL; } else if (radioGroupCallPut.SelectedIndex == 1) { i.callput = InstrInfo.ECallPut.PUT; } i.maturity = Convert.ToInt32(dateEditMaturity.DateTime.ToString("yyyyMMdd")); i.strike = Convert.ToSingle(textEditStrike.Text); } else if (radioGroupType.SelectedIndex == 0) { i.type = InstrInfo.EType.EQUITY; } if (_spread) { if (radioGroupSide.SelectedIndex == 0) { i.side = OrdInfo.ESide.BUY; } else if (radioGroupSide.SelectedIndex == 1) { i.side = OrdInfo.ESide.SELL; } i.ratio = Convert.ToInt32(textEditRatio.Text); } return(i); }
static InstrInfo[] ReadInfos() { var reader = new DataReader(GetSerializedInstrInfos()); var infos = new InstrInfo[DecoderConstants.NumberOfCodeValues]; var strings = FormatterStringsTable.GetStringsTable(); var ca = new char[1]; string s, s2, s3, s4; uint v, v2; int prevIndex = -1; for (int i = 0; i < infos.Length; i++) { var code = (Code)i; byte f = reader.ReadByte(); var ctorKind = (CtorKind)(f & 0x7F); int currentIndex; if (ctorKind == CtorKind.Previous) { currentIndex = reader.Index; reader.Index = prevIndex; ctorKind = (CtorKind)(reader.ReadByte() & 0x7F); } else { currentIndex = -1; prevIndex = reader.Index - 1; } s = strings[reader.ReadCompressedUInt32()]; if ((f & 0x80) != 0) { ca[0] = 'v'; s = AddPrefix(s, ca); } InstrInfo instrInfo; switch (ctorKind) { case CtorKind.Normal_1: instrInfo = new SimpleInstrInfo(code, s); break; case CtorKind.Normal_2a: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo(code, s, s2); break; case CtorKind.Normal_2b: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo(code, s, (InstrOpInfoFlags)v); break; case CtorKind.Normal_2c: ca[0] = (char)reader.ReadByte(); s = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo(code, s); break; case CtorKind.Normal_3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo(code, s, s2, (InstrOpInfoFlags)v); break; case CtorKind.AamAad: instrInfo = new SimpleInstrInfo_AamAad(code, s); break; case CtorKind.asz: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_as(code, (int)v, s); break; case CtorKind.bnd2_2: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_bnd2(code, s, s2); break; case CtorKind.bnd2_3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_bnd2(code, s, s2, (InstrOpInfoFlags)v); break; case CtorKind.DeclareData: instrInfo = new SimpleInstrInfo_DeclareData(code, s); break; case CtorKind.er_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er(code, (int)v, s); break; case CtorKind.er_4: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er(code, (int)v, s, s2, (InstrOpInfoFlags)v2); break; case CtorKind.far: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_far(code, (int)v, s, s2); break; case CtorKind.imul: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_imul(code, s, s2); break; case CtorKind.maskmovq: instrInfo = new SimpleInstrInfo_maskmovq(code, s); break; case CtorKind.movabs: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); s3 = strings[reader.ReadCompressedUInt32()]; ca[0] = (char)reader.ReadByte(); s4 = AddSuffix(s3, ca); instrInfo = new SimpleInstrInfo_movabs(code, (int)v, s, s2, s3, s4); break; case CtorKind.nop: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_nop(code, (int)v, s, (Register)v2); break; case CtorKind.OpSize: v = reader.ReadByte(); s2 = string.Intern(s + "w"); s3 = string.Intern(s + "l"); s4 = string.Intern(s + "q"); instrInfo = new SimpleInstrInfo_OpSize(code, (CodeSize)v, s, s2, s3, s4); break; case CtorKind.OpSize2_bnd: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; s4 = strings[reader.ReadCompressedUInt32()]; instrInfo = new SimpleInstrInfo_OpSize2_bnd(code, s, s2, s3, s4); break; case CtorKind.OpSize3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_OpSize3(code, (int)v, s, s2); break; case CtorKind.os_A: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os(code, (int)v, s); break; case CtorKind.os_B: v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os(code, (int)v, s, (InstrOpInfoFlags)v2); break; case CtorKind.os_bnd: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_bnd(code, (int)v, s); break; case CtorKind.os_jcc: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc(code, (int)v, s); break; case CtorKind.os_loop: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_loop(code, (int)v, (int)v2, s, s2); break; case CtorKind.os_mem: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem(code, (int)v, s, s2); break; case CtorKind.os_mem_reg16: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem_reg16(code, (int)v, s); break; case CtorKind.os_mem2: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem2(code, (int)v, s, s2); break; case CtorKind.os2_3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os2(code, (int)v, s, s2); break; case CtorKind.os2_4: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os2(code, (int)v, s, s2, (InstrOpInfoFlags)v2); break; case CtorKind.os2_bnd: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os2_bnd(code, (int)v, s, s2); break; case CtorKind.pblendvb: instrInfo = new SimpleInstrInfo_pblendvb(code, s); break; case CtorKind.pclmulqdq: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pclmulqdq(code, s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v)); break; case CtorKind.pops: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pops(code, s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v)); break; case CtorKind.Reg16: instrInfo = new SimpleInstrInfo_Reg16(code, s); break; case CtorKind.sae: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_sae(code, (int)v, s); break; case CtorKind.sae_pops: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_sae_pops(code, (int)v, s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v2)); break; case CtorKind.ST_STi: instrInfo = new SimpleInstrInfo_ST_STi(code, s); break; case CtorKind.STi_ST: instrInfo = new SimpleInstrInfo_STi_ST(code, s); break; case CtorKind.STi_ST2: instrInfo = new SimpleInstrInfo_STi_ST2(code, s); break; case CtorKind.STIG_1a: instrInfo = new SimpleInstrInfo_STIG1(code, s); break; case CtorKind.STIG_1b: v = reader.ReadByte(); if (v > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_STIG1(code, s, v != 0); break; case CtorKind.xbegin: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_xbegin(code, (int)v, s); break; default: throw new InvalidOperationException(); } infos[i] = instrInfo; if (currentIndex >= 0) { reader.Index = currentIndex; } } if (reader.CanRead) { throw new InvalidOperationException(); } return(infos); }
public QuoteFeedLogger(string pathname, InstrInfo instr) : base(pathname, instr) { enableFlag = true; }
private void AddInstrInfo(InstrInfo i) { _instBinding.Add(new InstTableObj(i)); PopulateGrid(); }
static InstrInfo[] ReadInfos() { var reader = new DataReader(GetSerializedInstrInfos()); var infos = new InstrInfo[IcedConstants.CodeEnumCount]; var strings = FormatterStringsTable.GetStringsTable(); var ca = new char[1]; string s, s2, s3, s4, s5, s6; uint v, v2, v3; int prevIndex = -1; for (int i = 0; i < infos.Length; i++) { byte f = reader.ReadByte(); var ctorKind = (CtorKind)(f & 0x7F); int currentIndex; if (ctorKind == CtorKind.Previous) { currentIndex = reader.Index; reader.Index = prevIndex; ctorKind = (CtorKind)(reader.ReadByte() & 0x7F); } else { currentIndex = -1; prevIndex = reader.Index - 1; } s = strings[reader.ReadCompressedUInt32()]; if ((f & 0x80) != 0) { ca[0] = 'v'; s = AddPrefix(s, ca); } InstrInfo instrInfo; switch (ctorKind) { case CtorKind.Normal_1: instrInfo = new SimpleInstrInfo(s); break; case CtorKind.Normal_2a: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo(s, s2); break; case CtorKind.Normal_2b: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo(s, (InstrOpInfoFlags)v); break; case CtorKind.Normal_2c: ca[0] = (char)reader.ReadByte(); s = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo(s); break; case CtorKind.Normal_3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo(s, s2, (InstrOpInfoFlags)v); break; case CtorKind.AamAad: instrInfo = new SimpleInstrInfo_AamAad(s); break; case CtorKind.asz: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_as((int)v, s); break; case CtorKind.bnd: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_bnd(s, s2, (InstrOpInfoFlags)v); break; case CtorKind.DeclareData: instrInfo = new SimpleInstrInfo_DeclareData((Code)i, s); break; case CtorKind.er_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er((int)v, s); break; case CtorKind.er_4: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er((int)v, s, s2, (InstrOpInfoFlags)v2); break; case CtorKind.far: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_far((int)v, s, s2); break; case CtorKind.imul: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_imul(s, s2); break; case CtorKind.maskmovq: instrInfo = new SimpleInstrInfo_maskmovq(s); break; case CtorKind.movabs: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); s3 = strings[reader.ReadCompressedUInt32()]; s4 = AddSuffix(s3, ca); instrInfo = new SimpleInstrInfo_movabs(s, s2, s3, s4); break; case CtorKind.nop: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_nop((int)v, s, (Register)v2); break; case CtorKind.OpSize: v = reader.ReadByte(); s2 = string.Intern(s + "w"); s3 = string.Intern(s + "l"); s4 = string.Intern(s + "q"); instrInfo = new SimpleInstrInfo_OpSize((CodeSize)v, s, s2, s3, s4); break; case CtorKind.OpSize2_bnd: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; s4 = strings[reader.ReadCompressedUInt32()]; instrInfo = new SimpleInstrInfo_OpSize2_bnd(s, s2, s3, s4); break; case CtorKind.OpSize3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_OpSize3((int)v, s, s2); break; case CtorKind.os: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); if (v2 > 1) { throw new InvalidOperationException(); } v3 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os((int)v, s, v2 != 0, (InstrOpInfoFlags)v3); break; case CtorKind.CC_1: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s }, new[] { s2 }); break; case CtorKind.CC_2: s2 = strings[reader.ReadCompressedUInt32()]; ca[0] = (char)reader.ReadByte(); v = reader.ReadCompressedUInt32(); s3 = AddSuffix(s, ca); s4 = AddSuffix(s2, ca); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s, s2 }, new[] { s3, s4 }); break; case CtorKind.CC_3: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; ca[0] = (char)reader.ReadByte(); v = reader.ReadCompressedUInt32(); s4 = AddSuffix(s, ca); s5 = AddSuffix(s2, ca); s6 = AddSuffix(s3, ca); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s, s2, s3 }, new[] { s4, s5, s6 }); break; case CtorKind.os_jcc_1: v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s }); break; case CtorKind.os_jcc_2: s2 = strings[reader.ReadCompressedUInt32()]; v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s, s2 }); break; case CtorKind.os_jcc_3: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s, s2, s3 }); break; case CtorKind.os_loopcc: s2 = strings[reader.ReadCompressedUInt32()]; ca[0] = (char)reader.ReadByte(); s3 = AddSuffix(s, ca); s4 = AddSuffix(s2, ca); v3 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_loop((int)v, (int)v2, (int)v3, new[] { s, s2 }, new[] { s3, s4 }); break; case CtorKind.os_loop: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_loop((int)v, (int)v2, -1, new[] { s }, new[] { s2 }); break; case CtorKind.os_mem: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem((int)v, s, s2); break; case CtorKind.Reg16: ca[0] = 'w'; s2 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_Reg16(s, s2); break; case CtorKind.os_mem2: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem2((int)v, s, s2); break; case CtorKind.os2_3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); if (v2 > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_os2((int)v, s, s2, v2 != 0, InstrOpInfoFlags.None); break; case CtorKind.os2_4: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); if (v2 > 1) { throw new InvalidOperationException(); } v3 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os2((int)v, s, s2, v2 != 0, (InstrOpInfoFlags)v3); break; case CtorKind.pblendvb: instrInfo = new SimpleInstrInfo_pblendvb(s); break; case CtorKind.pclmulqdq: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pclmulqdq(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v)); break; case CtorKind.pops: v = reader.ReadByte(); v2 = reader.ReadByte(); if (v2 > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_pops(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v), v2 != 0); break; case CtorKind.mem16: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); ca[0] = 'w'; s3 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_mem16(s, s2, s3); break; case CtorKind.Reg32: instrInfo = new SimpleInstrInfo_Reg32(s); break; case CtorKind.sae: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_sae((int)v, s); break; case CtorKind.ST_STi: instrInfo = new SimpleInstrInfo_ST_STi(s); break; case CtorKind.STi_ST: v = reader.ReadByte(); if (v > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_STi_ST(s, v != 0); break; case CtorKind.STIG1: v = reader.ReadByte(); if (v > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_STIG1(s, v != 0); break; default: throw new InvalidOperationException(); } infos[i] = instrInfo; if (currentIndex >= 0) { reader.Index = currentIndex; } } if (reader.CanRead) { throw new InvalidOperationException(); } return(infos); }
public static void CreateLevel2Form(InstrInfo i) { InstrInfo[] a = { i }; Hub._formFactory.CreateLevel2Form(a); }
public static void subtask(InstrInfo instr, uint ts, byte[] bidexch, byte[] askexch, Quote[] bidbk, Quote[] askbk, output x) { string _quoteinstrument = instr.sym + instr.maturity + instr.callput + instr.strike; #region Quote Filtering List<FilteredQuote> _Bidbk = new List<FilteredQuote>(); List<FilteredQuote> _Askbk = new List<FilteredQuote>(); List<char> _Bidexch = new List<char>(); List<char> _Askexch = new List<char>(); calib.QuoteFiltering(bidexch, bidbk, _Bidbk, _Bidexch); calib.QuoteFiltering(askexch, askbk, _Askbk, _Askexch); #endregion x._Wbidsz = calib.CalculateWsz(_Bidbk); x._Wasksz = calib.CalculateWsz(_Askbk); if (x._Wbidsz == 0) { x._Wbidprc = 0; } else { x._Wbidprc = calib.CalculateWprc(_Bidbk) / x._Wbidsz; } if (x._Wasksz == 0) { x._Waskprc = 0; } else { x._Waskprc = calib.CalculateWprc(_Askbk) / x._Wasksz; } if (x._Wbidprc == 0) { //low the weight by (wbidprc = 0 + waskprc + askprc[0]) / 3 x._Wmidpt = (x._Waskprc + _Askbk[0]._prc) / 3; x._Vwap = x._Wmidpt; } else if (x._Waskprc == 0) { x._Wmidpt = (x._Wbidprc + _Bidbk[0]._prc) / 3; x._Vwap = x._Wmidpt; } else { x._Wmidpt = (x._Wbidprc + x._Waskprc) / 2; x._Vwap = calib.CalculateVWAP(_Bidbk, _Askbk); } x.svwap = (x._Wmidpt + x._Vwap) / 2; Console.WriteLine(_quoteinstrument + " " + x.svwap); //asynsocketclient.StartSend("10.0.7.218",15000, x.stock + "|" + x.svwap); //sclient.start("10.0.7.182", x.stock + "|" + x.svwap); if (x.flag == true) { sclient.start(x.ip, x.stock + "|" + x.svwap); } else { x.flag = true; if (x.index == 1) { while (x.nearby.flag != true) { Thread.Sleep(30); } if (x.instr.strike > x.stock) { float svwap = x.svwap * (x.stock - x.nearby.instr.strike) / (x.instr.strike - x.nearby.instr.strike) + x.nearby.svwap * (x.instr.strike - x.stock) / (x.instr.strike - x.nearby.instr.strike); sclient.start(x.ip, x.stock + "|" + svwap); } } } Console.WriteLine("ip: " + x.ip); }
static InstrInfo[] ReadInfos() { var reader = new DataReader(GetSerializedInstrInfos()); var infos = new InstrInfo[IcedConstants.NumberOfCodeValues]; var strings = FormatterStringsTable.GetStringsTable(); var ca = new char[1]; string s, s2, s3, s4; uint v, v2, v3, v4; int prevIndex = -1; for (int i = 0; i < infos.Length; i++) { byte f = reader.ReadByte(); var ctorKind = (CtorKind)(f & 0x7F); int currentIndex; if (ctorKind == CtorKind.Previous) { currentIndex = reader.Index; reader.Index = prevIndex; ctorKind = (CtorKind)(reader.ReadByte() & 0x7F); } else { currentIndex = -1; prevIndex = reader.Index - 1; } s = strings[reader.ReadCompressedUInt32()]; if ((f & 0x80) != 0) { ca[0] = 'v'; s = AddPrefix(s, ca); } InstrInfo instrInfo; switch (ctorKind) { case CtorKind.Normal_1: instrInfo = new SimpleInstrInfo(s); break; case CtorKind.Normal_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo(s, (InstrOpInfoFlags)v); break; case CtorKind.AamAad: instrInfo = new SimpleInstrInfo_AamAad(s); break; case CtorKind.asz: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_as((int)v, s); break; case CtorKind.AX: instrInfo = new SimpleInstrInfo_AX(s); break; case CtorKind.AY: instrInfo = new SimpleInstrInfo_AY(s); break; case CtorKind.bcst: v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_bcst(s, (InstrOpInfoFlags)v, (InstrOpInfoFlags)v2); break; case CtorKind.bnd_1: instrInfo = new SimpleInstrInfo_bnd(s); break; case CtorKind.bnd_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_bnd(s, (InstrOpInfoFlags)v); break; case CtorKind.DeclareData: instrInfo = new SimpleInstrInfo_DeclareData((Code)i, s); break; case CtorKind.DX: instrInfo = new SimpleInstrInfo_DX(s); break; case CtorKind.er_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er((int)v, s); break; case CtorKind.er_3: v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_er((int)v, s, (InstrOpInfoFlags)v2); break; case CtorKind.far: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_far((int)v, s); break; case CtorKind.far_mem: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_far_mem((int)v, s); break; case CtorKind.invlpga: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_invlpga((int)v, s); break; case CtorKind.maskmovq: instrInfo = new SimpleInstrInfo_maskmovq(s); break; case CtorKind.mmxmem_1: instrInfo = new SimpleInstrInfo_mmxmem(s); break; case CtorKind.mmxmem_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_mmxmem(s, (InstrOpInfoFlags)v); break; case CtorKind.mmxmem_3: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_mmxmem(s, (InstrOpInfoFlags)v, (MemorySize)v2); break; case CtorKind.movabs: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_movabs((int)v, s); break; case CtorKind.ms_pops: v2 = reader.ReadByte(); v3 = reader.ReadCompressedUInt32(); v4 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_ms_pops(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v2), (InstrOpInfoFlags)v3, (MemorySize)v4); break; case CtorKind.nop: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_nop((int)v, s, (Register)v2); break; case CtorKind.OpSize: v = reader.ReadByte(); ca[0] = 'w'; s2 = AddSuffix(s, ca); ca[0] = 'd'; s3 = AddSuffix(s, ca); ca[0] = 'q'; s4 = AddSuffix(s, ca); instrInfo = new SimpleInstrInfo_OpSize((CodeSize)v, s, s2, s3, s4); break; case CtorKind.OpSize2_bnd: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; s4 = strings[reader.ReadCompressedUInt32()]; instrInfo = new SimpleInstrInfo_OpSize2_bnd(s, s2, s3, s4); break; case CtorKind.OpSize3: ca[0] = (char)reader.ReadByte(); s2 = AddSuffix(s, ca); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_OpSize3((int)v, s, s2); break; case CtorKind.os_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os((int)v, s); break; case CtorKind.os_3: v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os((int)v, s, (InstrOpInfoFlags)v2); break; case CtorKind.os_call_2: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_call((int)v, s); break; case CtorKind.os_call_3: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); if (v2 > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_os_call((int)v, s, v2 != 0); break; case CtorKind.CC_1: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s }); break; case CtorKind.CC_2: s2 = strings[reader.ReadCompressedUInt32()]; v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s, s2 }); break; case CtorKind.CC_3: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_cc((int)v, new[] { s, s2, s3 }); break; case CtorKind.os_jcc_a_1: v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s }); break; case CtorKind.os_jcc_a_2: s2 = strings[reader.ReadCompressedUInt32()]; v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s, s2 }); break; case CtorKind.os_jcc_a_3: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; v2 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v2, new[] { s, s2, s3 }); break; case CtorKind.os_jcc_b_1: v3 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v3, new[] { s }, (InstrOpInfoFlags)v2); break; case CtorKind.os_jcc_b_2: s2 = strings[reader.ReadCompressedUInt32()]; v3 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v3, new[] { s, s2 }, (InstrOpInfoFlags)v2); break; case CtorKind.os_jcc_b_3: s2 = strings[reader.ReadCompressedUInt32()]; s3 = strings[reader.ReadCompressedUInt32()]; v3 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_jcc((int)v, (int)v3, new[] { s, s2, s3 }, (InstrOpInfoFlags)v2); break; case CtorKind.os_loopcc: s2 = strings[reader.ReadCompressedUInt32()]; v3 = reader.ReadCompressedUInt32(); v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_os_loop((int)v, (int)v3, (Register)v2, new[] { s, s2 }); break; case CtorKind.os_loop: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_os_loop((int)v, -1, (Register)v2, new[] { s }); break; case CtorKind.os_mem: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem((int)v, s); break; case CtorKind.os_mem_reg16: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem_reg16((int)v, s); break; case CtorKind.os_mem2: v = reader.ReadCompressedUInt32(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_os_mem2((int)v, s, (InstrOpInfoFlags)v2); break; case CtorKind.pblendvb_1: instrInfo = new SimpleInstrInfo_pblendvb(s); break; case CtorKind.pblendvb_2: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pblendvb(s, (MemorySize)v); break; case CtorKind.pclmulqdq: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pclmulqdq(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v)); break; case CtorKind.pops_2: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_pops(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v)); break; case CtorKind.pops_3: v = reader.ReadByte(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_pops(s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v), (InstrOpInfoFlags)v2); break; case CtorKind.Reg16: instrInfo = new SimpleInstrInfo_Reg16(s); break; case CtorKind.reverse2: instrInfo = new SimpleInstrInfo_reverse2(s); break; case CtorKind.sae: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_sae((int)v, s); break; case CtorKind.sae_pops: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_sae_pops((int)v, s, FormatterConstants.GetPseudoOps((PseudoOpsKind)v2)); break; case CtorKind.SEX1: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_SEX1((int)v, (SignExtendInfo)v2, s); break; case CtorKind.SEX1a: v = reader.ReadCompressedUInt32(); v2 = reader.ReadByte(); instrInfo = new SimpleInstrInfo_SEX1a((int)v, (SignExtendInfo)v2, s); break; case CtorKind.SEX2_2: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_SEX2((SignExtendInfo)v, s); break; case CtorKind.SEX2_3: v = reader.ReadByte(); v2 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_SEX2((SignExtendInfo)v, s, (InstrOpInfoFlags)v2); break; case CtorKind.SEX2_4: v = reader.ReadByte(); v2 = reader.ReadByte(); v3 = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_SEX2((SignExtendInfo)v, (SignExtendInfo)v2, s, (InstrOpInfoFlags)v3); break; case CtorKind.SEX3: v = reader.ReadByte(); instrInfo = new SimpleInstrInfo_SEX3((SignExtendInfo)v, s); break; case CtorKind.STIG1_1: instrInfo = new SimpleInstrInfo_STIG1(s); break; case CtorKind.STIG1_2: v = reader.ReadByte(); if (v > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_STIG1(s, v != 0); break; case CtorKind.STIG2_2a: v = reader.ReadByte(); if (v > 1) { throw new InvalidOperationException(); } instrInfo = new SimpleInstrInfo_STIG2(s, v != 0); break; case CtorKind.STIG2_2b: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_STIG2(s, (InstrOpInfoFlags)v); break; case CtorKind.xbegin: v = reader.ReadCompressedUInt32(); instrInfo = new SimpleInstrInfo_xbegin((int)v, s); break; case CtorKind.XLAT: instrInfo = new SimpleInstrInfo_XLAT(s); break; case CtorKind.XY: instrInfo = new SimpleInstrInfo_XY(s); break; case CtorKind.YA: instrInfo = new SimpleInstrInfo_YA(s); break; case CtorKind.YD: instrInfo = new SimpleInstrInfo_YD(s); break; case CtorKind.YX: instrInfo = new SimpleInstrInfo_YX(s); break; default: throw new InvalidOperationException(); } infos[i] = instrInfo; if (currentIndex >= 0) { reader.Index = currentIndex; } } if (reader.CanRead) { throw new InvalidOperationException(); } return(infos); }
public static void subtask(InstrInfo instr, uint ts, byte[] bidexch, byte[] askexch, Quote[] bidbk, Quote[] askbk, output x) { lock (locker) { x.instr = new InstrInfo { sym = x.under, maturity = x.exp, callput = (MktSrvcAPI.InstrInfo.ECallPut)(x.callput == "CALL" ? 1 : 0), type = InstrInfo.EType.OPTION }; if (bidexch != null && askexch != null) { x.stock = (bidbk[0].prc + askbk[0].prc) / 2; } else if (bidexch != null && askexch == null) { x.stock = bidbk[0].prc; } else if (bidexch == null && askexch != null) { x.stock = askbk[0].prc; } else { x.stock = 0.0f; } Console.WriteLine(x.under + " " + x.stock); //ATM List<float> strikes = Conn.Dict[x.under + x.exp + x.callput]; strikes.Sort(); if (strikes[0] < x.stock && strikes[strikes.Count - 1] > x.stock) { foreach (float s in strikes) { if (s - x.stock >= 0) { if (s - x.stock == 0) { x.instr.strike = s; x.flag = true; reqFlow2.requestFlow(x, x); } else { output y = new output(); x.instr.strike = s; y.instr = new InstrInfo { sym = x.under, maturity = x.exp, callput = (MktSrvcAPI.InstrInfo.ECallPut)(x.callput == "CALL" ? 1 : 0), type = InstrInfo.EType.OPTION }; y.under = x.under; y.exp = x.exp; y.callput = x.callput; y.ip = x.ip; y.instr.strike = strikes[strikes.IndexOf(s) - 1]; x.flag = false; y.flag = false; x.nearby = y; y.nearby = x; x.index = 1; y.index = 0; reqFlow2.requestFlow(y, x); } break; } } } else if (strikes[0] == x.stock) { x.instr.strike = strikes[0]; reqFlow2.requestFlow(x, x); } else if (strikes[strikes.Count - 1] == x.stock) { x.instr.strike = strikes[strikes.Count - 1]; reqFlow2.requestFlow(x, x); } else { //pass } } }