UnitsType m_Units = UnitsType.Celsius; // this defines the units of the new input temperatures, but our calculations will be in Celcius #endregion Fields #region Constructors // constructor public Thermometer(UnitsType units, DirectionType direction, double threshold, double hysterisis) { Units = units; Direction = direction; Threshold = threshold; HysterisisThreshold = hysterisis; }
// ------------------------------------------------------------------------------------ // private void changeDirectionRandom() { float angle = 0; if (currentDirectionType == DirectionType.Forward) { if (Probability.getProbability(50)) { currentDirectionType = DirectionType.Left; angle = rotateAngle; } else { currentDirectionType = DirectionType.Right; angle = -rotateAngle; } } else if (currentDirectionType == DirectionType.Left) { currentDirectionType = DirectionType.Forward; angle = -rotateAngle; } else if (currentDirectionType == DirectionType.Right) { currentDirectionType = DirectionType.Forward; angle = rotateAngle; } rotateUnit(angle); }
public SortNode(XmlNode xmlNode, InternalScriptSettings settings) : base(xmlNode, settings) { // Load attributes foreach (XmlAttribute attr in xmlNode.Attributes) { switch (attr.Name) { case "direction": string dirStr = attr.Value.ToLower().Trim(); if (dirStr == "desc" || dirStr == "descending") direction = DirectionType.DESCENDING; else if (dirStr == "asc" || dirStr == "ascending") direction = DirectionType.ASCENDING; else { logger.Error("Invalid sort direction on: " + xmlNode.OuterXml); } break; case "by": sortBy = attr.Value; break; } } // Validate BY attribute if (sortBy == null) { logger.Error("Missing BY attribute on: " + xmlNode.OuterXml); loadSuccess = false; return; } }
public virtual void moveHere() { Direction favored = null; if (useFavoredDirection) favored = getAt(favoredDirection); Direction[] closest = getNearestDirections(Camera.mainCamera.transform.rotation); Direction turnTo = closest[0]; // If favored is activated & the favored direction is present, // decide whether we should select the favored direction instead if (favored != null && favoredDirection != turnTo.direction) { int indexOfFavored = -1; for (int i = 0; i < closest.Length; i++) { if (closest[i].Equals(favored)) { indexOfFavored = i; break; } } if (indexOfFavored != -1 && indexOfFavored <= Math.Ceiling(((double) closest.Length) / 2.0)) turnTo = favored; } curD = turnTo.direction; CameraAction action = new CameraAction(this, transform.position + offset, turnTo.rotation); CameraController.instance.addAction(action); }
public PacketLogEntry(DateTime time, DirectionType direction, string address, byte[] data) { Time = time; Direction = direction; Address = address; Data = data; }
static public string Convert(double bytes, double reference, DirectionType direction, string format) { ConversionType conversionType; conversionType = GetConversionType(reference); conversionType = MoveDirection(conversionType, direction); return Convert(bytes, conversionType, format); }
public PacketLogEntry(DateTime time, TransportProtocol protocol, DirectionType direction, DhtAddress address, byte[] data) { Time = time; Protocol = protocol; Direction = direction; Address = address; Data = data; }
public Tree(int x, int y) { base.Initialize(x, y, 1, 1, Texture); direction = DirectionType.South; Name = "Tree"; }
public HttpNetworkStream(DirectionType direction, Socket socket, System.IO.FileAccess fileAccess, bool ownsSocket) { Direction = direction; _socket = socket; _stream = new PrependableNetworkStream(socket, fileAccess, ownsSocket); _unknownContentLength = true; }
public HttpNetworkStream(DirectionType direction, ulong contentLength, byte[] prependToStream, Socket socket, System.IO.FileAccess fileAccess, bool ownsSocket) { Direction = direction; _contentLength = contentLength; _socket = socket; _stream = new PrependableNetworkStream(socket, fileAccess, ownsSocket, prependToStream); _unknownContentLength = false; }
public void ResetCounter(StateType state, DirectionType direction) { if (direction != Direction) { _counter = 1000; _animationIndex = 0; } State = state; Direction = direction; }
public EntityPainting(EntityTyped e) : base(e) { EntityPainting e2 = e as EntityPainting; if (e2 != null) { _xTile = e2._xTile; _yTile = e2._yTile; _zTile = e2._zTile; _dir = e2._dir; _motive = e2._motive; } }
public static DirectionType getRight(DirectionType d) { switch (d) { case DirectionType.NORTH: return DirectionType.NORTHEAST; case DirectionType.NORTHEAST: return DirectionType.EAST; case DirectionType.EAST : return DirectionType.SOUTHEAST; case DirectionType.SOUTHEAST : return DirectionType.SOUTH; case DirectionType.SOUTH : return DirectionType.SOUTHWEST; case DirectionType.SOUTHWEST : return DirectionType.WEST; case DirectionType.WEST : return DirectionType.NORTHWEST; case DirectionType.NORTHWEST : return DirectionType.NORTH; default : return DirectionType.NORTH; } }
public TransitDescription(Route route, DirectionType transitType) { if (route == null) { throw new ArgumentNullException("route"); } this.TransitType = transitType; this.StartLocation = route.RouteLegs[0].ActualStart.AsGeoCoordinate(); this.EndLocation = route.RouteLegs[0].ActualEnd.AsGeoCoordinate(); this.TravelDuration = route.TravelDuration; this.ArrivalTime = route.RouteLegs[0].EndTime.ToShortTimeString(); this.DepartureTime = route.RouteLegs[0].StartTime.ToShortTimeString(); // TODO: need to add endpoint to the step list? this.ItinerarySteps = new ObservableCollection<ItineraryStep>(); var stepNumber = 0; foreach (var topLeg in route.RouteLegs[0].ItineraryItems) { this.ItinerarySteps.Add(new ItineraryStep(topLeg, ++stepNumber)); // calculate the walking start and end times if (this.ItinerarySteps[stepNumber - 1].IconType == "Walk") { if (stepNumber == 1) { // WalkOnly directions needs to be set a default time. Using current time this.ItinerarySteps[stepNumber - 1].StartTime = this.TransitType == DirectionType.WalkOnly ? DateTime.Now : route.RouteLegs[0].StartTime; } else { this.ItinerarySteps[stepNumber - 1].StartTime = this.ItinerarySteps[stepNumber - 2].EndTime; } this.ItinerarySteps[stepNumber - 1].EndTime = this.ItinerarySteps[stepNumber - 1].StartTime + TimeSpan.FromSeconds(topLeg.TravelDuration); } } this.ItinerarySteps[0].StepType = ItineraryStep.ItineraryStepType.FirstStep; this.ItinerarySteps[this.ItinerarySteps.Count - 1].StepType = ItineraryStep.ItineraryStepType.LastStep; // check the first and last step for generic strings to replace // TODO: need a better place to put this this.ItinerarySteps[0].Instruction = this.ItinerarySteps[0].Instruction.Replace(SR.SourceLocation, ViewModelLocator.MainMapViewModelStatic.StartLocationText); this.ItinerarySteps[this.ItinerarySteps.Count - 1].Instruction = this.ItinerarySteps[this.ItinerarySteps.Count - 1].Instruction.Replace(SR.DestinationLocation, ViewModelLocator.MainMapViewModelStatic.EndLocationText); this.PathPoints = route.RoutePaths[0].Line; this.MapView = route.BoundingBox.AsLocationRect(); }
public Person(int x, int y) : base(x, y, 1, 1, texturesMap[ProfessionType.Worker]) { age = 0; education = 0; gender = GenderType.Male; health = HEALTH_MAX; profession = ProfessionType.Worker; Random random = new Random(); direction = (DirectionType)(random.Next() % (int)DirectionType.SIZE); remainingMovement = movementRange = 36; BlocksMovement = false; Name = "Person"; }
private IImageManager GetDirectionalImageManager(IImageManager imageManager, DirectionType directionType) { //TODO: Compressed and PDF files need to be able to find each other for the case of a folder containing both .pdf and .cbr IImageManager nextImageManager = null; var path = imageManager.Location; int directionOffset = directionType == DirectionType.Next ? 1 : -1; //TODO: code for CompressedFileImageManager and FolderImageManager is virtually identical. Consolidate! if ((imageManager is CompressedFileImageManager) || (imageManager is PDFImageManager)) { var fileName = Path.GetFileName(path).ToLower(); var fileInfo = new FileInfo(path); var supportFileTypes = imageManager is CompressedFileImageManager ? CompressedFileImageManager.SUPPORTED_FILETYPES : PDFImageManager.SUPPORTED_FILETYPES; var fileInfos = fileInfo.Directory.GetFiles() .Where(x => supportFileTypes.Contains(x.Extension.ToLower())) .OrderBy(x => x.Name, Utility.NaturalStringComparer) .ToList(); var foundFileIndex = fileInfos.FindIndex(x => x.Name.ToLower() == fileName) + directionOffset; if ((foundFileIndex < fileInfos.Count) && (foundFileIndex > -1)) { imageManager.Dispose(); nextImageManager = this.Load(fileInfos[foundFileIndex].FullName); } } else if (imageManager is FolderImageManager) { DirectoryInfo directoryInfo = new DirectoryInfo(path); var directoryName = directoryInfo.Name.ToLower(); var directoryInfos = directoryInfo.Parent.GetDirectories() .OrderBy(x => x.Name, Utility.NaturalStringComparer) .ToList(); var foundDirectoryIndex = directoryInfos.FindIndex(x => x.Name.ToLower() == directoryName) + directionOffset; if ((foundDirectoryIndex < directoryInfos.Count) && (foundDirectoryIndex > -1)) { imageManager.Dispose(); nextImageManager = this.Load(directoryInfos[foundDirectoryIndex].FullName); } } return nextImageManager; }
public void Initialize(string[] parameters) { if (parameters.Contains("Origin")) hasOrigin = true; if (parameters.Contains("Direction")) direction = DirectionType.Direction; else if (parameters.Contains("Angle")) direction = DirectionType.Angle; if (parameters.Contains("Speed")) hasSpeed = true; foreach (string param in parameters) if (param == "Param") paramCount++; }
public InputOrder( string brokerID, string investorID, DirectionType direction, OffsetFlag offsetFlag, string instrumentID, double price, int volume, string groupID) { this.BrokerID = brokerID; this.InvestorID = investorID; this.Direction = direction; this.OffsetFlag = offsetFlag; this.InstrumentID = instrumentID; this.Price = price; this.Volume = volume; this.GroupID = groupID; }
public override sealed void onUnitCollision(GameObject other) { base.onUnitCollision(other); if (other.tag.Equals("LevelBorder")) { float angle = 0; if (currentDirectionType == DirectionType.Left) { currentDirectionType = DirectionType.Right; angle = -rotateAngle*2; } else if (currentDirectionType == DirectionType.Right) { currentDirectionType = DirectionType.Left; angle = rotateAngle*2; } rotateUnit(angle); } }
public Tile getAdjascentTile(Tile t, DirectionType dir) { Tile retval = null; switch(dir) { case DirectionType.West: retval = getTileFromLocation(t.x, t.y - 1); break; case DirectionType.East: retval = getTileFromLocation(t.x, t.y + 1); break; case DirectionType.North: retval = getTileFromLocation(t.x - 1, t.y); break; case DirectionType.South: retval = getTileFromLocation(t.x + 1, t.y); break; default: break; } return retval; }
private void moveCube() { float testCubeXPos = _testCube.transform.position.x; if (_dirType == DirectionType.Left){ _testCube.transform.Translate(Vector3.left * 0.5f); } else if (_dirType == DirectionType.Right){ _testCube.transform.Translate(Vector3.right * 0.5f); } if (testCubeXPos < -3){ TestSignals.changeScaleSignal.dispatch(); _dirType = DirectionType.Right; } if (testCubeXPos > 3) { TestSignals.normalScaleSignal.dispatch(); _dirType = DirectionType.Left; } Debug.Log(testCubeXPos); }
/// <summary> /// /// </summary> public static string ConvertTo(string text, TransliteType type, DirectionType direct) { string output = text; Dictionary<string, string> tdictF = SetDictionary(type); foreach (KeyValuePair<string, string> key in tdictF) { if(direct == DirectionType.OnKaz) { output = output.Replace(key.Key, key.Value); } else if(direct == DirectionType.OutKaz) { output = output.Replace(key.Value, key.Key); } } Dispose(); return output; }
public Passage(DirectionType direction) { this.Direction = direction; //this.Name = "CatFlap V0.1"; }
internal virtual void SetReelSpeed( DirectionType direction, float speed ) { switch ( direction ) { case DirectionType.Down: this.ySpeed = this.protoYSpeed - speed; break; case DirectionType.Up: this.ySpeed = this.protoYSpeed + speed; break; case DirectionType.Left: this.xSpeed = this.protoXSpeed + speed; break; case DirectionType.Right: this.xSpeed = this.protoXSpeed - speed; break; } }
/// <summary> /// /// </summary> /// <param name="pInstrument"></param> /// <param name="pDirection"></param> /// <param name="pOffset"></param> /// <param name="pPrice">价格</param> /// <param name="pVolume"></param> /// <param name="pHedge"></param> /// <param name="pType">报单类型</param> /// <returns></returns> public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, HedgeType pHedge, OrderType pType, string pCustom) { return(((DefReqOrderInsert)Invoke(this._handle, "ReqOrderInsert", typeof(DefReqOrderInsert)))(pInstrument, pDirection, pOffset, pPrice, pVolume, pHedge, pType, pCustom)); }
//设置角色的方向 void SetDirection(DirectionType dir) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, transform.eulerAngles.y + (int)dir, 0), Time.deltaTime); }
public override TypedEntity LoadTree (TagNode tree) { TagNodeCompound ctree = tree as TagNodeCompound; if (ctree == null || base.LoadTree(tree) == null) { return null; } _dir = (DirectionType) ctree["Dir"].ToTagByte().Data; _motive = ctree["Motive"].ToTagString(); _xTile = ctree["TileX"].ToTagInt(); _yTile = ctree["TileY"].ToTagInt(); _zTile = ctree["TileZ"].ToTagInt(); return this; }
public int InputOrder(DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume) { Console.WriteLine(Ticks[0].UpdateTime + " " + Instrument.InstrumentID + "以价格" + pPrice.ToString() + "报单" + pDirection + " " + pVolume.ToString() + "手"); return(t.ReqOrderInsert(Instrument.InstrumentID, pDirection, pOffset, pPrice, pVolume)); }
/// <summary> /// Updates the statistics and graph on the control. /// </summary> /// <param name="messageNumber">Elapsed time.</param> /// <param name="elapsedMilliseconds">Elapsed time.</param> /// <param name="direction">The direction of the I/O operation: Send or Receive.</param> private void InternalUpdateStatistics(long messageNumber, long elapsedMilliseconds, DirectionType direction) { lock (this) { var elapsedSeconds = (double)elapsedMilliseconds / 1000; if (direction == DirectionType.Receive) { if (elapsedSeconds > receiverMaximumTime) { receiverMaximumTime = elapsedSeconds; } if (elapsedSeconds < receiverMinimumTime) { receiverMinimumTime = elapsedSeconds; } receiverTotalTime += elapsedSeconds; receiverMessageNumber += messageNumber; receiverAverageTime = receiverMessageNumber > 0 ? receiverTotalTime / receiverMessageNumber : 0; receiverMessagesPerSecond = receiverTotalTime > 0 ? receiverMessageNumber * receiverTaskCount / receiverTotalTime : 0; lblReceiverLastTime.Text = string.Format(LabelFormat, elapsedSeconds); lblReceiverLastTime.Refresh(); lblReceiverAverageTime.Text = string.Format(LabelFormat, receiverAverageTime); lblReceiverAverageTime.Refresh(); lblReceiverMaximumTime.Text = string.Format(LabelFormat, receiverMaximumTime); lblReceiverMaximumTime.Refresh(); lblReceiverMinimumTime.Text = string.Format(LabelFormat, receiverMinimumTime); lblReceiverMinimumTime.Refresh(); lblReceiverMessagesPerSecond.Text = string.Format(LabelFormat, receiverMessagesPerSecond); lblReceiverMessagesPerSecond.Refresh(); lblReceiverMessageNumber.Text = receiverMessageNumber.ToString(CultureInfo.InvariantCulture); lblReceiverMessageNumber.Refresh(); if (checkBoxReceiverEnableGraph.Checked) { chart.Series["ReceiverLatency"].Points.AddXY(receiverMessageNumber, elapsedSeconds); chart.Series["ReceiverThroughput"].Points.AddXY(receiverMessageNumber, receiverMessagesPerSecond); } } } }
public void Perform( CodeBlock block, Stack<DmlObject> stack, Dictionary<string, DmlObject> locals, DmlObject bullet, DmlSystem system) { string[] paramNames = new string[paramCount]; DmlObject[] values = new DmlObject[paramCount]; DmlObject top; List<DmlObject> param; for (int i = 0; i < paramCount; i++) { top = stack.Pop(); param = (List<DmlObject>)top.Value; paramNames[i] = (string)(param[0].Value); values[i] = param[1]; } var speed = 0d; var direction = new Vector2(0, 1); Vector2 origin; if (hasSpeed) speed = (double)(stack.Pop().Value); switch (this.direction) { case DirectionType.Direction: direction = (Vector2)(stack.Pop().Value); direction.Normalize(); break; case DirectionType.Angle: double angle = (double)(stack.Pop().Value); direction = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)); break; default: break; } if (hasOrigin) origin = (Vector2)(stack.Pop().Value); else origin = ((DmlBullet)bullet.Value).Position; var type = (DmlBulletFactory)(stack.Pop().Value); DmlObject newObj = type.Instantiate(origin, system); DmlBullet newBullet = (DmlBullet)newObj.Value; if (this.direction != DirectionType.None) newBullet.Direction = direction; if (hasSpeed) newBullet.Speed = speed; for (int i = 0; i < paramCount; i++) newObj.SetVar(paramNames[i], values[i]); if (bullet != null) // We have to check if bullet is null because Spawn is one of the few behaviours // that can be used in a Timeline. When the Timeline's code is executed, `null` // is sent in for `bullet`. ((DmlBullet)bullet.Value).Children.Add(newBullet); system.AddBullet(newBullet); }
protected virtual GWDataDBField[] GetFieldList(GWDataDBTable table, DirectionType direction) { return(GWDataDBField.GetFields(table, directionType)); }
public ChangeDirectionSignal(DirectionType type) { Direction = type; }
public MouseAxis(DirectionType direction) { Direction = direction; Name = _virtualKeyName = "Mouse Axis " + Direction.ToString(); }
// Update is called once per frame void Update() { //获取玩家的方向键 float xAxis = Input.GetAxis("Horizontal"); float yAxis = Input.GetAxis("Vertical"); Vector2 player_pos = transform.position; if (facing == DirectionType.left || facing == DirectionType.right) { //玩家上一轮是左右移动的,那么优先左右键 if (xAxis != 0) { player_pos.x += xAxis * speed * Time.deltaTime; if (xAxis > 0) { facing = DirectionType.right; } else { facing = DirectionType.left; } } else if (yAxis != 0) { player_pos.y += yAxis * speed * Time.deltaTime; if (yAxis > 0) { facing = DirectionType.down; } else { facing = DirectionType.up; } } } else { //玩家上一轮是上下移动的,那么优先上下键 if (yAxis != 0) { player_pos.y += yAxis * speed * Time.deltaTime; if (yAxis > 0) { facing = DirectionType.down; } else { facing = DirectionType.up; } } else if (xAxis != 0) { player_pos.x += xAxis * speed * Time.deltaTime; if (xAxis > 0) { facing = DirectionType.right; } else { facing = DirectionType.left; } } } transform.position = player_pos; }
private static Prediction Trade(DirectionType s, string ticker, DateTime receivedUTC, decimal TPPercent, decimal SLPercent, string comment, int longestTrade, int StrategyNr) { decimal maxMargin = 3000; decimal oneMargin = 600; decimal leverage = 10; using (var ctx = new Db()) { var open = ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= receivedUTC && x.adj_open != null); if (open == null || open.adj_open == null || open.adj_open.Value == 0) { return(null); } var currentMargin = ctx.Predictions.Where(x => x.StrategyNr == StrategyNr && x.TimeOpen <= receivedUTC && x.TimeClose >= receivedUTC).Select(x => x.Margin).DefaultIfEmpty(0).Sum(); if (currentMargin + oneMargin > maxMargin) { return(null); } var res = new Prediction { Ticker = ticker, BuySignal = s == DirectionType.Buy, Comment = $"TP:{TPPercent:00.#} SL:{SLPercent:00.#} {comment}", StrategyNr = StrategyNr, Commision = commisionsPerTrade, TimeOpen = open.date, OpenPrice = open.adj_open.Value, Volume = Math.Round(oneMargin * leverage / open.adj_open.Value), Margin = Math.Round(oneMargin * leverage / open.adj_open.Value) * open.adj_open.Value / leverage, StopLoss = open.adj_open.Value * ((100 - (SLPercent * (int)s)) / 100), TakeProfit = open.adj_open.Value * ((100 + (TPPercent * (int)s)) / 100) }; var endDate = receivedUTC.AddDays(longestTrade); var tp = s == DirectionType.Buy ? ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= open.date && x.date <= endDate && x.adj_high >= res.TakeProfit) : ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= open.date && x.date <= endDate && x.adj_low <= res.TakeProfit); var sl = s == DirectionType.Buy ? ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= open.date && x.date <= endDate && x.adj_low <= res.StopLoss) : ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= open.date && x.date <= endDate && x.adj_high >= res.StopLoss); if ((tp == null && sl != null) || (tp != null && sl != null && sl.date <= tp.date)) { res.TimeClose = sl.date; res.ClosePrice = res.StopLoss; res.Exit = ExitReason.StopLoss; res.Profit = res.Volume * (int)s * (res.ClosePrice - res.OpenPrice) - res.Commision - res.Swap; return(res); } if ((tp != null && sl == null) || (tp != null && sl != null && sl.date > tp.date)) { res.TimeClose = tp.date; res.ClosePrice = res.TakeProfit; res.Exit = ExitReason.TakeProfit; res.Profit = res.Volume * (int)s * (res.ClosePrice - res.OpenPrice) - res.Commision - res.Swap; return(res); } res.TimeClose = endDate; var cp = ctx.Prices.OrderBy(x => x.date).FirstOrDefault(x => x.ticker == ticker && x.date >= endDate && x.adj_close != null); res.ClosePrice = cp != null ? cp.adj_close.Value : res.OpenPrice; res.Exit = ExitReason.Timeout; res.Profit = res.Volume * (int)s * (res.ClosePrice - res.OpenPrice) - res.Commision - res.Swap; return(res); } }
public Move(DirectionType directionType, float speed) { Direction = directionType; Speed = speed; }
public virtual void Move(DirectionType direction) { Coordinate = Game.CalculateNewCoordinate(Coordinate, direction); }
/// <summary> /// /// </summary> /// <param name="pInstrument"></param> /// <param name="pDirection"></param> /// <param name="pOffset"></param> /// <param name="pPrice"></param> /// <param name="pVolume"></param> /// <param name="pHedge"></param> /// <returns>正确返回0</returns> public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, HedgeType pHedge = HedgeType.Speculation, OrderType pType = OrderType.Limit) { return(_proxy.ReqOrderInsert(pInstrument, pDirection, pOffset, pPrice, pVolume, pHedge, pType)); }
private void CTPOnRspQryInvestorPosition(ref CThostFtdcInvestorPositionField pInvestorPosition, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { if (!string.IsNullOrEmpty(pInvestorPosition.InstrumentID)) { // 排队交易所大额单边时所生成的非交易合约 if (this.DicInstrumentField.ContainsKey(pInvestorPosition.InstrumentID)) { var f = pInvestorPosition; _listPosi.Add(f); } } if (bIsLast) { foreach (var g in _listPosi.GroupBy(p => p.InstrumentID + "_" + p.PosiDirection)) { var id = g.First(); //整理持仓数据 HedgeType hedge = HedgeType.Speculation; switch (id.HedgeFlag) { case TThostFtdcHedgeFlagType.THOST_FTDC_HF_Speculation: hedge = HedgeType.Speculation; break; case TThostFtdcHedgeFlagType.THOST_FTDC_HF_Arbitrage: hedge = HedgeType.Arbitrage; break; case TThostFtdcHedgeFlagType.THOST_FTDC_HF_Hedge: hedge = HedgeType.Hedge; break; } DirectionType dire = DirectionType.Buy; if (g.First().PosiDirection == TThostFtdcPosiDirectionType.THOST_FTDC_PD_Short) { dire = DirectionType.Sell; } var key = id.InstrumentID + "_" + dire; var pf = DicPositionField.GetOrAdd(key, new PositionField { InstrumentID = id.InstrumentID, Direction = dire, Hedge = hedge, }); //if (pInvestorPosition.PositionDate == TThostFtdcPositionDateType.THOST_FTDC_PSD_Today) //{ // pf.TdPosition = pInvestorPosition.Position; // pf.TdCost = pf.TdPosition == 0 ? 0 : (pInvestorPosition.PositionCost /*pInvestorPosition.TodayPosition * pf.TdPosition*/); //} //if (pInvestorPosition.PositionDate == TThostFtdcPositionDateType.THOST_FTDC_PSD_History) //{ // pf.YdPosition = pInvestorPosition.Position; // pf.YdCost = pInvestorPosition.PreSettlementPrice * pf.YdPosition * DicInstrumentField[pf.InstrumentID].VolumeMultiple; // //pf.YdCost = pInvestorPosition.PositionCost / pInvestorPosition.YdPosition * pf.YdPosition; //} pf.Position = g.Sum(n => n.Position); // pf.TdPosition + pf.YdPosition; pf.TdPosition = g.Sum(n => n.TodayPosition); pf.YdPosition = pf.Position - pf.TdPosition; // g.Sum(n => n.YdPosition); // 交易合约可能不存在(如交易所合约的SP合约) if (DicInstrumentField.ContainsKey(pf.InstrumentID)) { pf.Price = pf.Position <= 0 ? 0 : (g.Sum(n => n.PositionCost) / DicInstrumentField[pf.InstrumentID].VolumeMultiple / pf.Position); } else { pf.Price = pf.Position <= 0 ? 0 : (g.Sum(n => n.PositionCost) / DicInstrumentField[pf.InstrumentID.Split('&')[1]].VolumeMultiple / pf.Position); } pf.CloseProfit = g.Sum(n => n.CloseProfit); pf.PositionProfit = g.Sum(n => n.PositionProfit); pf.Commission = g.Sum(n => n.Commission); pf.Margin = g.Sum(n => n.UseMargin); } TradingAccount.CloseProfit = _listPosi.Sum(n => n.CloseProfit); TradingAccount.PositionProfit = _listPosi.Sum(n => n.PositionProfit); TradingAccount.Commission = _listPosi.Sum(n => n.Commission); TradingAccount.Fund = TradingAccount.PreBalance + TradingAccount.CloseProfit + TradingAccount.PositionProfit - TradingAccount.Commission; TradingAccount.FrozenCash = _listPosi.Sum(n => n.FrozenCash); //由查帐户资金函数处理,原因:保证金有单边收的情况无法用持仓统计 //TradingAccount.CurrMargin = _listPosi.Sum(n => n.UseMargin); //TradingAccount.Available = TradingAccount.Fund - TradingAccount.CurrMargin - TradingAccount.FrozenCash; //TradingAccount.Risk = TradingAccount.CurrMargin / TradingAccount.Fund; _listPosi.Clear();//清除,以便得到结果是重新添加 } }
public DirectionPicker(DirectionType previousDirection, int changeDirectionModifier) { this.previousDirection = previousDirection; this.changeDirectionModifier = changeDirectionModifier; }
private void GenerateMazeDFS() { int BlockNum = 0; var PtCurrent = PtStart; var PtBlock = new DirectionType[4]; var stack = new Stack <Point>(); MzMap[PtStart.X, PtStart.Y] = Open; do { // 检测周围有没有未连通的格子 BlockNum = 0; // 检查左侧 if (PtCurrent.X > 0 && MzMap[PtCurrent.X - 1, PtCurrent.Y] == Closed) { PtBlock[BlockNum] = DirectionType.Left; BlockNum++; } // 检查右侧 if (PtCurrent.X < MapSize.Width - 1 && MzMap[PtCurrent.X + 1, PtCurrent.Y] == Closed) { PtBlock[BlockNum] = DirectionType.Right; BlockNum++; } // 检查上方 if (PtCurrent.Y > 0 && MzMap[PtCurrent.X, PtCurrent.Y - 1] == Closed) { PtBlock[BlockNum] = DirectionType.Up; BlockNum++; } // 检查下方 if (PtCurrent.Y < MapSize.Height - 1 && MzMap[PtCurrent.X, PtCurrent.Y + 1] == Closed) { PtBlock[BlockNum] = DirectionType.Down; BlockNum++; } // 选出下一个当前格 if (BlockNum > 0) { // 随机选择一个邻格 BlockNum = rand.Next(BlockNum); // 把当前格入栈 stack.Push(PtCurrent); // 连通邻格,并将邻格指定为当前格 SetDoorState(PtCurrent, PtBlock[BlockNum], Open); switch (PtBlock[BlockNum]) { case DirectionType.Left: PtCurrent.X--; break; case DirectionType.Right: PtCurrent.X++; break; case DirectionType.Up: PtCurrent.Y--; break; case DirectionType.Down: PtCurrent.Y++; break; } // 标记当前格 MzMap[PtCurrent.X, PtCurrent.Y] = Open; } else if (stack.Count > 0) { // 将栈顶作为当前格 PtCurrent = stack.Pop(); } }while (stack.Count > 0); }
public PortTool(DirectionType direction) { m_Direction = direction; }
public static Vector3 getDefaultEulerAngles(DirectionType d) { return(new Vector3(0, defaultAngle[d], 0)); }
public ShipPaintingAddon(DirectionType type) : this(type, 0, DateTime.UtcNow + TimeSpan.FromDays(7)) { }
public AroundPoint(Vector2Int point, DirectionType direction) { this.Point = point; this.Direction = direction; }
/// <summary> /// Updates the statistics and graph on the control. /// </summary> /// <param name="elapsedMilliseconds">Elapsed time.</param> /// <param name="direction">The direction of the I/O operation: Send or Receive.</param> private void UpdateStatistics(long elapsedMilliseconds, DirectionType direction) { blockingCollection.Add(new Tuple <long, DirectionType>(elapsedMilliseconds, direction)); }
public void turnLeft() { DirectionType d = DirectionUtil.getLeft(curD); Direction dir = null; int i = 0; while (dir == null && d != curD && i < 4) { dir = getAt (d); d = DirectionUtil.getLeft(d); i++; } if (dir != null) { curD = dir.direction; CameraController.instance.turnTo(this, dir.rotation); } }
public Neighbor(DirectionType direction, Tile tile) { this.direction = direction; this.tile = tile; }
/// <summary> /// /// </summary> /// <param name="pInstrument"></param> /// <param name="pDirection"></param> /// <param name="pOffset"></param> /// <param name="pPrice"></param> /// <param name="pVolume"></param> /// <param name="pHedge"></param> /// <returns>正确返回0</returns> public int ReqOrderInsert(string pInstrument, DirectionType pDirection, OffsetType pOffset, double pPrice, int pVolume, HedgeType pHedge = HedgeType.Speculation, OrderType pType = OrderType.Limit) { return _proxy.ReqOrderInsert(pInstrument, pDirection, pOffset, pPrice, pVolume, pHedge, pType); }
public double GetSumOfAlleleBaseQualites(int position, AlleleType alleleType, DirectionType directionType, int minAnchor = 0, int?maxAnchor = null, bool fromEnd = false, bool symmetric = false) { if (!IsPositionInRegion(position)) { throw new ArgumentException(string.Format("Position {0} is not in region '{1}'.", position, Name)); } var totCount = AlleleCountHelper.GetAnchorAdjustedTotalQuality(minAnchor, fromEnd, WellAnchoredIndex, NumAnchorIndexes, _sumOfAlleleBaseQualities, position - StartPosition, (int)alleleType, (int)directionType, _numAnchorTypes, maxAnchor, symmetric); return(totCount); }
private void ExecuteSwipe(DirectionType direction) { if (direction == DirectionType.Up) return; if (state == GameStateType.Pregame && !isTutorial) { state = GameStateType.Start; showTutorialButton.SetActive (false); } foreach (GameObject obj in fences) { FenceAreaHandler fence = obj.GetComponent<FenceAreaHandler>(); if (fence.fencePosition == direction) { if (fence.IsEqual (livestockManager.activeLivestock.textSOColor)) { if (!isTutorial) { BigInteger earn = CalculateGold(); CurrencyManager.shared ().AddGold (earn); Popuptext(earn.ToStringShort(), livestockManager.activeLivestock.transform.position ); inGameEarnedMoney += earn; UpdateDifficulty (Counter); timerControllerObject.AddTime (); Counter++; } else if (isTutorial) { tutorialCounter--; tutorialOkButton.SetActive(tutorialCounter <= 0); } GPGManager.Trigger1stJumpAchievement (); livestockManager.ActiveLivestockGo(direction); livestockManager.Spawn (); GetTutorialDirection(); } else { if (!isTutorial) { PlayerStatisticManager.shared().TotalBitten+=1; PlayerStatisticManager.shared().TotalJump+=counter; PlayerStatisticManager.shared().TotalGoldEarn1Game=inGameEarnedMoney; GPGManager.TriggerTotalEarnMoneyInOneAchievement(inGameEarnedMoney); GPGManager.TriggerTotalJumpInOneAchievement(Counter); GPGManager.TriggerIncrementalEatbyWolfAchievement(); GPGManager.TriggerTotalJumpAchievement(PlayerStatisticManager.shared().TotalJump); StartCoroutine (GameOver ()); } else { livestockManager.activeLivestock.FakePanic(); } } } } }
internal State(Vector2u size, StateId stateId, DirectionType direction, (Texture icon, float delay)[][] icons)
//pan from left->right private bool RenderKenBurns(float zoom, float pan, DirectionType direction) { //zoom (75%-100%) if (zoom < 75) { zoom = 75; } if (zoom > 100) { zoom = 100; } //pan 75%-125% if (pan < 75) { pan = 75; } if (pan > 125) { pan = 125; } //direction (left,right,up,down) return true; }
FocusWidget GetNextWidgetToFocus(FocusWidget widget, DirectionType direction) { switch (widget) { case FocusWidget.BackButton: switch (direction) { case DirectionType.TabForward: case DirectionType.Right: if (NextButton.Sensitive && NextButton.Visible) { return(FocusWidget.NextButton); } else if (notebook.Tabs.Count > 0) { currentFocusTab = 0; return(FocusWidget.Tabs); } else if (DropDownButton.Sensitive && DropDownButton.Visible) { return(FocusWidget.MenuButton); } else { return(FocusWidget.None); } case DirectionType.TabBackward: case DirectionType.Left: return(FocusWidget.None); } break; case FocusWidget.NextButton: switch (direction) { case DirectionType.TabForward: case DirectionType.Right: if (notebook.Tabs.Count > 0) { currentFocusTab = 0; return(FocusWidget.Tabs); } else if (DropDownButton.Sensitive && DropDownButton.Visible) { return(FocusWidget.MenuButton); } else { return(FocusWidget.None); } case DirectionType.TabBackward: case DirectionType.Left: if (PreviousButton.Sensitive && PreviousButton.Visible) { return(FocusWidget.BackButton); } else { return(FocusWidget.None); } } break; case FocusWidget.Tabs: switch (direction) { case DirectionType.TabForward: case DirectionType.Right: currentFocusCloseButton = true; return(FocusWidget.TabCloseButton); /* * if (currentFocusTab < notebook.Tabs.Count - 1) { * currentFocusTab++; * return FocusWidget.Tabs; * } else if (DropDownButton.Sensitive && DropDownButton.Visible) { * currentFocusTab = -1; * return FocusWidget.MenuButton; * } else { * return FocusWidget.None; * } */ case DirectionType.TabBackward: case DirectionType.Left: if (currentFocusTab > 0) { currentFocusTab--; currentFocusCloseButton = true; return(FocusWidget.TabCloseButton); } else if (NextButton.Sensitive && NextButton.Visible) { currentFocusTab = -1; return(FocusWidget.NextButton); } else if (PreviousButton.Sensitive && PreviousButton.Visible) { currentFocusTab = -1; return(FocusWidget.BackButton); } else { currentFocusTab = -1; return(FocusWidget.None); } } break; case FocusWidget.TabCloseButton: currentFocusCloseButton = false; switch (direction) { case DirectionType.TabForward: case DirectionType.Right: if (currentFocusTab < notebook.Tabs.Count - 1) { currentFocusTab++; return(FocusWidget.Tabs); } else if (DropDownButton.Sensitive && DropDownButton.Visible) { currentFocusTab = -1; return(FocusWidget.MenuButton); } else { return(FocusWidget.None); } case DirectionType.TabBackward: case DirectionType.Left: return(FocusWidget.Tabs); } break; case FocusWidget.MenuButton: switch (direction) { case DirectionType.TabForward: case DirectionType.Right: return(FocusWidget.None); case DirectionType.TabBackward: case DirectionType.Left: if (notebook.Tabs.Count > 0) { currentFocusTab = notebook.Tabs.Count - 1; currentFocusCloseButton = true; return(FocusWidget.TabCloseButton); } else if (NextButton.Sensitive && NextButton.Visible) { return(FocusWidget.NextButton); } else if (PreviousButton.Sensitive && PreviousButton.Visible) { return(FocusWidget.BackButton); } else { return(FocusWidget.None); } } break; case FocusWidget.None: switch (direction) { case DirectionType.TabForward: case DirectionType.Right: if (PreviousButton.Sensitive && PreviousButton.Visible) { return(FocusWidget.BackButton); } else if (NextButton.Sensitive && NextButton.Visible) { return(FocusWidget.NextButton); } else if (notebook.Tabs.Count > 0) { currentFocusTab = 0; return(FocusWidget.Tabs); } else if (DropDownButton.Sensitive && DropDownButton.Visible) { return(FocusWidget.MenuButton); } else { return(FocusWidget.None); } case DirectionType.TabBackward: case DirectionType.Left: if (DropDownButton.Sensitive && DropDownButton.Visible) { return(FocusWidget.MenuButton); } else if (notebook.Tabs.Count > 0) { currentFocusTab = notebook.Tabs.Count - 1; currentFocusCloseButton = true; return(FocusWidget.TabCloseButton); } else if (NextButton.Sensitive && NextButton.Visible) { return(FocusWidget.NextButton); } else if (PreviousButton.Sensitive && PreviousButton.Visible) { return(FocusWidget.BackButton); } else { return(FocusWidget.None); } } break; } return(FocusWidget.None); }
public void Correction(Point position, MoveStateType moveState, DirectionType direction) { _currentPosition = position; MoveState = moveState; Direction = direction; }
public DealOperation(object dealContent, DirectionType directionType, DealTransfer transfer) : this(dealContent) { direction = directionType; transferContext = transfer.Context; dealContext = transfer.MyHeader.Context; }
public void Quarantine(MqttMessage message, DirectionType direction) { quarantine.Add(message, direction); }
public override void DependentAction(DirectionType selfDirection, float rocketSpeed) { spriteOpacityChanger.SetTargetFromStart(rocketSpeed * step.value); }
protected override bool OnFocused(DirectionType direction) { return true; }
public static Quaternion getDefaultRotation(DirectionType d) { return(Quaternion.Euler(0, defaultAngle[d], 0)); }