﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.com/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">entityregistry. StockSharp</title>
  <id>https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=entityregistry&amp;type=forum</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-06-14T17:57:10Z</updated>
  <logo>https://stocksharp.com/images/logo.png</logo>
  <link href="https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=entityregistry&amp;type=forum" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.com/topic/8797/</id>
    <title type="text">Storing positions</title>
    <published>2017-11-06T22:30:01Z</published>
    <updated>2017-12-18T10:16:31Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.com/users/99799/</uri>
      <email>info@stocksharp.com</email>
    </author>
    <category term="StorageRegistry" />
    <category term="InitializeStorage" />
    <category term="StorageAdapter" />
    <category term="EntityRegistry" />
    <content type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I need to store my positions so that when my application starts up it can load the existing positions. The code I use is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
var dataPath = @&amp;quot;Data\&amp;quot; + _connectorAccount.AccountName;
_entityRegistry = new CsvEntityRegistry(dataPath);
_storageRegistry = new StorageRegistry
{
    DefaultDrive = new LocalMarketDataDrive(dataPath)
};

_connector.InitializeStorage(_entityRegistry, _storageRegistry);
_entityRegistry.Init();

_connector.StorageAdapter.DaysLoad = DateTime.Now.Subtract(_connectorAccount.StartTrading.Value);

_connector.StorageAdapter.Format = StorageFormats.Csv;
_connector.StorageAdapter.Load();

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem is that when I connect to TWS, I get the following error message:&lt;/p&gt;
&lt;p&gt;Message 'Connect,T(L)=2017/11/06 21:25:31.278,Error=At least one connection should be made.' caused processing error.&lt;/p&gt;
&lt;p&gt;with inner exception message:&lt;/p&gt;
&lt;p&gt;The given key was not present in the dictionary.&lt;/p&gt;
&lt;p&gt;and inner exception stack trace:&lt;/p&gt;
&lt;p&gt;at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary&lt;code&gt;2.get_Item(TKey key) at Ecng.Collections.SynchronizedDictionary&lt;/code&gt;2.get_Item(TKey key)
at StockSharp.Algo.Connector.ProcessConnectMessage(BaseConnectionMessage message)
at StockSharp.Algo.Connector.OnProcessMessage(Message message)&lt;/p&gt;
</content>
  </entry>
  <entry>
    <id>https://stocksharp.com/topic/8796/</id>
    <title type="text">Storing positions</title>
    <published>2017-11-06T22:27:33Z</published>
    <updated>2017-11-06T22:27:33Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.com/users/99551/</uri>
      <email>info@stocksharp.com</email>
    </author>
    <category term="StorageRegistry" />
    <category term="InitializeStorage" />
    <category term="StorageAdapter" />
    <category term="EntityRegistry" />
    <content type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I need to store my positions so that when my application starts up it can load the existing positions. The code I use is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
var dataPath = @&amp;quot;Data\&amp;quot; + _connectorAccount.AccountName;
_entityRegistry = new CsvEntityRegistry(dataPath);
_storageRegistry = new StorageRegistry
{
    DefaultDrive = new LocalMarketDataDrive(dataPath)
};

_connector.InitializeStorage(_entityRegistry, _storageRegistry);
_entityRegistry.Init();

_connector.StorageAdapter.DaysLoad = DateTime.Now.Subtract(_connectorAccount.StartTrading.Value);

_connector.StorageAdapter.Format = StorageFormats.Csv;
_connector.StorageAdapter.Load();

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem is that when I connect to TWS, I get the following error message:&lt;/p&gt;
&lt;p&gt;Message 'Connect,T(L)=2017/11/06 21:25:31.278,Error=At least one connection should be made.' caused processing error.&lt;/p&gt;
&lt;p&gt;with inner exception message:&lt;/p&gt;
&lt;p&gt;The given key was not present in the dictionary.&lt;/p&gt;
&lt;p&gt;and inner exception stack trace:&lt;/p&gt;
&lt;p&gt;at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary&lt;code&gt;2.get_Item(TKey key) at Ecng.Collections.SynchronizedDictionary&lt;/code&gt;2.get_Item(TKey key)
at StockSharp.Algo.Connector.ProcessConnectMessage(BaseConnectionMessage message)
at StockSharp.Algo.Connector.OnProcessMessage(Message message)&lt;/p&gt;
</content>
  </entry>
</feed>