void SubscriptionListener.onItemUpdate(ItemUpdate itemUpdate) { try { lock (chartForm.quotessource) { CultureInfo culture = new CultureInfo("en-US"); double tmp = Double.Parse(itemUpdate.getValue("last_price"), culture); if (chartForm.quotessource.Count > 5000) { chartForm.quotessource.RemoveAt(0); } chartForm.quotessource.Add(new Record(5, itemUpdate.getValue("time"), tmp)); if (tmp < chartForm.minvisual) { chartForm.minvisual = tmp; } } chartForm.Invoke(delegateChart, new Object[] { itemUpdate.ItemPos, itemUpdate }); } catch (Exception e) { Console.WriteLine("Message: " + e.Message); Console.WriteLine(e.StackTrace); } }
void SubscriptionListener.onItemUpdate(ItemUpdate update) { Debug.WriteLine("Details received."); Debug.WriteLine(NotifyUpdate(update) + " for " + update.ItemName + ":" + update.getValue(1) + " - " + update.getValue(3) ); if (update.isValueChanged(1)) { rTfeed.DetailsName = update.getValue(1); } if (update.isValueChanged(2)) { rTfeed.DetailsLast = update.getValue(2); } if (update.isValueChanged(3)) { rTfeed.DetailsTime = update.getValue(3); } if (update.isValueChanged(4)) { rTfeed.DetailsMin = update.getValue(4); } if (update.isValueChanged(5)) { rTfeed.DetailsMax = update.getValue(5); } if (update.isValueChanged(6)) { rTfeed.DetailsChg = update.getValue(6); if (float.Parse(update.getValue(6)) > 0) { rTfeed.DetailsChgDiff = Color.Green; } else { rTfeed.DetailsChgDiff = Color.Red; } } if (update.isValueChanged(7)) { rTfeed.DetailsBid = update.getValue(7); } if (update.isValueChanged(8)) { rTfeed.DetailsAsk = update.getValue(8); } }
public void onItemUpdate(ItemUpdate update) { string command = update.getValue("command"); if (command.Equals("ADD")) { Console.WriteLine("first update for this key (" + update.getValue("key") + "), the library is now automatically subscribing the second level item for it"); } else if (command.Equals("UPDATE")) { StringBuilder updateString = new StringBuilder("Update for "); updateString.Append(update.getValue("stock_name")); //2nd level field updateString.Append(", last price is "); updateString.Append(update.getValue("last_price")); //2nd level field updateString.Append(" ("); updateString.Append(update.getValue("time")); // 2nd level field updateString.Append("), we own "); updateString.Append(update.getValue("qty")); //1st level field updateString.Append(" --> "); updateString.Append(getCtv(update)); Console.WriteLine(updateString); //there is the possibility that a second update for the first level is received before the first update for the second level //thus we might print a message that contains a few NULLs } else if (command.Equals("DELETE")) { Console.WriteLine("key (" + update.getValue("key") + "), was removed, the library is now automatically unsubscribing the second level item for it"); } }
protected override StreamingAccountData LoadUpdate(ItemUpdate update) { try { var streamingAccountData = new StreamingAccountData { ProfitAndLoss = StringToNullableDecimal(update.getValue("PNL")), Deposit = StringToNullableDecimal(update.getValue("DEPOSIT")), UsedMargin = StringToNullableDecimal(update.getValue("USED_MARGIN")), AmountDue = StringToNullableDecimal(update.getValue("AMOUNT_DUE")), AvailableCash = StringToNullableDecimal(update.getValue("AVAILABLE_CASH")) }; return(streamingAccountData); } catch (Exception) { return(null); } }
private string getCtv(ItemUpdate update) { long newqty; double newprice; if (Int64.TryParse(update.getValue("qty"), out newqty)) { if (Double.TryParse(update.getValue("last_price"), out newprice)) { return("" + (newqty * newprice)); } else { return("###"); } } else { return("###"); } }
public StreamingAccountData StreamingAccountDataUpdates(ItemUpdate update) { var streamingAccountData = new StreamingAccountData(); try { var pnl = update.getValue("PNL"); var deposit = update.getValue("DEPOSIT"); var usedMargin = update.getValue("USED_MARGIN"); var amountDue = update.getValue("AMOUNT_DUE"); var availableCash = update.getValue("AVAILABLE_CASH"); if (!string.IsNullOrEmpty(pnl)) { streamingAccountData.ProfitAndLoss = Convert.ToDecimal(pnl, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(deposit)) { streamingAccountData.Deposit = Convert.ToDecimal(deposit, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(usedMargin)) { streamingAccountData.UsedMargin = Convert.ToDecimal(usedMargin, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(amountDue)) { streamingAccountData.AmountDue = Convert.ToDecimal(amountDue, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(availableCash)) { streamingAccountData.AmountDue = Convert.ToDecimal(availableCash, CultureInfo.InvariantCulture); } } catch (Exception) { } return(streamingAccountData); }
protected override L1LsPriceData LoadUpdate(ItemUpdate update) { try { var lsL1PriceData = new L1LsPriceData { MidOpen = StringToNullableDecimal(update.getValue("MID_OPEN")), High = StringToNullableDecimal(update.getValue("HIGH")), Low = StringToNullableDecimal(update.getValue("LOW")), Change = StringToNullableDecimal(update.getValue("CHANGE")), ChangePct = StringToNullableDecimal(update.getValue("CHANGE_PCT")), UpdateTime = update.getValue("UPDATE_TIME"), MarketDelay = StringToNullableInt(update.getValue("MARKET_DELAY")), MarketState = update.getValue("MARKET_STATE"), Bid = StringToNullableDecimal(update.getValue("BID")), Offer = StringToNullableDecimal(update.getValue("OFFER")) }; return(lsL1PriceData); } catch (Exception) { return(null); } }
void SubscriptionListener.onItemUpdate(ItemUpdate update) { int itemPos = update.ItemPos; Debug.WriteLine("Update received."); Debug.WriteLine(NotifyUpdate(update) + " for " + itemPos + ":" + update.getValue(1) + " - " + update.getValue(2) ); if (itemPos == 1) { if (update.isValueChanged(2)) { rTfeed.LabelText0 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText0 = update.getValue(1); } } if (itemPos == 2) { if (update.isValueChanged(2)) { rTfeed.LabelText1 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText1 = update.getValue(1); } } if (itemPos == 3) { if (update.isValueChanged(2)) { rTfeed.LabelText2 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText2 = update.getValue(1); } } if (itemPos == 4) { if (update.isValueChanged(2)) { rTfeed.LabelText3 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText3 = update.getValue(1); } } if (itemPos == 5) { if (update.isValueChanged(2)) { rTfeed.LabelText4 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText4 = update.getValue(1); } } if (itemPos == 6) { if (update.isValueChanged(2)) { rTfeed.LabelText5 = update.getValue(2); } if (update.isValueChanged(1)) { rTfeed.DescText5 = update.getValue(1); } } }
protected override ChartCandelData LoadUpdate(ItemUpdate update) { try { var updateData = new ChartCandelData { Bid = new HlocData { High = StringToNullableDecimal(update.getValue("BID_HIGH")), Low = StringToNullableDecimal(update.getValue("BID_LOW")), Open = StringToNullableDecimal(update.getValue("BID_OPEN")), Close = StringToNullableDecimal(update.getValue("BID_CLOSE")) }, Offer = new HlocData { High = StringToNullableDecimal(update.getValue("OFR_HIGH")), Low = StringToNullableDecimal(update.getValue("OFR_LOW")), Open = StringToNullableDecimal(update.getValue("OFR_OPEN")), Close = StringToNullableDecimal(update.getValue("OFR_CLOSE")) }, LastTradedPrice = new HlocData { High = StringToNullableDecimal(update.getValue("LTP_HIGH")), Low = StringToNullableDecimal(update.getValue("LTP_LOW")), Open = StringToNullableDecimal(update.getValue("LTP_OPEN")), Close = StringToNullableDecimal(update.getValue("LTP_CLOSE")) }, LastTradedVolume = StringToNullableDecimal(update.getValue("LTV")), IncrimetalTradingVolume = StringToNullableDecimal(update.getValue("TTV")), UpdateTime = EpocStringToNullableDateTime(update.getValue("UTM")), DayMidOpenPrice = StringToNullableDecimal(update.getValue("DAY_OPEN_MID")), DayChange = StringToNullableDecimal(update.getValue("DAY_NET_CHG_MID")), DayChangePct = StringToNullableDecimal(update.getValue("DAY_PERC_CHG_MID")), DayHigh = StringToNullableDecimal(update.getValue("DAY_HIGH")), DayLow = StringToNullableDecimal(update.getValue("DAY_LOW")), TickCount = StringToNullableInt(update.getValue("CONS_TICK_COUNT")) }; var conEnd = StringToNullableInt(update.getValue("CONS_END")); updateData.EndOfConsolidation = conEnd.HasValue ? conEnd > 0 : (bool?)null; return(updateData); } catch (Exception) { return(null); } }
protected override ChartTickData LoadUpdate(ItemUpdate update) { try { var updateData = new ChartTickData { Bid = StringToNullableDecimal(update.getValue("BID")), Offer = StringToNullableDecimal(update.getValue("OFR")), LastTradedPrice = StringToNullableDecimal(update.getValue("LTP")), LastTradedVolume = StringToNullableDecimal(update.getValue("LTV")), IncrimetalTradingVolume = StringToNullableDecimal(update.getValue("TTV")), UpdateTime = EpocStringToNullableDateTime(update.getValue("UTM")), DayMidOpenPrice = StringToNullableDecimal(update.getValue("DAY_OPEN_MID")), DayChange = StringToNullableDecimal(update.getValue("DAY_NET_CHG_MID")), DayChangePct = StringToNullableDecimal(update.getValue("DAY_PERC_CHG_MID")), DayHigh = StringToNullableDecimal(update.getValue("DAY_HIGH")), DayLow = StringToNullableDecimal(update.getValue("DAY_LOW")) }; return(updateData); } catch (Exception) { return(null); } }
public string L1PriceUpdates(ItemUpdate update) { var sb = new StringBuilder(); sb.AppendLine("Item Position: " + update.ItemPos); sb.AppendLine("Item Name: " + update.ItemName); try { var midOpen = update.getValue("MID_OPEN"); var high = update.getValue("HIGH"); var low = update.getValue("LOW"); var change = update.getValue("CHANGE"); var changePct = update.getValue("CHANGE_PCT"); var updateTime = update.getValue("UPDATE_TIME"); var marketDelay = update.getValue("MARKET_DELAY"); var marketState = update.getValue("MARKET_STATE"); var bid = update.getValue("BID"); var offer = update.getValue("OFFER"); if (!string.IsNullOrEmpty(midOpen)) { sb.AppendLine("mid open: " + midOpen); } if (!string.IsNullOrEmpty(high)) { sb.AppendLine("high: " + high); } if (!string.IsNullOrEmpty(low)) { sb.AppendLine("low: " + low); } if (!string.IsNullOrEmpty(change)) { sb.AppendLine("change: " + change); } if (!string.IsNullOrEmpty(changePct)) { sb.AppendLine("change percent: " + changePct); } if (!string.IsNullOrEmpty(updateTime)) { sb.AppendLine("update time: " + updateTime); } if (!string.IsNullOrEmpty(marketDelay)) { sb.AppendLine("market delay: " + marketDelay); } if (!string.IsNullOrEmpty(marketState)) { sb.AppendLine("market state: " + marketState); } if (!string.IsNullOrEmpty(bid)) { sb.AppendLine("bid: " + bid); } if (!string.IsNullOrEmpty(offer)) { sb.AppendLine("offer: " + offer); } } catch (Exception ex) { sb.AppendLine("Exception in L1 Prices"); sb.AppendLine(ex.Message); } return(sb.ToString()); }
public L1LsPriceData L1LsPriceUpdateData(ItemUpdate update) { var lsL1PriceData = new L1LsPriceData(); try { var midOpen = update.getValue("MID_OPEN"); var high = update.getValue("HIGH"); var low = update.getValue("LOW"); var change = update.getValue("CHANGE"); var changePct = update.getValue("CHANGE_PCT"); var updateTime = update.getValue("UPDATE_TIME"); var marketDelay = update.getValue("MARKET_DELAY"); var marketState = update.getValue("MARKET_STATE"); var bid = update.getValue("BID"); var offer = update.getValue("OFFER"); if (!string.IsNullOrEmpty(midOpen)) { lsL1PriceData.MidOpen = Convert.ToDecimal(midOpen, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(high)) { lsL1PriceData.High = Convert.ToDecimal(high, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(low)) { lsL1PriceData.Low = Convert.ToDecimal(low, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(change)) { lsL1PriceData.Change = Convert.ToDecimal(change, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(changePct)) { lsL1PriceData.ChangePct = Convert.ToDecimal(changePct, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(updateTime)) { lsL1PriceData.UpdateTime = updateTime; } if (!string.IsNullOrEmpty(marketDelay)) { lsL1PriceData.MarketDelay = Convert.ToInt32(marketDelay, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(marketState)) { lsL1PriceData.MarketState = marketState; } if (!string.IsNullOrEmpty(bid)) { lsL1PriceData.Bid = Convert.ToDecimal(bid, CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(offer)) { lsL1PriceData.Offer = Convert.ToDecimal(offer, CultureInfo.InvariantCulture); } } catch (Exception) { } return(lsL1PriceData); }