public void CustomOffsets() { // reset "book" reset(); // get default offset ot.DefaultOffset = SampleOffset(); // verify that random symbol has default values Assert.AreEqual(ot.DefaultOffset.ProfitPercent, ot[SYMB].ProfitPercent); Assert.AreEqual(ot.DefaultOffset.StopPercent, ot[SYMB].StopPercent); Assert.AreEqual(ot.DefaultOffset.ProfitDist, ot[SYMB].ProfitDist); Assert.AreEqual(ot.DefaultOffset.StopDist, ot[SYMB].StopDist); // add custom offset different than default ot[SYMB] = new OffsetInfo(POFFSET * 2, SOFFSET * 2, .5m, .5m, true, 100); // verify custom has taken effect Assert.AreEqual(ot.DefaultOffset.ProfitPercent / 2, ot[SYMB].ProfitPercent); Assert.AreEqual(ot.DefaultOffset.StopPercent / 2, ot[SYMB].StopPercent); Assert.AreEqual(ot.DefaultOffset.ProfitDist * 2, ot[SYMB].ProfitDist); Assert.AreEqual(ot.DefaultOffset.StopDist * 2, ot[SYMB].StopDist); // verify another symbol still has default Assert.AreEqual(ot.DefaultOffset.ProfitPercent, ot[SYMC].ProfitPercent); Assert.AreEqual(ot.DefaultOffset.StopPercent, ot[SYMC].StopPercent); Assert.AreEqual(ot.DefaultOffset.ProfitDist, ot[SYMC].ProfitDist); Assert.AreEqual(ot.DefaultOffset.StopDist, ot[SYMC].StopDist); }
public void Execute() { var prevIndex = -1; for (var i = SortedEntities.Length - 1; i >= 0; --i) { var entity = SortedEntities[i].Value; if (!EntitiesIndexMap.TryGetValue(entity, out var index)) { continue; } var vertexData = Vertices[entity]; var vertexIndexData = VertexIndices[entity]; var sharedComponentIndex = SharedComponentIndices[index]; var prevSharedComponentIndex = prevIndex >= 0 ? SharedComponentIndices[prevIndex] : -1; Offsets[index] = new OffsetInfo { Vertex = VertexCounter.Value, VertexCount = vertexData.Length, Indices = VertexIndexCounter.Value, SubMeshIndex = sharedComponentIndex != prevSharedComponentIndex ? SubMeshCounter.Value : -1, SubMesh = sharedComponentIndex != prevSharedComponentIndex ? VertexIndexCounter.Value : -1, SubMeshMaterialId = sharedComponentIndex != prevSharedComponentIndex ? sharedComponentIndex : -1 }; if (sharedComponentIndex != prevSharedComponentIndex) { SubMeshCounter.Increment(1); } VertexCounter.Increment(vertexData.Length); VertexIndexCounter.Increment(vertexIndexData.Length); prevIndex = index; } }
public void SerializeDeserialize() { OffsetInfo oi = new OffsetInfo(2, 1); string msg = OffsetInfo.Serialize(oi); OffsetInfo co = OffsetInfo.Deserialize(msg); Assert.AreEqual(2, oi.ProfitDist); Assert.AreEqual(1, oi.StopDist); }
private static string FormatMessage(OffsetInfo location, string message) { return(String.Concat( location.LineNumber.ToString(CultureInfo.InvariantCulture), ":", location.ColumnNumber.ToString(CultureInfo.InvariantCulture), ": ", message )); }
public void TrailStartedAfterFirePoint() { // setup trail tracker TrailTracker tt = new TrailTracker(); tt.isValid = true; const string acct = "DEFAULT"; tt.pt.DefaultAccount = acct; tt.SendOrder += new OrderDelegate(tt_SendOrder); //tt.SendDebug += new DebugFullDelegate(tt_SendDebug); // set 15c trailing stop tt.DefaultTrail = new OffsetInfo(0, .15m); // verify it's set Assert.AreEqual(.15m, tt.DefaultTrail.StopDist); // tt.TrailByDefault = true; // put in a position to track tt.Adjust(new PositionImpl(SYM, 11.00m, 100, 0m, acct)); // check position in tt-pt Assert.AreEqual(1, tt.pt.Count); // manually enter a trail tt[SYM] = new OffsetInfo(0m, .25m); // check if trail entered for symbol Assert.AreEqual(.25m, tt[SYM].StopDist); // get feed Tick[] tape = SampleData(); // test broker Broker b = new Broker(); // get fills over to trail tracker b.GotFill += new FillDelegate(tt.Adjust); // get orders from trail tracker tt.SendOrder += new OrderDelegate(b.SendOrder); // no orders to start oc = 0; // iterate through feed for (int i = 0; i < tape.Length; i++) { Tick k = tape[i]; // set a date and time k.date = 20070926; k.time = 95500; // execute orders, nothing to do on first two ticks b.Execute(k); // pass every tick to tracker tt.newTick(k); } Assert.AreEqual(1, oc); }
void CreateOffsets( NativeHashMap <Entity, int> entitiesIndexMap, NativeArray <SortedEntity> sortedEntities, NativeArray <int> sharedComponentIndices, NativeArray <OffsetInfo> offsets, NativeCounter vertexCounter, NativeCounter vertexIndexCounter, NativeCounter subMeshCounter) { var vertices = GetBufferFromEntity <Vertex>(true); var vertexIndices = GetBufferFromEntity <VertexIndex>(true); Job .WithReadOnly(entitiesIndexMap) .WithReadOnly(sortedEntities) .WithReadOnly(sharedComponentIndices) .WithReadOnly(vertices) .WithReadOnly(vertexIndices) .WithCode(() => { var prevIndex = -1; for (var i = sortedEntities.Length - 1; i >= 0; --i) { var entity = sortedEntities[i].Value; if (!entitiesIndexMap.TryGetValue(entity, out var index)) { continue; } var vertexData = vertices[entity]; var vertexIndexData = vertexIndices[entity]; var sharedComponentIndex = sharedComponentIndices[index]; var prevSharedComponentIndex = prevIndex >= 0 ? sharedComponentIndices[prevIndex] : -1; offsets[index] = new OffsetInfo { Vertex = vertexCounter.Value, VertexCount = vertexData.Length, Indices = vertexIndexCounter.Value, SubMeshIndex = sharedComponentIndex != prevSharedComponentIndex ? subMeshCounter.Value : -1, SubMesh = sharedComponentIndex != prevSharedComponentIndex ? vertexIndexCounter.Value : -1, SubMeshMaterialId = sharedComponentIndex != prevSharedComponentIndex ? sharedComponentIndex : -1 }; if (sharedComponentIndex != prevSharedComponentIndex) { subMeshCounter.Increment(1); } vertexCounter.Increment(vertexData.Length); vertexIndexCounter.Increment(vertexIndexData.Length); prevIndex = index; } }).Schedule(); }
public static bool IsDuplicate(OffsetInfo offsetInfo, List <OffsetInfo> offsetList) { if (offsetList.Count != 0) { foreach (var offset in offsetList) { if (offsetInfo.Offset == offset.Offset) { MyMessage.MsgShowWarning(@"Found Duplicate " + offsetInfo.Offset + @", Please Check it again before adding a offset!!!"); return(true); } } } return(false); }
private OffsetInfo GetOffsetInfo(Point offset) { var info = new OffsetInfo(); var lastPositive = Array.IndexOf(offset.Coordinates, 1); var lastNegative = Array.IndexOf(offset.Coordinates, -1); info.Dimension = lastNegative == -1 ? lastPositive : lastNegative; info.Forward = lastNegative == -1; info.Direction = info.Dimension * 2; if (info.Forward) { info.Direction++; } return(info); }
public void ResendTest2() { // reset "book" to start from scratch reset(); // SETOFFSET("IBM", 0.03, 0, 1, 0); const string sym = "IBM"; const decimal pdist = .03m; const decimal pct = 1; ot[sym] = new OffsetInfo(pdist, 0, pct, 0, false, 1); Assert.AreEqual(pdist, ot[sym].ProfitDist); Assert.AreEqual(pct, ot[sym].ProfitPercent); // entry fill // 094508: fill: 20100423,94532,IBM,SELL,10,128.85, 0 fill(new TradeImpl(sym, 128.85m, -10)); Assert.AreEqual(-10, ot.PositionTracker[sym].Size); // profit // 094508: sent new profit: 634076112353906253 BUY10 [email protected] [] 634076112353906253 Assert.AreEqual(1, profits.Count); Order profit = profits[0]; Assert.AreEqual(128.82m, profit.price); Assert.AreEqual(10, profit.size); // fill profit // 094609: fill: 20100423,94632,IBM,BUY,10,128.82, 634076112353906253 // 094609: IBM hit profit: 634076112353906253 Assert.IsTrue(profit.Fill(TickImpl.NewTrade(sym, 128.82m, 10))); Trade profitfill = (Trade)profit; fill(profitfill); // we're now flat // 094609: IBM now flat. Assert.IsTrue(ot.PositionTracker[sym].isFlat); // tick ot.newTick(TickImpl.NewTrade(sym, 128.82m, 100)); Assert.AreEqual(0, profits.Count); // re-enter //094722: fill: 20100423,94746,IBM,SELL,10,128.86, 100947 fill(new TradeImpl(sym, 128.86m, -10)); Assert.AreEqual(-10, ot.PositionTracker[sym].Size); // we should now have a profit offset Assert.AreEqual(1, profits.Count); profit = profits[0]; Assert.AreEqual(128.83m, profit.price); Assert.AreEqual(10, profit.size); }
private void btnSave_Click(object sender, EventArgs e) { if (!MyMessage.MsgOkCancel("Do you want to save?\n\n" + "Click \"OK\" to confirm.\n\n" + "Click \"Cancel\" to cancel.")) { return; } try { var offsetList = new List <OffsetInfo>(); for (var i = 0; i < dataList.Rows.Count; i++) { var offset = new OffsetInfo { OffsetId = i, Offset = dataList.Rows[i].Cells[0].Value.ToString(), Hex = dataList.Rows[i].Cells[1].Value.ToString() }; offsetList.Add(offset); } OffsetPatch.FunctionList[_index] = new FunctionList() { CheatName = txtNameCheat.Text, FunctionValue = txtValues.Text, FunctionType = _type, OffsetList = offsetList, MultipleValue = chkMultiple.Checked, HookInfo = HookValue() }; Dispose(); } catch (Exception exception) { MyMessage.MsgShowError("Error" + exception.Message); } }
/// <summary> /// Completely populate all Region property members. Missing data /// is computed based on the values that are already present. /// </summary> /// <param name="region"></param> /// <param name="newLineIndex"></param> public static void Populate(this Region region, NewLineIndex newLineIndex) { // TODO: we need charOffset and byteOffset to be expressed as // nullable types in order to differentiate between text // and binary file regions. For text files, we need to populate // startLine, etc. based on document offset. For now, we'll // assume we're always looking at text files if (region.StartLine == 0) { OffsetInfo offsetInfo = newLineIndex.GetOffsetInfoForOffset(region.Offset); region.StartLine = offsetInfo.LineNumber; region.StartColumn = offsetInfo.ColumnNumber; offsetInfo = newLineIndex.GetOffsetInfoForOffset(region.Offset + region.Length); region.StartLine = offsetInfo.LineNumber; region.EndColumn = offsetInfo.ColumnNumber; } else { // Make endColumn and endLine explicit, if not expressed if (region.EndLine == 0) { region.EndLine = region.StartLine; } if (region.EndColumn == 0) { region.EndColumn = region.StartColumn; } LineInfo lineInfo = newLineIndex.GetLineInfoForLine(region.StartLine); region.Offset = lineInfo.StartOffset + (region.StartColumn - 1); lineInfo = newLineIndex.GetLineInfoForLine(region.EndLine); region.Length = lineInfo.StartOffset + (region.EndColumn - 1) - region.Offset; } }
private static DeclarationList CreateCurrentDeclarations() { DeclarationList declarationList = new DeclarationList(); int num = 1; declarationList[num++] = IDOwner.GetDeclaration(); declarationList[num++] = ReportItem.GetDeclaration(); num++; declarationList[num++] = Report.GetDeclaration(); declarationList[num++] = PageSection.GetDeclaration(); declarationList[num++] = Line.GetDeclaration(); declarationList[num++] = Rectangle.GetDeclaration(); declarationList[num++] = Image.GetDeclaration(); num++; declarationList[num++] = CheckBox.GetDeclaration(); declarationList[num++] = TextBox.GetDeclaration(); declarationList[num++] = SubReport.GetDeclaration(); declarationList[num++] = ActiveXControl.GetDeclaration(); declarationList[num++] = DataRegion.GetDeclaration(); num++; declarationList[num++] = ReportHierarchyNode.GetDeclaration(); declarationList[num++] = Grouping.GetDeclaration(); declarationList[num++] = Sorting.GetDeclaration(); declarationList[num++] = List.GetDeclaration(); declarationList[num++] = Pivot.GetDeclaration(); declarationList[num++] = Matrix.GetDeclaration(); declarationList[num++] = PivotHeading.GetDeclaration(); declarationList[num++] = MatrixHeading.GetDeclaration(); declarationList[num++] = MatrixColumn.GetDeclaration(); num++; declarationList[num++] = MatrixRow.GetDeclaration(); num++; declarationList[num++] = Subtotal.GetDeclaration(); declarationList[num++] = Table.GetDeclaration(); declarationList[num++] = TableColumn.GetDeclaration(); num++; declarationList[num++] = TableGroup.GetDeclaration(); declarationList[num++] = TableRow.GetDeclaration(); num++; declarationList[num++] = OWCChart.GetDeclaration(); declarationList[num++] = ChartColumn.GetDeclaration(); num++; declarationList[num++] = ReportItemCollection.GetDeclaration(); declarationList[num++] = ReportItemIndexer.GetDeclaration(); num++; declarationList[num++] = Style.GetDeclaration(); num++; declarationList[num++] = AttributeInfo.GetDeclaration(); declarationList[num++] = Visibility.GetDeclaration(); declarationList[num++] = ExpressionInfo.GetDeclaration(); num++; declarationList[num++] = DataAggregateInfo.GetDeclaration(); num++; declarationList[num++] = RunningValueInfo.GetDeclaration(); num++; num++; declarationList[num++] = Filter.GetDeclaration(); num++; declarationList[num++] = DataSource.GetDeclaration(); num++; declarationList[num++] = DataSet.GetDeclaration(); num++; declarationList[num++] = ReportQuery.GetDeclaration(); declarationList[num++] = Field.GetDeclaration(); num++; declarationList[num++] = ParameterValue.GetDeclaration(); num++; num++; num++; num++; declarationList[num++] = ReportSnapshot.GetDeclaration(); declarationList[num++] = SenderInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = ReceiverInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = DocumentMapNode.GetDeclaration(); declarationList[num++] = InfoBase.GetDeclaration(); declarationList[num++] = OffsetInfo.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = ReportItemInstanceInfo.GetDeclaration(); declarationList[num++] = ReportInstanceInfo.GetDeclaration(); declarationList[num++] = ReportItemColInstanceInfo.GetDeclaration(); declarationList[num++] = LineInstanceInfo.GetDeclaration(); declarationList[num++] = TextBoxInstanceInfo.GetDeclaration(); declarationList[num++] = RectangleInstanceInfo.GetDeclaration(); declarationList[num++] = CheckBoxInstanceInfo.GetDeclaration(); declarationList[num++] = ImageInstanceInfo.GetDeclaration(); declarationList[num++] = SubReportInstanceInfo.GetDeclaration(); declarationList[num++] = ActiveXControlInstanceInfo.GetDeclaration(); declarationList[num++] = ListInstanceInfo.GetDeclaration(); declarationList[num++] = ListContentInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixHeadingInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixCellInstanceInfo.GetDeclaration(); declarationList[num++] = TableInstanceInfo.GetDeclaration(); declarationList[num++] = TableGroupInstanceInfo.GetDeclaration(); declarationList[num++] = TableRowInstanceInfo.GetDeclaration(); declarationList[num++] = OWCChartInstanceInfo.GetDeclaration(); declarationList[num++] = ChartInstanceInfo.GetDeclaration(); declarationList[num++] = NonComputedUniqueNames.GetDeclaration(); declarationList[num++] = InstanceInfoOwner.GetDeclaration(); declarationList[num++] = ReportItemInstance.GetDeclaration(); num++; declarationList[num++] = ReportInstance.GetDeclaration(); declarationList[num++] = ReportItemColInstance.GetDeclaration(); declarationList[num++] = LineInstance.GetDeclaration(); declarationList[num++] = TextBoxInstance.GetDeclaration(); declarationList[num++] = RectangleInstance.GetDeclaration(); declarationList[num++] = CheckBoxInstance.GetDeclaration(); declarationList[num++] = ImageInstance.GetDeclaration(); declarationList[num++] = SubReportInstance.GetDeclaration(); declarationList[num++] = ActiveXControlInstance.GetDeclaration(); declarationList[num++] = ListInstance.GetDeclaration(); declarationList[num++] = ListContentInstance.GetDeclaration(); num++; declarationList[num++] = MatrixInstance.GetDeclaration(); declarationList[num++] = MatrixHeadingInstance.GetDeclaration(); num++; declarationList[num++] = MatrixCellInstance.GetDeclaration(); num++; num++; declarationList[num++] = TableInstance.GetDeclaration(); declarationList[num++] = TableRowInstance.GetDeclaration(); declarationList[num++] = TableColumnInstance.GetDeclaration(); declarationList[num++] = TableGroupInstance.GetDeclaration(); num++; declarationList[num++] = OWCChartInstance.GetDeclaration(); declarationList[num++] = ParameterInfo.GetDeclaration(); num++; num++; num++; declarationList[num++] = InstanceInfo.GetDeclaration(); num++; declarationList[num++] = RecordSetInfo.GetDeclaration(); declarationList[num++] = RecordRow.GetDeclaration(); declarationList[num++] = RecordField.GetDeclaration(); declarationList[num++] = ValidValue.GetDeclaration(); num++; declarationList[num++] = ParameterDataSource.GetDeclaration(); declarationList[num++] = ParameterDef.GetDeclaration(); num++; declarationList[num++] = ParameterBase.GetDeclaration(); num++; declarationList[num++] = ProcessingMessage.GetDeclaration(); declarationList[num++] = MatrixSubtotalHeadingInstanceInfo.GetDeclaration(); declarationList[num++] = MatrixSubtotalCellInstance.GetDeclaration(); declarationList[num++] = CodeClass.GetDeclaration(); num++; declarationList[num++] = TableDetail.GetDeclaration(); declarationList[num++] = TableDetailInstance.GetDeclaration(); num++; declarationList[num++] = TableDetailInstanceInfo.GetDeclaration(); num++; declarationList[num++] = Action.GetDeclaration(); declarationList[num++] = ActionInstance.GetDeclaration(); declarationList[num++] = Chart.GetDeclaration(); declarationList[num++] = ChartHeading.GetDeclaration(); declarationList[num++] = ChartDataPoint.GetDeclaration(); num++; declarationList[num++] = MultiChart.GetDeclaration(); declarationList[num++] = MultiChartInstance.GetDeclaration(); num++; declarationList[num++] = Axis.GetDeclaration(); declarationList[num++] = AxisInstance.GetDeclaration(); declarationList[num++] = ChartTitle.GetDeclaration(); declarationList[num++] = ChartTitleInstance.GetDeclaration(); declarationList[num++] = ThreeDProperties.GetDeclaration(); declarationList[num++] = PlotArea.GetDeclaration(); declarationList[num++] = Legend.GetDeclaration(); declarationList[num++] = GridLines.GetDeclaration(); declarationList[num++] = ChartDataLabel.GetDeclaration(); declarationList[num++] = ChartInstance.GetDeclaration(); declarationList[num++] = ChartHeadingInstance.GetDeclaration(); declarationList[num++] = ChartHeadingInstanceInfo.GetDeclaration(); num++; declarationList[num++] = ChartDataPointInstance.GetDeclaration(); declarationList[num++] = ChartDataPointInstanceInfo.GetDeclaration(); num++; num++; declarationList[num++] = RenderingPagesRanges.GetDeclaration(); num++; declarationList[num++] = IntermediateFormatVersion.GetDeclaration(); declarationList[num++] = ImageInfo.GetDeclaration(); declarationList[num++] = ActionItem.GetDeclaration(); declarationList[num++] = ActionItemInstance.GetDeclaration(); num++; num++; declarationList[num++] = DataValue.GetDeclaration(); declarationList[num++] = DataValueInstance.GetDeclaration(); num++; num++; declarationList[num++] = Tablix.GetDeclaration(); declarationList[num++] = TablixHeading.GetDeclaration(); declarationList[num++] = CustomReportItem.GetDeclaration(); declarationList[num++] = CustomReportItemInstance.GetDeclaration(); declarationList[num++] = CustomReportItemHeading.GetDeclaration(); declarationList[num++] = CustomReportItemHeadingInstance.GetDeclaration(); num++; num++; num++; num++; declarationList[num++] = CustomReportItemCellInstance.GetDeclaration(); num++; num++; declarationList[num++] = DataValueCRIList.GetDeclaration(); declarationList[num++] = BookmarkInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = DrillthroughInformation.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); num++; declarationList[num++] = CustomReportItemInstanceInfo.GetDeclaration(); declarationList[num++] = ImageMapAreaInstanceList.GetDeclaration(); declarationList[num++] = ImageMapAreaInstance.GetDeclaration(); num++; declarationList[num++] = InstanceInfo.GetDeclaration(); declarationList[num++] = SortFilterEventInfo.GetDeclaration(); declarationList[num++] = EndUserSort.GetDeclaration(); num++; num++; declarationList[num++] = RecordSetPropertyNames.GetDeclaration(); num++; num++; num++; declarationList[num++] = PageSectionInstance.GetDeclaration(); num++; declarationList[num++] = PageSectionInstanceInfo.GetDeclaration(); declarationList[num++] = SimpleTextBoxInstanceInfo.GetDeclaration(); declarationList[num++] = ScopeLookupTable.GetDeclaration(); num++; declarationList[num++] = ReportDrillthroughInfo.GetDeclaration(); declarationList[num++] = InstanceInfo.GetDeclaration(); Global.Tracer.Assert(declarationList.Count == num, "(current.Count == index)"); return(declarationList); }
/// <summary>Initializes a new instance of the <see cref="G4ParseFailureException"/> class.</summary> /// <param name="info">The serialization info from which the value shall be deserialized.</param> /// <param name="context">The streaming context from which the value shall be deserialized.</param> private G4ParseFailureException(SerializationInfo info, StreamingContext context) : base(info, context) { this.Location = (OffsetInfo)info.GetValue("Location", typeof(OffsetInfo)); }
/// <summary> /// Initializes a new instance of the <see cref="G4ParseFailureException"/> class. /// </summary> /// <param name="location">The location in the source text where the parse failure occurred.</param> /// <param name="message">The message indicating why the failure occurred.</param> /// <param name="args">The arguments to use when formatting <paramref name="message"/>.</param> public G4ParseFailureException(OffsetInfo location, string message, params string[] args) : base(FormatMessage(location, String.Format(CultureInfo.InvariantCulture, message, args))) { this.Location = location; }
/// <summary> /// Initializes a new instance of the <see cref="G4ParseFailureException"/> class. /// </summary> /// <param name="location">The location in the source text where the parse failure occurred.</param> /// <param name="message">The message indicating why the failure occurred.</param> public G4ParseFailureException(OffsetInfo location, string message) : base(FormatMessage(location, message)) { this.Location = location; }