Posted 11/23/2008 19:04:47
|
|
|
|
Does the new RE have any functions for manipulating watch lists? I need to keep a watch list up to date with an index.
At this stage I am looking at writing code to delete/update the XML file and was wondering if there is a faster/easier way?
|
|
Posted 11/24/2008 07:46:27
|
|
|
|
The beta does not. However, if you look at XmlSerialization, if should be a snap to load. I've attached the class for a watchlistitem and some sample code to load and save the watchlist.// Load StreamReader streamReader = new StreamReader(fileName); XmlSerializer xmlSerializer = new XmlSerializer(typeof(WatchListItem)); rootItem = (WatchListItem)xmlSerializer.Deserialize(streamReader); // Save streamWriter = new StreamWriter(fileName); XmlSerializer xmlSerializer = new XmlSerializer(typeof(WatchListItem)); xmlSerializer.Serialize(streamWriter, rootItem);
. kaizen (11/23/2008) Does the new RE have any functions for manipulating watch lists? I need to keep a watch list up to date with an index.
At this stage I am looking at writing code to delete/update the XML file and was wondering if there is a faster/easier way?
|
|
Posted 11/27/2008 03:24:52
|
|
|
|
Thanks that got me on the right track.
Do you have nay functions to add/delete a folder/symbol? i.e one at a time.
|
|
Posted 12/2/2008 05:04:03
|
|
|
|
| Is this something that can be done/used while the system is running live?
|
|
Posted 12/2/2008 07:44:01
|
|
|
|
| Well, not specifically. Everything exists in a collection and we add/remove from the collection. Usually when a change is made to the collection, it is saved to disk. kaizen (11/27/2008) Thanks that got me on the right track.
Do you have nay functions to add/delete a folder/symbol? i.e one at a time.
|
|
Posted 12/2/2008 07:44:56
|
|
|
|
| You can add/remove symbols from the folder from wherever you want, but keep in mind, the symbols themselves are only loaded by RightEdge at the start of the system. lksf (12/2/2008) Is this something that can be done/used while the system is running live?
|
|
Posted 12/5/2008 03:34:36
|
|
|
|
Are you able to have a look at the attached code and let me know what I am doing wrong?
I can find the folder I want but when I try to add a symbol to it it is not saving the symbol name correctly. Am I going about it all wrong or am I missing something easy?
I ma loading a list of symbol from the txt file to add to the S&P 200 watch list.
Thanks.
namespace Update_RE_Watch_List{ public partial class Form1 : Form{ public Form1(){ InitializeComponent(); } private void button1_Click(object sender, EventArgs e){ // Loadstring filename = "C:\\Documents and Settings\\Jimmy\\Application Data\\Yye Software\\RightEdge\\2008.1.0.0\\SymbolConfig.xml";StreamReader streamReader = new StreamReader(filename);XmlSerializer xmlSerializer = new XmlSerializer(typeof(RightEdge.Objects.WatchListItem));RightEdge.Objects. WatchListItem wlItem;//load the text file//"C:\\Trading Data\\Stocks\\ASX\\Lists\\S&P ASX 200.asx.txt"// create reader & open fileTextReader tr = new StreamReader("C:\\Trading Data\\Stocks\\ASX\\Lists\\S&P ASX 200.asx.txt");wlItem = (RightEdge.Objects. WatchListItem)xmlSerializer.Deserialize(streamReader);foreach (RightEdge.Objects.WatchListItem item in wlItem.folder.Contents){ if (item.folder.FolderName == "S&P ASX 200"){ System.Diagnostics. Debug.Print(item.folder.FolderName);//RightEdge.Common.Symbol symbol = new RightEdge.Common.Symbol();RightEdge.Common. Symbol newSymbol = new RightEdge.Common.Symbol();// = new RightEdge.Common.SymbolSetup();newSymbol.AssetClass = RightEdge.Common. AssetClass.Stock;newSymbol.ContractType = RightEdge.Common. ContractType.NoContract;newSymbol.CurrencyType = RightEdge.Common. CurrencyType.AUD;newSymbol.Exchange = "";newSymbol.SymbolInformation.DecimalPlaces = 3; newSymbol.SymbolInformation.CompanyName = "";newSymbol.SymbolInformation.ContractSize = 0; newSymbol.SymbolInformation.Industry = "";newSymbol.SymbolInformation.Margin = 0; newSymbol.SymbolInformation.Sector = "";newSymbol.SymbolInformation.TickSize = 0; newSymbol.SymbolInformation.SymbolNotes = "Auto Gen Code";//delete all the old contentsitem.Folder.Contents.Clear(); string input = null;while ((input = tr.ReadLine()) != null){ RightEdge.Objects. WatchListItem newItem = new RightEdge.Objects.WatchListItem();newItem.BarConstruction = RightEdge.Common. BarConstructionType.Last;newItem.Folder = item.Folder; newItem.IsFolder = item.IsFolder; newItem.Parent = item.Parent; newSymbol.Name = input; newItem.symbol = newSymbol; newItem.Symbol = newSymbol; newItem.symbol.Name = input; item.Folder.Contents.Add(newItem); } tr.Close(); streamReader.Close(); StreamWriter streamWriter = new StreamWriter(filename);XmlSerializer xmlSaveSerializer = new XmlSerializer(typeof(RightEdge.Objects.WatchListItem));xmlSerializer.Serialize(streamWriter, wlItem); break;} } } } }
|
|
Posted 12/5/2008 04:53:21
|
|
|
|
The inner while loop is adding the same 'newSymbol' object to each 'newItem' being created. Given this I would expect all of the added items to have a Symbol.Name set to whatever the final input line was from the ReadLine(). If that's the problem you are seeing, you might try moving the 'newSymbol' creation/setup inside your while ReadLine() loop.
HTH,
Mark
|
|
Posted 12/5/2008 06:30:49
|
|
|
|
No it is actually not setting the symbol name at all.
The symbol name gets updated on each loop as it is updated with the input var on each loop. The symbol object is correct but it not being passed to the watch list object correctly.
The problem (as I forgot to mention before) is it sets each symbol to the name of the folder. So when I do a break point and view the contents of the folder there are 200 items with the name of the folder. Where each symbol should be named by the symbol from the text file.
|
|
Posted 12/5/2008 08:12:26
|
|
|
|
I've been staring at it for a bit and nothing jumps out at me. However, I don't know why you're doing all of that additional initialization. In our code it's simply: WatchListItem item = new WatchListItem(false); item.Symbol = Symbol; item.Parent = destItem; destItem.Folder.Contents.Add(item);
|
|
|
|