← 返回

Unable to load existing position from storage

Hi

Using my application I opened a position in SPXW call. My application uses CSV storage, so it should have been stored. If I open my application the existing position does not get loaded. I have attached a console application that loads and connects using the storage my own application created. I have included the csv store in the zip file. It is in the bin/debug/data directory. Please look at the store. Did the position save to the store? If so, why does it not load? I also included the connector log in the bin/debug/logs directory.

Regards

评论 (5)

登录创建账户, 登录或注册以发表评论

Johan Kirsten
Johan Kirsten 作者

Hi

Is this problem related to not including this code:


_entityRegistry.DelayAction.DefaultGroup.WaitFlush(true);

in the application that must save the position? What does this code do?

Support
Support

Johan Kirsten: Hi

Is this problem related to not including this code:

_entityRegistry.DelayAction.DefaultGroup.WaitFlush(true);

> 
> in the application that must save the position? What does this code do?

We will investigate your archive later.

Yes, this line is necessary because saving process goes in parallel. You application can shut down before all changes will be flushed into disk.
Support
Support

Please use the following lines in your code:

_connector.NewPosition += _connector_NewPosition;
_connector.PositionChanged += _connector_PositionChanged;

private static void _connector_PositionChanged(StockSharp.BusinessEntities.Position obj)
{
	Console.WriteLine("_connector_PositionChanged:" + obj);
}

private static void _connector_NewPosition(StockSharp.BusinessEntities.Position obj)
{
	Console.WriteLine("_connector_NewPosition:" + obj);
}

After modification your sample with sent csv storage should display following output:

_connector_NewPortfolio:DU775642 _connector_NewPosition:DU775642-SPXW 171215C02580000@CBOE _connector_PositionChanged:DU775642-SPXW 171215C02580000@CBOE _connector_NewPosition:DU775642-SPXW 171215C02580000@ALL _connector_PositionChanged:DU775642-SPXW 171215C02580000@ALL _connector_NewPortfolio:DU229525 _connector_NewPosition:DU229525-AAPL@NASDAQ _connector_PositionChanged:DU229525-AAPL@NASDAQ

Portfolio - is only money position. To get position for security you should to use Position class instead.

Johan Kirsten
Johan Kirsten 作者

Hi

This will give me the position in the position collection of the _connector. But I need the mytrade loaded into the mytrade collection so that I can access the original user order id. Currently the mytrade collection does not load. How do I get it to load

Regards

Support
Support

Thank you for more details. The answer was provided my colleague by email.