﻿<?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">initializestorage. StockSharp</title>
  <id>https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=initializestorage&amp;type=forum</id>
  <rights type="text">Copyright @ StockSharp Platform LLC 2010 - 2025</rights>
  <updated>2026-04-16T10:20:43Z</updated>
  <logo>https://stocksharp.com/images/logo.png</logo>
  <link href="https://stocksharp.com/handlers/atom.ashx?category=tag&amp;id=initializestorage&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">Hi&lt;br /&gt;&lt;br /&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;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;br /&gt;var dataPath = @&amp;quot;Data\&amp;quot; + _connectorAccount.AccountName;&lt;br /&gt;_entityRegistry = new CsvEntityRegistry(dataPath);&lt;br /&gt;_storageRegistry = new StorageRegistry&lt;br /&gt;{&lt;br /&gt;    DefaultDrive = new LocalMarketDataDrive(dataPath)&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;_connector.InitializeStorage(_entityRegistry, _storageRegistry);&lt;br /&gt;_entityRegistry.Init();&lt;br /&gt;&lt;br /&gt;_connector.StorageAdapter.DaysLoad = DateTime.Now.Subtract(_connectorAccount.StartTrading.Value);&lt;br /&gt;&lt;br /&gt;_connector.StorageAdapter.Format = StorageFormats.Csv;&lt;br /&gt;_connector.StorageAdapter.Load();&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The problem is that when I connect to TWS, I get the following error message:&lt;br /&gt;&lt;br /&gt;Message &amp;#39;Connect,T(L)=2017/11/06 21:25:31.278,Error=At least one connection should be made.&amp;#39; caused processing error.&lt;br /&gt;&lt;br /&gt;with inner exception message:&lt;br /&gt;&lt;br /&gt;The given key was not present in the dictionary.&lt;br /&gt;&lt;br /&gt;and inner exception stack trace:&lt;br /&gt;&lt;br /&gt;   at System.ThrowHelper.ThrowKeyNotFoundException()&lt;br /&gt;   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)&lt;br /&gt;   at Ecng.Collections.SynchronizedDictionary`2.get_Item(TKey key)&lt;br /&gt;   at StockSharp.Algo.Connector.ProcessConnectMessage(BaseConnectionMessage message)&lt;br /&gt;   at StockSharp.Algo.Connector.OnProcessMessage(Message message)&lt;br /&gt;&lt;br /&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">Hi&lt;br /&gt;&lt;br /&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;br /&gt;&lt;br /&gt;&lt;div class="code"&gt;&lt;strong&gt;Code&lt;/strong&gt;&lt;div class="innercode"&gt;&lt;br /&gt;var dataPath = @&amp;quot;Data\&amp;quot; + _connectorAccount.AccountName;&lt;br /&gt;_entityRegistry = new CsvEntityRegistry(dataPath);&lt;br /&gt;_storageRegistry = new StorageRegistry&lt;br /&gt;{&lt;br /&gt;    DefaultDrive = new LocalMarketDataDrive(dataPath)&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;_connector.InitializeStorage(_entityRegistry, _storageRegistry);&lt;br /&gt;_entityRegistry.Init();&lt;br /&gt;&lt;br /&gt;_connector.StorageAdapter.DaysLoad = DateTime.Now.Subtract(_connectorAccount.StartTrading.Value);&lt;br /&gt;&lt;br /&gt;_connector.StorageAdapter.Format = StorageFormats.Csv;&lt;br /&gt;_connector.StorageAdapter.Load();&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;The problem is that when I connect to TWS, I get the following error message:&lt;br /&gt;&lt;br /&gt;Message &amp;#39;Connect,T(L)=2017/11/06 21:25:31.278,Error=At least one connection should be made.&amp;#39; caused processing error.&lt;br /&gt;&lt;br /&gt;with inner exception message:&lt;br /&gt;&lt;br /&gt;The given key was not present in the dictionary.&lt;br /&gt;&lt;br /&gt;and inner exception stack trace:&lt;br /&gt;&lt;br /&gt;   at System.ThrowHelper.ThrowKeyNotFoundException()&lt;br /&gt;   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)&lt;br /&gt;   at Ecng.Collections.SynchronizedDictionary`2.get_Item(TKey key)&lt;br /&gt;   at StockSharp.Algo.Connector.ProcessConnectMessage(BaseConnectionMessage message)&lt;br /&gt;   at StockSharp.Algo.Connector.OnProcessMessage(Message message)&lt;br /&gt;&lt;br /&gt;</content>
  </entry>
</feed>