public static bool IsPastRegularTradingHours(this DateTime datetime, InstrumentType insType) { if (insType != InstrumentType.Stock) throw new NotImplementedException("Not implemented for anything other than stocks"); return datetime.TimeOfDay.TotalSeconds > PstSessionTimeConstants.StockExchangeEndTimeSeconds; }
public static bool IsWithinRegularTradingHours(this Quote quote, InstrumentType insType) { if (insType != InstrumentType.Stock) throw new NotImplementedException("Not implemented for anything other than stocks"); return quote.DateTime.IsWithinRegularTradingHours(insType); }
public TTSettlesSubscriber(KafkaClient awsKafkaClient, KafkaClient njKafkaClient, WorkerDispatcher dispatcher, InstrumentType instrumentType) { this._awsKafkaClient = awsKafkaClient; this._njKafkaClient = njKafkaClient; this._dispatcher = dispatcher; this._instrumentType = instrumentType; }
public IInstrument Create(InstrumentType instrumentType) { var renderer = _rendererFactory.CreateRenderer(instrumentType); var instrument = new Instrument(instrumentType, renderer, _instrumentStateSnapshotCache, _performanceCounterInstanceFactory); return(instrument); }
public BjerksundAndStensland2002Calculator(OptionType optionType, double strike, double spotPrice, double maturityInYears, double standardDeviation, double riskFreeRate, double dividendRate, double notional, InstrumentType underlyingInstrumentType, double riskfreeDfAtExercise, double riskfreeDfAtMaturity, double expiryDayRemainingLife = double.NaN, double timeIncrement = 0.0) { _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType); _optionType = optionType; _X = strike; _S = spotPrice; _T = maturityInYears + timeIncrement; if (!double.IsNaN(expiryDayRemainingLife)) { _T = expiryDayRemainingLife; } _sigma = standardDeviation; _r = riskFreeRate; _dividend = dividendRate; _b = riskFreeRate - dividendRate; _notional = notional; _riskfreeDfAtExercise = riskfreeDfAtExercise; _riskfreeDfAtMaturity = riskfreeDfAtMaturity; _expiryDayRemainingLife = expiryDayRemainingLife; }
public void executeChangeInstrumentInfoFromProp(NodeClick click, InstrumentType type, int string_num) { selections.Instrument = type; selections.StringNum = string_num; executeCommandBase(click, CommandType.ChangeInstrumentInfo, UpdateType.RedrawPart, false, false); }
public static bool HasOrderExecuted( IBroker broker, string stockCode, int quantity, double price, OrderPriceType orderType, OrderDirection orderDirection, InstrumentType instrumentType, DateTime expiryDate, out string orderReferenceNumber) { orderReferenceNumber = null; string contract = String.Empty; string strExpDate = expiryDate.ToString("dd-MMM-yyyy"); if (instrumentType == InstrumentType.FutureIndex || instrumentType == InstrumentType.FutureStock) { contract += "FUT-"; } else { throw new NotSupportedException(); } contract += (stockCode + "-" + strExpDate); // this loop is there just for potential retry purpose for (int count = 1; count <= 2; count++) { Dictionary <string, DerivativeTradeBookRecord> trades; BrokerErrorCode errorCode = broker.GetDerivativesTradeBook(DateTime.Now, DateTime.Now, instrumentType, true, out trades); if (!errorCode.Equals(BrokerErrorCode.Success)) { return(false); } foreach (DerivativeTradeBookRecord singleTrade in trades.Values) { if (singleTrade.ContractName.ToUpperInvariant() != contract.ToUpperInvariant()) { continue; } if (singleTrade.Quantity != quantity) { continue; } if (singleTrade.Direction != orderDirection) { continue; } orderReferenceNumber = singleTrade.OrderRefenceNumber; return(true); } } return(false); }
SignOn(InstrumentType instrument, string accessCode = DefaultAccessCode) { var code = (int)instrument < 10 ? string.Concat("0", (int)instrument) : instrument.ToString(); var cmd = $"SN,{accessCode}{ControlCharacters.STX}vq{code}"; return(new MiCommandDefinition <StatusResponseMessage>(cmd, ResponseProcessors.ResponseCode)); }
public double GetTradeExecutionPrice(DateTime fromDate, DateTime toDate, InstrumentType instrumentType, string orderRefString) { double executionPrice = -1; BrokerErrorCode errorCode = BrokerErrorCode.Success; if (instrumentType.Equals(InstrumentType.Share)) { errorCode = RefreshEquityTradeBook(this, fromDate, toDate, false); if (!errorCode.Equals(BrokerErrorCode.Success)) { return(executionPrice); } lock (lockObjectEquity) { if (mEquityTradeBook.ContainsKey(orderRefString)) { executionPrice = mEquityTradeBook[orderRefString].Price; } } } return(executionPrice); }
public ResetStrikeOption(Date startDate, Date maturityDate, OptionExercise exercise, OptionType optionType, ResetStrikeType resetStrikeType, double strike, InstrumentType underlyingInstrumentType, ICalendar calendar, IDayCount dayCount, CurrencyCode payoffCcy, CurrencyCode settlementCcy, Date[] exerciseDates, Date[] observationDates, Date strikefixingDate, double notional = 1, DayGap settlementGap = null, Date optionPremiumPaymentDate = null, double optionPremium = 0) : base(startDate: startDate, maturityDate: maturityDate, exercise: exercise, optionType: optionType, strike: new double[] { strike }, underlyingInstrumentType: underlyingInstrumentType, calendar: calendar, dayCount: dayCount, settlementCcy: settlementCcy, payoffCcy: payoffCcy, exerciseDates: exerciseDates, observationDates: observationDates, notional: notional, settlementGap: settlementGap, optionPremiumPaymentDate: optionPremiumPaymentDate, optionPremium: optionPremium) { ResetStrikeType = resetStrikeType; StrikeFixingDate = strikefixingDate; }
public StockLayOut(StockInfo _stock) { InitializeComponent(); stock = _stock; it = InstrumentType.Stock; }
public void Play(InstrumentType instrument, MetronomeMark metronomeMark, ChordOffset[] melody) { PrepareChordsOctave(instrument, melody[0].Chord); var stopwatch = new Stopwatch(); stopwatch.Start(); for (var strumIndex = 0; strumIndex < melody.Length;) { var strum = melody[strumIndex]; if (stopwatch.ElapsedMilliseconds > metronomeMark.WholeNoteLength.Multiply(strum.Offest).TotalMilliseconds) { var chord = strum.Chord; PlayChord(instrument, chord); if (strumIndex < melody.Length - 1) { PrepareChordsOctave(instrument, melody[strumIndex + 1].Chord); } strumIndex++; } else { Thread.Sleep(TimeSpan.FromMilliseconds(1)); } } stopwatch.Stop(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="startDate">开始日期</param> /// <param name="maturityDate">到期日</param> /// <param name="exercise">行权方式</param> /// <param name="optionType">看涨看跌</param> /// <param name="strike">行权价</param> /// <param name="underlyingInstrumentType">标的资产类型</param> /// <param name="calendar">交易日历</param> /// <param name="dayCount">日期规则</param> /// <param name="payoffCcy">收益计算币种</param> /// <param name="settlementCcy">结算币种</param> /// <param name="exerciseDates">行权日</param> /// <param name="observationDates">观察日</param> /// <param name="notional">名义本金</param> /// <param name="settlementGap">结算日规则</param> /// <param name="optionPremiumPaymentDate">权利金支付日</param> /// <param name="optionPremium">权利金</param> /// <param name="isMoneynessOption">是否为相对行权价期权</param> /// <param name="initialSpotPrice">标的资产期初价格</param> /// <param name="dividends">标的资产分红</param> /// <param name="hasNightMarket">标的资产是否有夜盘交易</param> /// <param name="commodityFuturesPreciseTimeMode">是否启用精确时间计算模式</param> public VanillaOption(Date startDate, Date maturityDate, //underlying maturity, for option on forward OptionExercise exercise, OptionType optionType, double strike, InstrumentType underlyingInstrumentType, ICalendar calendar, IDayCount dayCount, CurrencyCode payoffCcy, CurrencyCode settlementCcy, Date[] exerciseDates, Date[] observationDates, double notional = 1, DayGap settlementGap = null, Date optionPremiumPaymentDate = null, double optionPremium = 0.0, bool isMoneynessOption = false, double initialSpotPrice = 0.0, Dictionary <Date, double> dividends = null, bool hasNightMarket = false, bool commodityFuturesPreciseTimeMode = false ) : base(startDate, maturityDate, exercise, optionType, new double[] { strike }, underlyingInstrumentType, calendar, dayCount, payoffCcy, settlementCcy, exerciseDates, observationDates, notional, settlementGap, optionPremiumPaymentDate, optionPremium, isMoneynessOption: isMoneynessOption, initialSpotPrice: initialSpotPrice, dividends: dividends, hasNightMarket: hasNightMarket, commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode) { if (Exercise == OptionExercise.European && exerciseDates.Length != 1) { throw new PricingLibraryException("Vanilla European option can have only 1 observation date"); } }
public LookbackOption(Date startDate, Date maturityDate, OptionExercise exercise, OptionType optionType, StrikeStyle strikeStyle, double strike, InstrumentType underlyingInstrumentType, ICalendar calendar, IDayCount dayCount, CurrencyCode payoffCcy, CurrencyCode settlementCcy, Date[] exerciseDates, Date[] observationDates, Dictionary <Date, double> fixings, double notional = 1, DayGap settlementGap = null, Date optionPremiumPaymentDate = null, double optionPremium = 0, bool isMoneynessOption = false, double initialSpotPrice = 0.0, Dictionary <Date, double> dividends = null, bool hasNightMarket = false, bool commodityFuturesPreciseTimeMode = false ) : base(startDate, maturityDate, exercise, optionType, new double[] { strike }, underlyingInstrumentType, calendar, dayCount, settlementCcy, payoffCcy, exerciseDates, observationDates, notional, settlementGap, optionPremiumPaymentDate, optionPremium, isMoneynessOption: isMoneynessOption, initialSpotPrice: initialSpotPrice, dividends: dividends, hasNightMarket: hasNightMarket, commodityFuturesPreciseTimeMode: commodityFuturesPreciseTimeMode) { Fixings = fixings; StrikeStyle = strikeStyle; }
public Instrument(string name, InstrumentType type, Color color, AudioClip clip) { this.name = name; this.type = type; this.color = color; this.clip = clip; }
public LookbackOptionCalculator( OptionType optionType, InstrumentType underlyingProductType, StrikeStyle strikeStyle, double strike, double spotPrice, double exerciseInYears, double realizedMaxPrice, double realizedMinPrice, double sigma, double riskFreeRate, double dividendRate, double notional) { _optionType = optionType; _strikeStyle = strikeStyle; _X = strike; _S = spotPrice; _Smin = realizedMinPrice; _Smax = realizedMaxPrice; _T = exerciseInYears; _sigma = sigma; _r = riskFreeRate; _dividendRate = dividendRate; if (FuturesProducts.Contains(underlyingProductType)) { _b = 0.0; } else { _b = riskFreeRate - dividendRate; } _notional = notional; }
public static string GetInstrumentDescriptionString(InstrumentType instrumentType, string symbol, DateTime expiryDate, double strikePrice) { string instrumentDescription = string.Empty; if (instrumentType == InstrumentType.Share) { instrumentDescription += "SHARE"; return(instrumentDescription); } string instrumentCode = GetInstrumentTypeString(instrumentType); string expiryDateString = expiryDate.ToString("dd-MMM-yyyy"); instrumentDescription += instrumentCode + "-" + symbol + "-" + expiryDateString; if (IsInstrumentOptionType(instrumentType)) { string instrumentDirection = GetFnOInstrumentDirectionString(instrumentType); instrumentDescription += "-" + strikePrice.ToString() + "-" + instrumentDirection; } return(instrumentDescription); }
internal Instrument(IOrchestra orchestra, InstrumentType instrumentType, Scale scale, int octave = 0) { Scale = scale; Octave = octave; _orchestra = orchestra; InstrumentType = instrumentType; }
void OnHighlightOn(InstrumentType instrumentType) { sectionLabel.text = instrumentType.ToString("F"); sectionLabel.gameObject.SetActive(true); blackOverlay.gameObject.SetActive(true); EnableButtonCollider(false); }
public Instrument(InstrumentType type, string symbol, string description = "", byte currencyId = 148 /* USD */) { Type = type; Symbol = symbol; Description = description; CurrencyId = currencyId; }
public static string toString(InstrumentType type) { switch (type) { case InstrumentType.GUITAR: return("Guitar"); case InstrumentType.BANJO: return("Banjo"); case InstrumentType.DOBRO: return("Dobro"); case InstrumentType.FIDDLE: return("Fiddle"); case InstrumentType.BASS: return("Bass"); case InstrumentType.MANDOLIN: return("Mandolin"); default: return("Unspecified"); } }
/// <summary> /// Starts play effect. /// </summary> /// <param name="creature"></param> /// <param name="instrumentType"></param> /// <param name="quality"></param> /// <param name="compressedMml"></param> /// <param name="scoreId"></param> private void StartPlay(Creature creature, Skill skill, InstrumentType instrumentType, int quality, string compressedMml, int scoreId) { // [200200, NA242 (2016-12-15)] // The playing effect for instruments was turned into a prop, // presumably to have something to reference in the world // for jams, and to make it more than a temp effect. //Send.PlayEffect(creature, instrumentType, quality, mml, rndScore); var regionId = creature.RegionId; var pos = creature.GetPosition(); var prop = new PlayingInstrumentProp(regionId, pos.X, pos.Y); prop.CompressedMML = compressedMml; prop.ScoreId = scoreId; prop.Quality = quality; prop.Instrument = instrumentType; prop.StartTime = DateTime.Now; prop.CreatureEntityId = creature.EntityId; creature.Region.AddProp(prop); creature.Temp.PlayingInstrumentProp = prop; }
public string InstrumentTypeToString(InstrumentType i) { switch (i) { case InstrumentType.BANJO: return("Banjo"); case InstrumentType.BASS: return("Bass"); case InstrumentType.DOBRA: return("Dobra"); case InstrumentType.FIDDLE: return("Fiddle"); case InstrumentType.GUITAR: return("guitar"); case InstrumentType.MANDOLIN: return("Mandolin"); default: return("wrong choice"); } }
public OneTouchCalculator( BinaryRebateType binaryRebateType, double strike, double spotPrice, double sigma, double dividendRate, double riskFreeRate, double cashOrNothingAmount, double exerciseInYears, InstrumentType underlyingInstrumentType, double notional = 1.0) { _X = strike; _S = spotPrice; _notional = notional; _cashOrNothingAmount = cashOrNothingAmount; _sigma = sigma; _T = exerciseInYears; _binaryRebateType = binaryRebateType; _r = riskFreeRate; _dividendRate = dividendRate; _isOptionOnFutures = AnalyticalOptionPricerUtil.isFuturesOption(underlyingInstrumentType); _isOptionOnForward = AnalyticalOptionPricerUtil.isForwardOption(underlyingInstrumentType); _b = AnalyticalOptionPricerUtil.costOfCarry(_isOptionOnFutures || _isOptionOnForward, dividendRate, riskFreeRate); }
public Position( string name, string figi, string ticker, string isin, InstrumentType instrumentType, decimal balance, decimal blocked, MoneyAmount expectedYield, int lots, MoneyAmount averagePositionPrice, MoneyAmount averagePositionPriceNoNkd) { Name = name; Figi = figi; Ticker = ticker; Isin = isin; InstrumentType = instrumentType; Balance = balance; Blocked = blocked; ExpectedYield = expectedYield; Lots = lots; AveragePositionPrice = averagePositionPrice; AveragePositionPriceNoNkd = averagePositionPriceNoNkd; }
public SpiderVwapBand(BarSeries input, double factor, InstrumentType instrumentType) : base(input) { _factor = factor; _instrumentType = instrumentType; this.Name = string.Format("SpiderVwapBand ({0:N4})", factor); }
public Instrument(InstrumentType type, string symbol, string description = "", byte currencyId = 1) : this() { this.type = type; this.symbol = symbol; this.description = description; this.currencyId = currencyId; }
public StockLayOut(ObligInfo _oblig) { InitializeComponent(); oblig = _oblig; it = InstrumentType.Bond; }
/// <summary> /// Sets the default parameters for an index instrument. /// </summary> /// <param name="symbol">The instrument symbol.</param> /// <param name="instrType">The instrument type: Index or CFD</param> private void SetDefaultIndexParams(string symbol, InstrumentType instrType) { Symbol = symbol; InstrType = instrType; Comment = symbol + " " + instrType; Digits = 2; LotSize = 100; Spread = 4; SwapType = CommissionType.Percents; SwapLong = -5.0; SwapShort = -1.0; CommissionType = CommissionType.Percents; CommissionScope = CommissionScope.Deal; CommissionTime = CommissionTime.OpenClose; Commission = 0.25; Slippage = 0; PriceIn = "USD"; RateToUSD = 1; RateToEUR = 1; RateToGBP = 1; RateToJPY = 0.01; BaseFileName = symbol; LotSize = 10000; StopLevel = 5; TickValue = LotSize * Point; MinLot = 0.01; MaxLot = 100; LotStep = 0.01; MarginRequired = 1000; }
/// <summary> /// Broadcasts Effect in range of creature. /// </summary> /// <param name="creature"></param> /// <param name="instrument"></param> /// <param name="quality"></param> /// <param name="compressedMML"></param> /// <param name="rndScore"></param> public static void PlayEffect(Creature creature, InstrumentType instrument, PlayingQuality quality, string compressedMML, int rndScore) { var packet = new Packet(Op.Effect, creature.EntityId); packet.PutInt(E.PlayMusic); packet.PutByte(compressedMML != null); // has scroll if (compressedMML != null) { packet.PutString(compressedMML); } else { packet.PutInt(rndScore); } packet.PutInt(0); packet.PutShort(0); packet.PutInt(14113); // ? packet.PutByte((byte)quality); packet.PutByte((byte)instrument); packet.PutByte(0); packet.PutByte(0); packet.PutByte(1); // loops // Singing? //packet.PutByte(0); //packet.PutByte(1); creature.Region.Broadcast(packet, creature); }
public Instrument(InstrumentType instrumentType, IEnumerable <ItemValue> items) { TestDateTime = DateTime.Now; CertificateId = null; Type = instrumentType; Items = items; }
public void StartNoise(int noteLength) { Type = InstrumentType.Noise; _noiseCounter = 0x7FFF; BaseTimer = 8006; Start(noteLength); }
/// <summary> /// /// </summary> /// <param name="instrumentType"></param> public static InstrumentBase AddInstrument(InstrumentType instrumentType) { try { InstrumentManager.InstExclusiveLockObject.EnterWriteLock(); Program.SoundUpdating(); if (instruments[(int)instrumentType].Count < 8) { Assembly asm = Assembly.GetAssembly(typeof(InstrumentType)); string name = Enum.GetName(typeof(InstrumentType), instrumentType); Type t = asm.GetType("zanac.MAmidiMEmo.Instruments.Chips." + name); var inst = (InstrumentBase)Activator.CreateInstance(t, (uint)instruments[(int)instrumentType].Count); inst.PrepareSound(); instruments[(int)instrumentType].Add(inst); InstrumentAdded?.Invoke(typeof(InstrumentManager), EventArgs.Empty); if (VgmRecodring) { inst.StartVgmRecordingTo(LastVgmOutputDir); } return(inst); } } finally { Program.SoundUpdated(); InstrumentManager.InstExclusiveLockObject.ExitWriteLock(); } return(null); }
public void Read(NetworkStream stream) { X = StreamHelper.ReadInt(stream); Y = StreamHelper.ReadShort(stream); Z = StreamHelper.ReadInt(stream); Instrument = (InstrumentType)stream.ReadByte(); Pitch = (byte)stream.ReadByte(); }
public InstrumentProperties(string symbol, InstrumentType instrType) { if (instrType == InstrumentType.Forex) SetDefaultForexParams(symbol); else SetDefaultIndexParams(symbol, instrType); SetPrecision(); }
public void Program(byte program, bool mt32) { Clear(); if (program > 127) return; _type = InstrumentType.Program; _instrument = new InstrumentProgram(program, mt32); }
public Instrument(string serialNumber, double price, InstrumentSpec spec) { this.serialNumber = serialNumber; this.price = price; this.spec = spec; this.instrumentType = getInstrumentType(spec); }
public SpiderVwapBandOld(ISeries input, double factor, BarSeries priceBarSeries, int barSize, InstrumentType instrumentType) : base(input) { _factor = factor; _priceBarSeries = priceBarSeries; _barSize = barSize; _instrumentType = instrumentType; this.Name = string.Format("SpiderVwapBand ({0:N4})", factor); }
public static bool IsSessionOpenBar(this Bar bar, InstrumentType insType) { if (insType != InstrumentType.Stock) throw new NotImplementedException("Not implemented for anything other than stocks"); if (IsDailyBar(bar)) return true; return bar.BeginTime.TimeOfDay.TotalSeconds <= 23400; }
public static bool IsWithinRegularTradingHours(this Bar bar, InstrumentType insType) { if (insType != InstrumentType.Stock) throw new NotImplementedException("Not implemented for anything other than stocks"); if (IsDailyBar(bar)) return true; return bar.BeginTime.IsWithinRegularTradingHours(insType); }
public static bool IsWithinRegularTradingHours(this DateTime datetime, InstrumentType insType) { if (insType != InstrumentType.Stock) throw new NotImplementedException("Not implemented for anything other than stocks"); return datetime.TimeOfDay.TotalSeconds >= PstSessionTimeConstants.StockExchangeStartTimeSeconds && datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.StockExchangeEndTimeSeconds && datetime.DayOfWeek != DayOfWeek.Saturday && datetime.DayOfWeek != DayOfWeek.Sunday; }
public Track(Composition composition, string fullname, string shortname, InstrumentFamily family, InstrumentType type, InstrumentFeature feature, string color) { this.Composition = composition; this.FullName = fullname; this.ShortName = shortname; this.Instrument = new Instrument(family, type, feature); this.Family = family; this.Type = type; this.Feature = feature; this.Color = color; this.SaveToDB(); }
public override IFactory GetInstrument(InstrumentType instrument) { switch (instrument) { case InstrumentType.Fender: return new Fender(); case InstrumentType.Gibson: return new Gibson(); default: throw new ApplicationException($"Instrument type {instrument} cannot be created"); } }
public Track(Composition composition, string fullname, string shortname, InstrumentFamily family, InstrumentType type, InstrumentFeature feature, string color) { this.Id = Guid.NewGuid(); this.Composition = composition; this.FullName = fullname; this.ShortName = shortname; this.Family = family.ToString(); this.Type = type.ToString(); this.Feature = feature.ToString(); this.Instrument = new Instrument(family, type, feature); this.Color = color; this.Notes = new List<Note>(); this.Save(); }
public void SetInstrumentType(string type) { if (!string.IsNullOrEmpty(type)) { switch (type.ToLower()) { case "stock": _instrumentType = InstrumentType.Stock; break; case "etf": _instrumentType = InstrumentType.ETF; break; case "index": _instrumentType = InstrumentType.Index; break; } } }
public static bool IsWithinRegularTradingHours(this DateTime datetime, InstrumentType instrumentType) { if (datetime.DayOfWeek == DayOfWeek.Saturday) return false; if (instrumentType == InstrumentType.Stock) { return datetime.TimeOfDay.TotalSeconds >= PstSessionTimeConstants.StockExchangeStartTimeSeconds && datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.StockExchangeEndTimeSeconds && datetime.DayOfWeek != DayOfWeek.Saturday && datetime.DayOfWeek != DayOfWeek.Sunday; } if (instrumentType == InstrumentType.Futures) { if (datetime.DayOfWeek == DayOfWeek.Sunday) { return datetime.TimeOfDay.TotalSeconds >= PstSessionTimeConstants.FuturesExchangeStartTimeInSecods; } else { return datetime.TimeOfDay.TotalSeconds >= PstSessionTimeConstants.FuturesExchangeStartTimeInSecods || datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.FuturesExchangeEndTimeInSecods; } } if (instrumentType == InstrumentType.FX) { if (datetime.DayOfWeek == DayOfWeek.Sunday) { return datetime.TimeOfDay.TotalSeconds >= PstSessionTimeConstants.FxExchangeSundayStartTimeInSecods; } else { return true; } } throw new NotSupportedException("Does not support instrument type of: " + instrumentType.ToString()); }
public static string toString(InstrumentType type) { switch (type) { case InstrumentType.GUITAR: return "Guitar"; case InstrumentType.BANJO: return "Banjo"; case InstrumentType.DOBRO: return "Dobro"; case InstrumentType.FIDDLE: return "Fiddle"; case InstrumentType.BASS: return "Bass"; case InstrumentType.MANDOLIN: return "Mandolin"; default: return "Unspecified"; } }
public static bool IsSessionOpeningBar(this DateTime datetime, long barSize, InstrumentType instrumentType) { if (!datetime.IsWithinRegularTradingHours(instrumentType)) return false; if (instrumentType == InstrumentType.Futures) { return datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.FuturesExchangeStartTimeInSecods + barSize + 1; } if (instrumentType == InstrumentType.FX) { return datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.FxExchangeSundayStartTimeInSecods + barSize + 1; } if (instrumentType == InstrumentType.Stock) { return datetime.TimeOfDay.TotalSeconds <= PstSessionTimeConstants.StockExchangeStartTimeSeconds + barSize + 1; } throw new NotSupportedException("Does not support instrument type of: " + instrumentType.ToString()); }
public static Instrument Create(InstrumentType type) { switch (type) { case InstrumentType.Line: return new LineInstrument(); case InstrumentType.Pen: return new PenInstrument(); case InstrumentType.Rect: return new RectInstrument(); case InstrumentType.Arrow: return new ArrowInstrument(); case InstrumentType.Blur: return new BlurInstrument(); case InstrumentType.Hightlight: return new HightlightInstrument(); case InstrumentType.Text: return new TextInstrument(); default: throw new NotImplementedException(); } }
/// <summary> /// Broadcasts Effect in range of creature. /// </summary> /// <param name="creature"></param> /// <param name="instrument"></param> /// <param name="quality"></param> /// <param name="compressedMML"></param> /// <param name="rndScore"></param> public static void PlayEffect(Creature creature, InstrumentType instrument, PlayingQuality quality, string compressedMML, int rndScore) { var packet = new Packet(Op.Effect, creature.EntityId); packet.PutInt(E.PlayMusic); packet.PutByte(compressedMML != null); // has scroll if (compressedMML != null) packet.PutString(compressedMML); else packet.PutInt(rndScore); packet.PutInt(0); packet.PutShort(0); packet.PutInt(14113); // ? packet.PutByte((byte)quality); packet.PutByte((byte)instrument); packet.PutByte(0); packet.PutByte(0); packet.PutByte(1); // loops // Singing? //packet.PutByte(0); //packet.PutByte(1); creature.Region.Broadcast(packet, creature); }
public IInstrument GetInstrument(InstrumentType type) { IInstrument instrument = null; bool found = instruments.TryGetValue(type, out instrument); if (!found) { if (type == InstrumentType.Violin) { instrument = new Violin(); instruments.Add(type, instrument); } else if(type == InstrumentType.Trumpet) { instrument = new Trumpet(); instruments.Add(type, instrument); } else { instrument = new Drum(); instruments.Add(type, instrument); } } return instrument; }
internal Instrument(int id, InstrumentType type, string symbol, string description = "", byte currencyId = 1) : this() { this.id = id; this.type = type; this.symbol = symbol; this.description = description; this.currencyId = currencyId; }
public Instrument(InstrumentType type, string symbol, string description = "", byte currencyId = 1) : this() { this.type = type; this.symbol = symbol; this.description = description; this.currencyId = currencyId; }
/// <summary> /// Playing instrument effect (sound and motion) for creature, /// based on the given MML code. /// </summary> /// <param name="creature"></param> /// <param name="instrument"></param> /// <param name="quality"></param> /// <param name="compressedMML"></param> /// <returns></returns> public static MabiPacket PlayEffect(MabiCreature creature, InstrumentType instrument, PlayingQuality quality, string compressedMML) { var p = new MabiPacket(Op.Effect, creature.Id); p.PutInt(Effect.PlayMusic); p.PutByte(true); // has scroll p.PutString(compressedMML); p.PutInt(0); p.PutShort(0); p.PutInt(14113); // ? p.PutByte((byte)quality); p.PutByte((byte)instrument); p.PutByte(0); p.PutByte(0); p.PutByte(1); // loops return p; }
/// <summary> /// Playing instrument effect (sound and motion) for creature, /// based on the given score id (client:score.xml). /// </summary> /// <param name="creature"></param> /// <param name="instrument"></param> /// <param name="quality"></param> /// <param name="score"></param> /// <returns></returns> public static MabiPacket PlayEffect(MabiCreature creature, InstrumentType instrument, PlayingQuality quality, uint score) { var p = new MabiPacket(Op.Effect, creature.Id); p.PutInt(Effect.PlayMusic); p.PutByte(false); p.PutInt(score); p.PutInt(0); p.PutShort(0); p.PutInt(14113); p.PutByte((byte)quality); p.PutByte((byte)instrument); p.PutByte(0); p.PutByte(0); p.PutByte(1); return p; }
public void CreateTrack(Composition SelectedComposition, string FullName, string ShortName, InstrumentFamily Family, InstrumentType Type, InstrumentFeature Feature, string Color) { Track Track = new Track(SelectedComposition, FullName, ShortName, Family, Type, Feature, Color); }
public void EditTrack(Track SelectedTrack, Composition NewComposition, string NewFullName, string NewShortName, InstrumentFamily NewFamily, InstrumentType NewType, InstrumentFeature NewFeature, string NewColor) { SelectedTrack.Update( new Track() { Composition = NewComposition, FullName = NewFullName, ShortName = NewShortName, Family = NewFamily.ToString(), Type = NewType.ToString(), Feature = NewFeature.ToString(), Instrument = new Instrument(NewFamily, NewType, NewFeature), Color = NewColor }); }
public static SecurityType SecurityTypeConverter(InstrumentType type) { if((int)type >= 13) { throw new Exception(string.Format("Can not convert InstrumentType {0} to SecurityType", type)); } return (SecurityType)(int)type; }
internal static string Convert(InstrumentType instrumentType) { switch (instrumentType) { case InstrumentType.Stock: return "CS"; case InstrumentType.Futures: return "FUT"; case InstrumentType.Option: return "OPT"; case InstrumentType.FutOpt: return "FOP"; case InstrumentType.Bond: return "TBOND"; case InstrumentType.Index: return "IDX"; case InstrumentType.ETF: return "ETF"; case InstrumentType.FX: return "FOR"; case InstrumentType.MultiLeg: return "MLEG"; case InstrumentType.Commodity: return "CMDTY"; default: throw new NotImplementedException("SecurityType is not supported : " + instrumentType); } }
/// <summary> /// Starts play effect. /// </summary> /// <param name="creature"></param> /// <param name="instrumentType"></param> /// <param name="quality"></param> /// <param name="compressedMml"></param> /// <param name="scoreId"></param> private void StartPlay(Creature creature, Skill skill, InstrumentType instrumentType, int quality, string compressedMml, int scoreId) { // [200200, NA242 (2016-12-15)] // The playing effect for instruments was turned into a prop, // presumably to have something to reference in the world // for jams, and to make it more than a temp effect. //Send.PlayEffect(creature, instrumentType, quality, mml, rndScore); var regionId = creature.RegionId; var pos = creature.GetPosition(); var prop = new PlayingInstrumentProp(regionId, pos.X, pos.Y); prop.CompressedMML = compressedMml; prop.ScoreId = scoreId; prop.Quality = quality; prop.Instrument = instrumentType; prop.StartTime = DateTime.Now; prop.CreatureEntityId = creature.EntityId; creature.Region.AddProp(prop); creature.Temp.PlayingInstrumentProp = prop; }