public BarDataTypeItem(BarType barType, long barSize) : base(DataType.Bar) { this.barType = barType; this.barSize = barSize; this.key = string.Format("{0}{1}", (object) barType, (object) barSize); }
protected void CreateNewBar(BarType barType, DateTime beginTime, DateTime endTime, double price) { if (barType == BarType.Time && this.barSize == 86400) this.bar = new Daily(beginTime, price, price, price, price, 0); else this.bar = new Bar(barType, this.barSize, beginTime, endTime, price, price, price, price, 0, 0); }
protected BarFactoryItem(Instrument instrument, BarType barType, long barSize) { this.factory = null; this.instrument = instrument; this.barType = barType; this.barSize = barSize; }
protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1) : this(instrument, barType, barSize, barInput, providerId) { this.sessionEnabled = true; this.session1 = session1; this.session2 = session2; }
protected void CreateNewBar(BarType barType, DateTime beginTime, DateTime endTime, double price) { if (barType == BarType.Time && this.newBarSize == 86400) this.bar = new Bar(new FreeQuant.Data.Daily(beginTime, price, price, price, price, 0)); else this.bar = new Bar(new FreeQuant.Data.Bar(EnumConverter.Convert(barType), this.newBarSize, beginTime, endTime, price, price, price, price, 0, 0)); }
///<summary> /// Gets bar series by instrument, bar type and bar size ///</summary> public BarSeries this [Instrument instrument, BarType barType, long barSize] { get { return new BarSeries(FreeQuant.Instruments.DataManager.Bars[Map.OQ_FQ_Instrument[(object)instrument] as FreeQuant.Instruments.Instrument, EnumConverter.Convert(barType), barSize]); } }
void OnGUI() { if (!loaded) { loaded = true; Load(); } EditorGUIUtility.LookLikeControls(80f); GameObject go = NGUIEditorTools.SelectedRoot(); GUILayout.BeginHorizontal(); ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, true, GUILayout.Width(140f)); GUILayout.Label("Texture atlas used by widgets", GUILayout.MinWidth(10000f)); GUILayout.EndHorizontal(); GUILayout.Space(-2f); NGUIEditorTools.DrawSeparator(); GUILayout.BeginHorizontal(); template = (BarType)EditorGUILayout.EnumPopup("Template", template, GUILayout.Width(200f)); GUILayout.Space(20f); GUILayout.Label("Select a widget template to use"); GUILayout.EndHorizontal(); switch (template) { case BarType.Filled: CreateFilled(go); break; case BarType.Repeated: CreateRepeated(go); break; case BarType.Sequence: CreateSequence(go); break; } }
public static bool TryGetBarTypeSize(string seriesName, out BarType barType, out long barSize) { DataSeriesInfo dataSeriesInfo = DataSeriesHelper.GetDataSeriesInfo(seriesName); barType = dataSeriesInfo.BarType; barSize = dataSeriesInfo.BarSize; return dataSeriesInfo.DataType == DataType.Bar; }
public void Add(InstrumentList instruments, BarType barType, long barSize) { foreach (Instrument current in instruments) { this.Add(current, barType, barSize); } }
public static string BarTypeSizeToString(BarType barType, long barSize) { switch (barType) { case BarType.Time: if (barSize == 86400L) return "Daily"; if (barSize % 86400L == 0L) return string.Format("{0} day", barSize / 86400); if (barSize % 3600L == 0L) return string.Format("{0} hour", (object)(barSize / 3600L)); if (barSize % 60L == 0L) return string.Format("{0} min", (object)(barSize / 60L)); else return string.Format("{0} sec", (object)barSize); case BarType.Tick: return string.Format("{0} tick", (object)barSize); case BarType.Volume: return string.Format("{0} vol", (object)barSize); case BarType.Range: return string.Format("{0} range", (object)((double)barSize / 10000.0)); default: throw new ArgumentException(string.Format("Unknown bar type - {0}", barType)); } }
public static BarSeries GetHistoricalBars(Instrument instrument, DateTime begin, DateTime end, BarType barType, long barSize) { FreeQuant.Instruments.Instrument instrument1 = Map.OQ_FQ_Instrument[(object)instrument] as FreeQuant.Instruments.Instrument; if (barSize == 86400) return new BarSeries((FreeQuant.Series.BarSeries)FreeQuant.Instruments.DataManager.GetDailySeries(instrument1, begin, end)); else return new BarSeries(FreeQuant.Instruments.DataManager.GetBarSeries(instrument1, begin, end, EnumConverter.Convert(barType), barSize)); }
public BarSeries this[Instrument instrument, BarType barType, long barSize] { get { SmartQuant.Instruments.Instrument instrument2 = Map.OQ_SQ_Instrument[instrument] as SmartQuant.Instruments.Instrument; return new BarSeries(SmartQuant.Instruments.DataManager.Bars[instrument2, EnumConverter.Convert(barType), barSize]); } }
private Bar GetBarPrefab(BarType barType) { if (barType == BarType.PlainBar) return plainBarPrefab; else if (barType == BarType.ButtonBar) return buttonBarPrefab; else { Debug.LogError("invalid bar type: " + barType.ToString()); return null; } }
public void Add(string[] symbols, BarType barType, long barSize) { for (int i = 0; i < symbols.Length; i++) { string symbol = symbols[i]; this.Add(this.framework.InstrumentManager.Get(symbol), barType, barSize); } }
protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1) { this.instrument = instrument; this.barType = barType; this.barSize = barSize; this.barInput = barInput; this.providerId = providerId; }
public bool Contains(BarType barType, long barSize) { foreach (BarRequest barRequest in this.list) { if (barSize == barRequest.BarSize && barType == barRequest.BarType) return true; } return false; }
public bool Contains(BarType barType, long barSize, bool isBuiltFromTrades) { foreach (BarRequest barRequest in this.list) { if (barSize == barRequest.BarSize && barType == barRequest.BarType && isBuiltFromTrades == barRequest.IsBarFactoryRequest) return true; } return false; }
public static bool TryGetBarTypeSize(DataSeries series, out BarType barType, out long barSize) { barType = BarType.Time; barSize = 0; var parts = series.Name.Split(new[] { '.' }, StringSplitOptions.None); return parts.Length >= 3 && GetDataType(series) == DataObjectType.Bar && Enum.TryParse<BarType>(parts[parts.Length - 3], out barType) && long.TryParse(parts[parts.Length - 2], out barSize); }
public static BarSeries GetHistoricalBars(Instrument instrument, DateTime begin, DateTime end, BarType barType, long barSize) { SmartQuant.Instruments.Instrument instrument2 = Map.OQ_SQ_Instrument[instrument] as SmartQuant.Instruments.Instrument; if (barSize == 86400L) { return new BarSeries(SmartQuant.Instruments.DataManager.GetDailySeries(instrument2, begin, end)); } return new BarSeries(SmartQuant.Instruments.DataManager.GetBarSeries(instrument2, begin, end, EnumConverter.Convert(barType), barSize)); }
public bool Contains(BarType barType, long barSize) { if (!this.Enabled) return true; foreach (BarFilterItem item in this.Items) { if (item.BarType == barType && item.BarSize == barSize) return item.Enabled; } return false; }
public override DataSeries GetDataSeries(Instrument instrument, byte type, BarType barType = BarType.Time, long barSize = 60) { if (type == DataObjectType.Bar) return GetBarDataSeriesInCache(instrument, barType, barSize, false); var series = this.byType[type][instrument.Id]; if (series == null) { string name = DataSeriesNameHelper.GetName(instrument, type); series = (this.dataFile.Get(name) as DataSeries); this.byType[type][instrument.Id] = series; } return series; }
private static bool SeriesNameToBarTypeSize(string name, out BarType barType, out long barSize) { barType = BarType.Range; barSize = -1L; string[] strArray = name.Split(new char[1] { '.' }); if (strArray.Length >= 4 && strArray[strArray.Length - 3] == "Bar" && Enum.IsDefined(typeof(BarType), (object)strArray[strArray.Length - 2])) { barType = (BarType)Enum.Parse(typeof(BarType), strArray[strArray.Length - 2]); if (long.TryParse(strArray[strArray.Length - 1], out barSize)) return true; } return false; }
public void Add(Instrument instrument, BarType barType, long barSize) { BarFactoryItem item; switch (barType) { case BarType.Time: item = new TimeBarFactoryItem(instrument, barSize); break; case BarType.Tick: item = new TickBarFactoryItem(instrument, barSize); break; case BarType.Volume: item = new VolumeBarFactoryItem(instrument, barSize); break; default: throw new ArgumentException(string.Format("Unknown bar type - {0}", barType)); } this.Add(item); }
public BarSeries this [Instrument instrument, BarType barType, long barSize] { get { if (this.MSDWvxa7A1) { Hashtable hashtable = this.JqsWcXm11r(instrument, barType); BarSeries barSeries = hashtable[barSize] as BarSeries; if (barSeries == null) { barSeries = new BarSeries(string.Format("{0}-{1}-{2}", instrument.Symbol, barType, barSize)); hashtable.Add(barSize, barSeries); if (this.BarSeriesAdded != null) this.BarSeriesAdded(this, new BarSeriesEventArgs(barSeries, instrument)); } return barSeries; } else { this.barType = barType; this.barSize = barSize; Hashtable hashtable = new Hashtable(this.listByIntrument); foreach (DictionaryEntry entry in this.listByIntrument) { Instrument instrument1 = entry.Key as Instrument; BarSeries barSeries = entry.Value as BarSeries; barSeries.Name = string.Format("{0}", instrument1.Symbol, barType, barSize); this.JqsWcXm11r(instrument1, barType).Add(barSize, barSeries); } this.listByIntrument.Clear(); this.MSDWvxa7A1 = true; BarSeries barSeries1 = this[instrument, barType, barSize]; foreach (DictionaryEntry dictionaryEntry in hashtable) { if (this.BarSeriesRenamed != null) this.BarSeriesRenamed(this, new BarSeriesEventArgs(dictionaryEntry.Value as BarSeries, dictionaryEntry.Key as Instrument)); } return barSeries1; } } }
public static string Convert(byte dataType, BarType? barType = null, long? barSize = null) { switch (dataType) { case 2: return "Bid"; case 3: return "Ask"; case 4: return "Trade"; case 5: return "Quote"; case 6: if (!barType.HasValue) return "Bar"; if (!barSize.HasValue) return string.Format("Bar {0}", (object) barType.Value); return string.Format("Bar {0} {1}", (object) barType.Value, (object) barSize.Value); default: return string.Format("DataType #{0}", (object) dataType); } }
public static BarCompressor GetCompressor(BarType barType, long oldBarSize, long newBarSize) { BarCompressor barCompressor; switch (barType) { case BarType.Time: barCompressor = new TimeBarCompressor(); break; case BarType.Tick: barCompressor = new TickBarCompressor(); break; case BarType.Volume: barCompressor = new VolumeBarCompressor(); break; case BarType.Range: barCompressor = new RangeBarCompressor(); break; default: throw new ArgumentException(string.Format("Unknown bar type - {0}", barType)); } barCompressor.oldBarSize = oldBarSize; barCompressor.newBarSize = newBarSize; return barCompressor; }
public BarTypeSize(BarType barType, long barSize) { BarType = barType; BarSize = barSize; }
internal BarSeriesInfo(BarType barType, long barSize) { this.BarType = barType; this.BarSize = barSize; }
protected void EmitNewBar(Instrument instrument, BarType barType, long barSize, DateTime beginDateTime, DateTime endDateTime, double open, double high, double low, double close, long volume) { this.provider.EmitBar(instrument, barType, barSize, beginDateTime, endDateTime, open, high, low, close, volume); }
public BarRequest(BarType barType, long barSize, bool isBarFactoryRequest) { this.BarType = barType; this.BarSize = barSize; this.IsBarFactoryRequest = isBarFactoryRequest; }
public void Unselect() { selectedSide = BarType.none; selectedBox = null; }
private Bar CreateBarIfAvailable(MonoBehaviour behaviour, BarType barType, Canvas canvas) { return(behaviour ? CreateBar(behaviour.gameObject, barType, canvas) : null); }
/// <summary> /// Initializes a new instance of the <see cref="BarDataFrame"/> class. /// </summary> /// <param name="barType">The symbol bar data.</param> /// <param name="bars">The bars dictionary.</param> public BarDataFrame(BarType barType, Bar[] bars) { this.BarType = barType; this.Bars = bars; }
/// <summary> /// 下载已经结束交易的品种数据 /// 这里只下载分钟数据 /// </summary> public static void DownFinishMinTrade(BarType barType) { if (barType == BarType.Day || barType == BarType.Week) { return; } CodeInfo[] codes; using (var db = new QuantDBContext()) { codes = db.CodeInfos.Where(o => o.LastTradeDate < DateTime.Now.Date).OrderByDescending(o => o.LastTradeDate).ToArray(); } foreach (var item in codes) { using (var db = new QuantDBContext()) { try { // 先下载日K的看看效果 var dbItems = db.Bars.Where(o => o.WindCode == item.WindCode && o.BarType == barType).OrderBy(o => o.D).ToArray(); var startDate = item.IssueDate.ToString("yyyyMMdd"); var endDate = item.LastTradeDate.ToString("yyyyMMdd"); var firtItem = dbItems.FirstOrDefault(); var endItem = dbItems.LastOrDefault(); if (firtItem != null && firtItem.TradingDay.ToString() == startDate && endItem != null && endItem.TradingDay.ToString() == endDate) { Console.WriteLine($"Ignore {item.WindCode}"); } else { var startDateTime = item.IssueDate; if (endItem != null) { startDateTime = endItem.D.AddMinutes(-1); } var bars = DumpBarByWind(item.WindCode, startDateTime.ToString("yyyy-MM-dd 21:00:00"), item.LastTradeDate.ToString("yyyy-MM-dd 13:00:00"), barType); Console.WriteLine($"{item.WindCode} {startDate} - {endDate} count:{bars.Length}"); var count = 0; foreach (var newItem in bars) { if (!dbItems.Any(o => o.D == newItem.D)) { db.Add(newItem); count++; } } if (count > 0) { Console.WriteLine($"add {item.WindCode} {count}"); db.SaveChanges(); } } } catch (Exception ex) { Console.WriteLine(item.WindCode); Console.WriteLine(ex); } } } }
public BarViewModel(BarType type, double width, double height) { Type = type; Width = width; Height = height; }
public static BarSeries GetHistoricalBars(Instrument instrument, DateTime begin, DateTime end, BarType barType, long barSize) { SmartQuant.Instruments.Instrument instrument2 = Map.OQ_SQ_Instrument[instrument] as SmartQuant.Instruments.Instrument; if (barSize == 86400L) { return(new BarSeries(SmartQuant.Instruments.DataManager.GetDailySeries(instrument2, begin, end))); } return(new BarSeries(SmartQuant.Instruments.DataManager.GetBarSeries(instrument2, begin, end, EnumConverter.Convert(barType), barSize))); }
public static unsafe Bar[] DumpBarByWind(string code, string startDate, string endDate, BarType barType) { var ret = new List <Bar>(); if (barType == BarType.Day || barType == BarType.Week) { WindData wd = wind.wsd(code, "open,high,low,close,volume,settle,oi", startDate, endDate, ""); if (wd.data == null) { return(ret.ToArray()); } object[,] data = wd.getDataByFunc("wsd", false) as object[, ]; var w = wd.fieldList.Length; var l = (int)(data.Length / w); for (var i = 0; i < l; i++) { var bar = new Bar(); bar.TradingDay = int.Parse(wd.timeList[i].ToString("yyyyMMdd")); bar.D = wd.timeList[i]; bar.Settle = data[i, 5].GetDouble(); bar.O = data[i, 0].GetDouble(); bar.H = data[i, 1].GetDouble(); bar.L = data[i, 2].GetDouble(); bar.C = data[i, 3].GetDouble(); bar.V = data[i, 4].GetDouble(); bar.I = data[i, 6].GetDouble(); bar.WindCode = code; bar.BarType = barType; ret.Add(bar); } } else { var wd = wind.wsi(code, "open,high,low,close,volume,oi", startDate, endDate, $"BarSize={(int)barType}"); if (wd.data == null) { return(ret.ToArray()); } object[,] data = wd.getDataByFunc("wsi", false) as object[, ]; if (data == null) { Console.WriteLine($"{code} not find wsi {startDate} ~ {endDate}"); return(ret.ToArray()); } var w = wd.fieldList.Length; var l = (int)(data.Length / w); for (var i = 0; i < l; i++) { var bar = new Bar(); bar.TradingDay = int.Parse(wd.timeList[i].ToString("yyyyMMdd")); bar.D = wd.timeList[i]; bar.O = data[i, 0].GetDouble(); bar.H = data[i, 1].GetDouble(); bar.L = data[i, 2].GetDouble(); bar.C = data[i, 3].GetDouble(); bar.V = data[i, 4].GetDouble(); bar.I = data[i, 5].GetDouble(); bar.WindCode = code; bar.BarType = barType; ret.Add(bar); } } return(ret.ToArray()); }
public BarSeriesMenuItem(BarType barType, long barSize) { this.barType = barType; this.barSize = barSize; this.Text = DataSeriesHelper.BarTypeSizeToString(barType, barSize); }
public static void Init() { if (DataManager.initialized) return; ProviderManager.NewQuote += new QuoteEventHandler(DataManager.OnNewQuote); ProviderManager.NewTrade += new TradeEventHandler(DataManager.OnNewTrade); ProviderManager.NewBar += new BarEventHandler(DataManager.OnNewBar); ProviderManager.NewBarOpen += new BarEventHandler(DataManager.OnNewBarOpen); ProviderManager.NewMarketDepth += new MarketDepthEventHandler(DataManager.OnNewMarketDepth); ProviderManager.NewFundamental += new FundamentalEventHandler(DataManager.OnNewFundamental); ProviderManager.NewCorporateAction += new CorporateActionEventHandler(DataManager.OnNewCorporateAction); ProviderManager.MarketDataRequestReject += new MarketDataRequestRejectEventHandler(DataManager.OnMarketDataRequestReject); ProviderManager.Connected += new ProviderEventHandler(DataManager.a9pwYGI8t); DataManager.barArrayLength = -1; DataManager.tradeArrayLength = -1; DataManager.quoteArrayLength = -1; DataManager.fundamentalArrayLength = -1; DataManager.corporateActionArrayLength = -1; DataManager.defaultBarType = BarType.Time; // DataManager.TrxWldYDwK = BarType.Time; DataManager.defaultBarSize = 60; // DataManager.AK2WYmbanY DataManager.Load(); DataManager.initialized = true; }
public BarRequest(BarType type, long size) : base(RequestType.Bar) { this.BarType = type; this.BarSize = size; this.isBarFactoryRequest = true; }
public void InitBarSettings(BarType barType, long barSize) { this.barType = barType; this.barSize = barSize; }
private static void UpdatePrefabOverrideOrLivePropertyBarStyleEvent(GeometryChangedEvent evt, BarType barType) { var container = evt.target as InspectorElement; if (container == null) { return; } var barContainer = barType switch { BarType.PrefabOverride => container.Q(BindingExtensions.prefabOverrideBarContainerName), BarType.LiveProperty => container.Q(BindingExtensions.livePropertyBarContainerName), _ => throw new ArgumentOutOfRangeException(nameof(barType), barType, null) }; if (barContainer == null) { return; } for (var i = 0; i < barContainer.childCount; i++) { UpdatePrefabOverrideOrLivePropertyBarStyle(barContainer[i]); } }
public void Add(BarType barType, long size, DateTime beginTime, DateTime endTime, double open, double high, double low, double close, long volume, long openInt) { this.series.Add(new SmartQuant.Data.Bar(EnumConverter.Convert(barType), size, beginTime, endTime, open, high, low, close, volume, openInt)); }
public static void MakeBars(IDataSeries tradeSeries, IDataSeries barSeries, BarType barType, long barSize) { switch (barType) { case BarType.Time: Bar bar1 = (Bar)null; foreach (Trade trade in tradeSeries) { if (bar1 == null || bar1.EndTime <= trade.DateTime) { if (bar1 != null) { barSeries.Add(bar1.DateTime, bar1); } DateTime beginTime = BarMaker.qtghhEheM(trade.DateTime, barSize); bar1 = new Bar(BarType.Time, barSize, beginTime, beginTime.AddSeconds((double)barSize), trade.Price, trade.Price, trade.Price, trade.Price, (long)trade.Size, 0L); } else { if (trade.Price > bar1.High) { bar1.High = trade.Price; } if (trade.Price < bar1.Low) { bar1.Low = trade.Price; } bar1.Close = trade.Price; bar1.Volume += (long)trade.Size; } } if (bar1 != null) { barSeries.Add(bar1.DateTime, bar1); } barSeries.Flush(); break; case BarType.Tick: Bar bar2 = (Bar)null; int num = 0; foreach (Trade trade in tradeSeries) { if (bar2 == null) { bar2 = new Bar(BarType.Tick, barSize, trade.DateTime, trade.DateTime, trade.Price, trade.Price, trade.Price, trade.Price, (long)trade.Size, 0L); num = 1; } else { bar2.EndTime = trade.DateTime; if (trade.Price > bar2.High) { bar2.High = trade.Price; } if (trade.Price < bar2.Low) { bar2.Low = trade.Price; } bar2.Close = trade.Price; bar2.Volume += (long)trade.Size; ++num; } if ((long)num == barSize) { barSeries.Add(bar2.DateTime, bar2); bar2 = (Bar)null; } } if (bar2 != null) { barSeries.Add(bar2.DateTime, bar2); } barSeries.Flush(); break; case BarType.Volume: Bar bar3 = (Bar)null; foreach (Trade trade in tradeSeries) { if (bar3 == null) { bar3 = new Bar(BarType.Volume, barSize, trade.DateTime, trade.DateTime, trade.Price, trade.Price, trade.Price, trade.Price, (long)trade.Size, 0L); } else { bar3.EndTime = trade.DateTime; if (trade.Price > bar3.High) { bar3.High = trade.Price; } if (trade.Price < bar3.Low) { bar3.Low = trade.Price; } bar3.Close = trade.Price; bar3.Volume += (long)trade.Size; } if (bar3.Volume >= barSize) { barSeries.Add(bar3.DateTime, bar3); bar3 = (Bar)null; } } if (bar3 != null) { barSeries.Add(bar3.DateTime, bar3); } barSeries.Flush(); break; case BarType.Range: Bar bar4 = (Bar)null; foreach (Trade trade in tradeSeries) { DateTime dateTime = trade.DateTime; double price = trade.Price; long volume = (long)trade.Size; if (bar4 == null) { bar4 = new Bar(BarType.Range, barSize, dateTime, dateTime, price, price, price, price, volume, 0L); } else { bar4.EndTime = dateTime; if (price > bar4.High) { bar4.High = price; } if (price < bar4.Low) { bar4.Low = price; } bar4.Volume += volume; bool flag = false; while (!flag) { if (10000.0 * (bar4.High - bar4.Low) >= (double)barSize) { Bar bar5 = new Bar(BarType.Range, barSize, dateTime, dateTime, price, price, price, price, 0L, 0L); if (bar4.High == price) { bar4.High = bar4.Low + barSize / 10000.0; bar4.Close = bar4.High; bar5.Low = bar4.High; } if (bar4.Low == price) { bar4.Low = bar4.High - barSize / 10000.0; bar4.Close = bar4.Low; bar5.High = bar4.Low; } barSeries.Add(bar4.DateTime, bar4); bar4 = bar5; flag = 10000.0 * (bar5.High - bar5.Low) < (double)barSize; } else { flag = true; } } } } if (bar4 != null) { barSeries.Add(bar4.DateTime, bar4); } barSeries.Flush(); break; default: throw new NotImplementedException("BarType Invalid: " + barType); } }
private Bar CreateBar(GameObject originalBar, BarType type, Canvas canvas) { GameObject cloned = Instantiate(originalBar); cloned.transform.SetParent(canvas.transform); cloned.transform.localScale = new Vector3(0.0007f, 0.0007f, 0.0007f); cloned.transform.rotation = canvas.transform.rotation; uGUI_CircularBar newBar = cloned.GetComponentInChildren <uGUI_CircularBar>(); newBar.texture = originalBar.GetComponentInChildren <uGUI_CircularBar>().texture; newBar.overlay = originalBar.GetComponentInChildren <uGUI_CircularBar>().overlay; string valueUnit = "%"; switch (type) { case BarType.HEALTH: newBar.color = HEALTH_BAR_COLOR; newBar.borderColor = HEALTH_BAR_BORDER_COLOR; cloned.transform.localPosition = new Vector3(-0.075f, 0.35f, 0f); cloned.name = playerName + "'s Health"; cloned.RequireTransform("Icon").localRotation = Quaternion.Euler(0f, 0f, 0f); Destroy(cloned.GetComponent <uGUI_HealthBar>()); cloned.transform.localScale = new Vector3(0.0007f, 0.0007f, 0.0007f); break; case BarType.OXYGEN: newBar.color = OXYGEN_BAR_COLOR; newBar.borderColor = OXYGEN_BAR_BORDER_COLOR; cloned.transform.localPosition = new Vector3(-0.025f, 0.35f, 0f); valueUnit = "s"; cloned.name = playerName + "'s Oxygen"; cloned.RequireTransform("OxygenTextLabel").localRotation = Quaternion.Euler(0f, 270f, 0f); Destroy(cloned.GetComponent <uGUI_OxygenBar>()); cloned.transform.localScale = new Vector3(0.0003f, 0.0003f, 0.0003f); break; case BarType.FOOD: newBar.color = FOOD_BAR_COLOR; newBar.borderColor = FOOD_BAR_BORDER_COLOR; cloned.transform.localPosition = new Vector3(0.025f, 0.35f, 0f); cloned.name = playerName + "'s Food"; cloned.RequireTransform("Icon").localRotation = Quaternion.Euler(0f, 0f, 0f); Destroy(cloned.GetComponent <uGUI_FoodBar>()); cloned.transform.localScale = new Vector3(0.0007f, 0.0007f, 0.0007f); break; case BarType.WATER: newBar.color = WATER_BAR_COLOR; newBar.borderColor = WATER_BAR_BORDER_COLOR; cloned.transform.localPosition = new Vector3(0.075f, 0.35f, 0f); cloned.name = playerName + "'s Water"; cloned.RequireTransform("Icon").localRotation = Quaternion.Euler(0f, 0f, 0f); Destroy(cloned.GetComponent <uGUI_WaterBar>()); cloned.transform.localScale = new Vector3(0.0007f, 0.0007f, 0.0007f); break; default: Log.Info("Unhandled bar type: " + type); break; } return(new Bar(newBar.gameObject, new SmoothedValue(100, 100, 100, 100), valueUnit)); }
int[] VarianceByBar(BarType barType, int currentNote, int totalNotes) { int[] variance = new int[2]; switch (barType) { case BarType.Start: if (currentNote == 0) { variance[0] = 0; variance[1] = 0; } else if (currentNote >= totalNotes / 4) { variance[0] = -1; variance[1] = 1; } break; case BarType.End: if (currentNote == 0) { variance[0] = -1; variance[1] = 1; } else if (currentNote == totalNotes - 1) { variance[0] = 0; variance[1] = 0; } break; case BarType.Fall: variance[0] = -2; variance[1] = 0; break; case BarType.Rise: variance[0] = 0; variance[1] = 2; break; case BarType.EarlyPeak: if (currentNote < totalNotes / 3.0f) { variance[0] = 1; variance[1] = 3; } else { variance[0] = -2; variance[1] = 0; } break; case BarType.Peak: if (currentNote < totalNotes / 2.0f) { variance[0] = 0; variance[1] = 2; } else { variance[0] = -2; variance[1] = 0; } break; case BarType.LatePeak: if (currentNote < (totalNotes * 2.0f) / 3.0f) { variance[0] = 0; variance[1] = 2; } else { variance[0] = -3; variance[1] = -1; } break; case BarType.EarlyTrough: if (currentNote < totalNotes / 3.0f) { variance[0] = -3; variance[1] = -1; } else { variance[0] = 0; variance[1] = 2; } break; case BarType.Trough: if (currentNote < totalNotes / 2.0f) { variance[0] = -2; variance[1] = 0; } else { variance[0] = 0; variance[1] = 2; } break; case BarType.LateTrough: if (currentNote < (totalNotes * 2.0f) / 3.0f) { variance[0] = -2; variance[1] = 0; } else { variance[0] = 1; variance[1] = 3; } break; default: variance[0] = -1; variance[1] = 1; break; } return(variance); }
public BarChartItemInfoContainer(BarType type, ChartViewModelBase viewModel) { this.BarType = type; this.ChartModel = viewModel; }
public static Bar Bar(BarType type) { string typeCode = type.GetCode(); return(new Bar(typeCode, "g")); }
protected A(BarType foo) { _foo = foo; }
protected void CreateNewBar(BarType barType, DateTime beginTime, DateTime endTime, double price) { bar = new Bar(beginTime, endTime, instrumentId, barType, newBarSize, price, price, price, price, 0L, 0L); }
public static BarSeries GetHistoricalBars(Instrument instrument, BarType barType, long barSize) { return(DataManager.GetHistoricalBars(instrument, DateTime.MinValue, DateTime.MaxValue, barType, barSize)); }
public static GameObject NewScrollView(Vector2 size = default(Vector2), BarType barType = BarType.None, ContentType contentType = ContentType.VerticalLayout, Vector2 spacing = default(Vector2), Vector2 gridSize = default(Vector2)) { //创建ScrollRect GameObject go1 = new GameObject("ScrollView", new System.Type[] { typeof(RectTransform), typeof(ScrollRect) }); go1.layer = 0; RectTransform tf1 = go1.GetComponent <RectTransform>(); tf1.anchoredPosition = new Vector2(0, 0); tf1.sizeDelta = size == default(Vector2) ? new Vector2(100, 100) : size; ScrollRect scrollRect = go1.GetComponent <ScrollRect>(); scrollRect.horizontal = false; //创建Viewport GameObject go2 = new GameObject("Viewport", new System.Type[] { typeof(RectTransform), typeof(Mask), typeof(Image) }); go2.layer = 0; RectTransform tf2 = go2.GetComponent <RectTransform>(); tf2.SetParent(tf1, false); tf2.anchorMin = new Vector2(0, 0); tf2.anchorMax = new Vector2(1, 1); tf2.anchoredPosition = new Vector2(0, 0); tf2.sizeDelta = new Vector2(-17, -17); tf2.pivot = new Vector2(0, 1); Image image2 = go2.GetComponent <Image>(); image2.color = new Color(0.5568628f, 0.5568628f, 0.5568628f); Mask mask = go2.GetComponent <Mask>(); mask.showMaskGraphic = false; //创建Content GameObject go3 = new GameObject("Content", new System.Type[] { typeof(RectTransform), typeof(ContentSizeFitter) }); go3.layer = 0; RectTransform tf3 = go3.GetComponent <RectTransform>(); tf3.SetParent(tf2, false); tf3.anchorMin = new Vector2(0, 1); tf3.anchorMax = new Vector2(1, 1); tf3.anchoredPosition = new Vector2(0, 0); tf3.sizeDelta = new Vector2(0, 0); tf3.pivot = new Vector2(0.5f, 1); ContentSizeFitter contentSizeFitter = tf3.GetComponent <ContentSizeFitter>(); contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; switch (contentType) { case ContentType.Grid: GridLayoutGroup gridLayoutGroup = go3.AddComponent <GridLayoutGroup>(); gridLayoutGroup.cellSize = gridSize == default(Vector2) ? new Vector2(100, 100) : gridSize; gridLayoutGroup.spacing = spacing; break; case ContentType.VerticalLayout: VerticalLayoutGroup verticalLayoutGroup = go3.AddComponent <VerticalLayoutGroup>(); verticalLayoutGroup.spacing = spacing.y; verticalLayoutGroup.childControlHeight = false; verticalLayoutGroup.childControlWidth = false; verticalLayoutGroup.childForceExpandHeight = false; verticalLayoutGroup.childForceExpandWidth = false; verticalLayoutGroup.childAlignment = TextAnchor.UpperCenter; break; default: break; } //关联控件 scrollRect.viewport = tf2; scrollRect.content = tf3; switch (barType) { case BarType.Vertical: GameObject go4 = new GameObject("ScrollbarVertical", new System.Type[] { typeof(RectTransform), typeof(Image), typeof(Scrollbar) }); go4.layer = 0; RectTransform tf4 = go4.GetComponent <RectTransform>(); tf4.SetParent(tf1, false); tf4.anchorMin = new Vector2(1, 0); tf4.anchorMax = new Vector2(1, 1); tf4.anchoredPosition = new Vector2(0, 0); tf4.sizeDelta = new Vector2(20, 0); tf4.pivot = new Vector2(1, 1); Image image4 = go4.GetComponent <Image>(); image4.sprite = default(Sprite); image4.color = new Color(0.9490196f, 0.509803951f, 0.503921571f); Scrollbar scrollbar = go4.GetComponent <Scrollbar>(); scrollbar.direction = Scrollbar.Direction.BottomToTop; GameObject go5 = new GameObject("SlidingArea", new System.Type[] { typeof(RectTransform) }); go5.layer = 0; RectTransform tf5 = go5.GetComponent <RectTransform>(); tf5.SetParent(tf4, false); tf5.anchorMin = new Vector2(0, 0); tf5.anchorMax = new Vector2(1, 1); tf5.anchoredPosition = new Vector2(0, 0); tf5.sizeDelta = new Vector2(-20, -20); tf5.pivot = new Vector2(0.5f, 0.5f); GameObject go6 = new GameObject("Handle", new System.Type[] { typeof(RectTransform), typeof(Image) }); go6.layer = 0; RectTransform tf6 = go6.GetComponent <RectTransform>(); tf6.SetParent(tf5, false); tf6.anchorMin = new Vector2(0, 0.5f); tf6.anchorMax = new Vector2(1, 1); tf6.anchoredPosition = new Vector2(0, 0); tf6.sizeDelta = new Vector2(20, 20); tf6.pivot = new Vector2(0.5f, 0.5f); Image image6 = go6.GetComponent <Image>(); image6.sprite = default(Sprite); image6.color = new Color(0.9490196f, 0.509803951f, 0.503921571f); scrollbar.targetGraphic = image6; scrollbar.handleRect = tf6; scrollRect.verticalScrollbar = scrollbar; scrollRect.verticalScrollbarVisibility = ScrollRect.ScrollbarVisibility.AutoHideAndExpandViewport; scrollRect.verticalScrollbarSpacing = -3; break; default: break; } return(go1); }
private void SetBar(BarType barType, GameObject ExtraBar) { Image bar = ExtraBar.transform.GetChild(0).GetChild(0).GetComponent<Image>(); Image frame = ExtraBar.transform.GetChild(0).GetChild(1).GetComponent<Image>(); Text name = ExtraBar.transform.GetChild(1).GetComponent<Text>(); Text value = ExtraBar.transform.GetChild(2).GetComponent<Text>(); int max = 1; int cur = 1; switch (barType) { case BarType.HP: name.text = "HP:"; max = fighter.Health; cur = fighter.Health / 2; bar.color = Color.red; break; case BarType.Mana: max = fighter.Points; cur = fighter.Points / 2; name.text = "Mana:"; bar.color = Color.blue; break; case BarType.Stamina: max = fighter.Points; cur = fighter.Points / 2; name.text = "Stmn:"; bar.color = new Color(255,195,0); break; default: break; } value.text = string.Format("{0}/{1}",cur, max); if (max > 0) { float percent = (float)cur / (float)max; Vector2 rt = frame.rectTransform.sizeDelta; rt.x = rt.x * percent; bar.rectTransform.sizeDelta = rt; } }
public static BarSeries CompressBars(TradeSeries trades, BarType barType, long barSize) { return(DataManager.CompressBars(new TradeDataEnumerator(trades), barType, 1L, barSize)); }
public BarSeries CompressBars(BarType barType, long barSize) { return DataManager.CompressBars(this, barType, barSize); }
private static BarSeries CompressBars(DataEntryEnumerator enumerator, BarType barType, long oldBarSize, long newBarSize) { BarCompressor compressor = BarCompressor.GetCompressor(barType, oldBarSize, newBarSize); return(compressor.Compress(enumerator)); }
private Bar ssgZj9bjo(BarType obj0, long obj1, DateTime obj2, DateTime obj3, double obj4) { return(new Bar(obj0, obj1, obj2, obj3, obj4, obj4, obj4, obj4, 0, 0)); }
public Bars AddBars(ILArray <double> barStart, ILArray <double> barEnd, ILArray <double> barPosition, ILArray <double> barThickness, BarType barType) { int n = barStart.Dimensions[0]; if (barThickness.IsScalar) { barThickness = ILMath.ones(n) * barThickness; } Bars bars = new Bars(this, barStart, barEnd, barPosition, barThickness, barType); barsList.Add(bars); foreach (Path rectangle in bars.Paths) { canvas.Children.Add(rectangle); IBoundableFromChild.Add((object)(rectangle), bars); } if (graphToCanvas.Matrix.M11 != 0) { ViewedRegion = GetCanvasChildrenBounds(); } else { ViewedRegion = bars.Bounds; } return(bars); }
public static BarSeries GetBarSeries(Instrument instrument, DateTime datetime1, DateTime datetime2, BarType barType, long barSize) { string suffix = string.Format("{0}{1}{2}{3}{4}", SUFFIX_BAR, SERIES_SEPARATOR, barType, SERIES_SEPARATOR, barSize); return DataManager.GetBarSeries(instrument, suffix, datetime1, datetime2); }
///<summary> /// Sets a bar size and type to filter bars ///</summary> public void SetBarFilter(long barSize, BarType barType) { ((StopBase)this.stop).SetBarFilter(barSize, EnumConverter.Convert(barType)); }