Profile Picture

Export Closed Positions

Posted By phg 8 Years Ago
Message
phg
Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)
Posted Wednesday February 18 2009
The strategy I am currently working on makes an unconscionable number of trades in a day. It would be nice to able to examine the list more carefully in Excel after the market closes. But that means it would be nice to be able to export the list to an external file. (Unless it is already available in an xml file somewhere?) Thanks.

-Pete

See also Yahoo group about applying RE.

Posted Wednesday February 18 2009
We don't currently have support for this out of the box, but you can add it in your system.  In the OrderFilled event handler, check if the corresponding position is closed, and if so append the information you want to a closed positions file.

Thanks,
Daniel

phg
Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)
Posted Thursday February 19 2009
Thanks. That's a workable solution. But export of the grid to a csv file would be a convenience.Tongue

-Pete

See also Yahoo group about applying RE.

phg
Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)
Posted Friday February 20 2009

I need some help. The first four lines are trying to set things up (showing just the essential stuff). But ‘sw’ is not recognized in the event handler.

 

public class MySystem : MySystemBase

public StreamWriter sw;

 

public override void Startup()      <- Under MySystem

StreamWriter sw = new StreamWriter(@"C:\Documents and Settings….closedtrades.csv",true);

 

public override void OrderFilled(Position position, Trade trade)

sw.WriteLine(msg);   <- ‘sw’ does not exist in this context.

 

(Also:

public override void Shutdown()     <- Under MySysetm

sw.Close(); <- Runtime exception, ‘sw’ is not an instance   )

 

I am doing something not right, but what?

Thanks for your help.

-Pete

See also Yahoo group about applying RE.

Posted Friday February 20 2009
You are declaring a local sw that is masking your class level member variable.

Try this instead.

public override void Startup() <- Under MySystem
sw = new StreamWriter(@"C:\Documents and Settings….closedtrades.csv",true);
Posted Friday February 20 2009
Here is the problem:

StreamWriter sw = new StreamWriter(@"C:\Documents and Settings….closedtrades.csv",true);

You need to delete the first "StreamWriter" from this line.  Right now it is declaring a new variable with local scope, which means the class variable you created is not being set.

Also, since your sw variable is declared in your system class, to access it from your symbol script class (ie in the order filled method), you will need to first refer to the system class instance.  This is available via the TradingSystem property, so you can write "TradingSystem.sw.WriteLine(msg);".

Thanks,
Daniel

EDIT: Darnit, looks like Mark beat me by two minutes Smile

phg
Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)Supreme Being (48,337 reputation)
Posted Friday February 20 2009
Thank you both. Those suggestions did indeed fix the problem.

>Also, since your sw variable is declared in your system class, to access it from your symbol script class (ie in the order filled method), you will need to >first refer to the system class instance.  This is available via the TradingSystem property, so you can write "TradingSystem.sw.WriteLine(msg);".

Where else would it have been appropriate to make the declaration? "MySymbolScript" did not seem right?

-Pete

See also Yahoo group about applying RE.

Posted Friday February 20 2009
No you declared the sw variable in the right place.  You only want one per system so it should go in the system class.  But to access it from the symbol scripts you need to go through the TradingSystem property.

Thanks,
Daniel



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems