﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/style.css'?>
<?xml-stylesheet type='text/css' href='https://stocksharp.ru/css/bbeditor.css'?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html">Storing positions</title>
  <id>~/topic/8797/storing-positions/</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-06-14T17:53:37Z</updated>
  <logo>https://stocksharp.ru/images/logo.png</logo>
  <link href="https://stocksharp.ru/handlers/atom.ashx?category=topic&amp;id=8797" rel="self" type="application/rss+xml" />
  <entry>
    <id>https://stocksharp.ru/posts/m/41574/</id>
    <title type="text">Yes, InitializeStorage will reset entire adapter settings. Including all inner adapters. </title>
    <published>2017-11-09T08:31:07Z</published>
    <updated>2017-11-09T08:31:07Z</updated>
    <author>
      <name>Support</name>
      <uri>https://stocksharp.ru/users/97869/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Yes, InitializeStorage will reset entire adapter settings. Including all inner adapters.&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41561/</id>
    <title type="text">Hi I think I found the problem. When I changed the code as follows, it worked: var adapter = _connec...</title>
    <published>2017-11-08T23:44:15Z</published>
    <updated>2017-11-08T23:44:15Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.ru/users/99799/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I think I found the problem. When I changed the code as follows, it worked:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
            var adapter = _connector.Adapter.InnerAdapters.OfType&amp;lt;InteractiveBrokersMessageAdapter&amp;gt;().First();

            _connector.InitializeStorage(_entityRegistry, _storageRegistry);

            _connector.Adapter.InnerAdapters.Add(adapter);

&lt;/code&gt;&lt;/pre&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41543/</id>
    <title type="text">Could you please send us small example for reproduce? support@stocksharp.com </title>
    <published>2017-11-08T12:39:58Z</published>
    <updated>2017-11-08T12:39:58Z</updated>
    <author>
      <name>Support</name>
      <uri>https://stocksharp.ru/users/97869/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <content type="html">&lt;p&gt;Could you please send us small example for reproduce? support@stocksharp.com&lt;/p&gt;
</content>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
  <entry>
    <id>https://stocksharp.ru/posts/m/41516/</id>
    <title type="text">Hi I need to store my positions so that when my application starts up it can load the existing posit...</title>
    <published>2017-11-06T22:30:01Z</published>
    <updated>2017-11-06T22:30:01Z</updated>
    <author>
      <name>Johan Kirsten</name>
      <uri>https://stocksharp.ru/users/99799/</uri>
      <email>info@stocksharp.ru</email>
    </author>
    <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>
    <rights type="html">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  </entry>
</feed>