public enum TradeFileImportMode { Format1, Format2, NinjaTrader7, AccountsFile };public static void ImportHistoricalTrades(this WealthScript ws, string TradeFileName, string DateTimeFormat, TradeFileImportMode FileFormat, string AccountName="")
public static void SimTradeFile(this WealthScript ws, string TradeFileName, string DateTimeFormat) //one roundtrip per line public static void SimTradeFile2(this WealthScript ws, string TradeFileName, string DateTimeFormat) //one trade per line public static void SimTradeFile_NT(this WealthScript ws, string TradeFileName, string DateTimeFormat) //NinjaTrader7 filespublic void SimTradeFile(string TradeFileName, string DateTimeFormat) public void SimTradeFile2(string TradeFileName, string DateTimeFormat) public void SimTradeFile_NT(string TradeFileName, string DateTimeFormat)
Short;QQQQ;25-06-2009;36;25-06-2009;35.5;2000 Long;AAPL;12-05-2009;124;26-05-2009;130.4
AAPL;12-05-2009;Buy;124 AAPL;26-05-2009;Sell;130.4 QQQQ;25-06-2009;Short;36 QQQQ;25-06-2009;Cover;35.5
QQQQ;25-06-2009;Cover;35.5;100
QQQQ,12-01-2010 00:00:00,Buy,45.87 AA,25-11-2014 12:34:56,Buy,17.6
Trade-#,Instrument,Account,Strategy,Market pos.,Quantity,Entry price,Exit price,Entry time,Exit time,Entry name,Exit name,Profit,Cum. profit,Commission,MAE,MFE,ETD,Bars, 1,$AUDUSD,Backtest,ACE,Long,30000,0.7611,0.7646,8/1/2005 4:25:00 AM,8/2/2005 2:44:00 AM,Buy,Sell,0.00459860727893831,0.00459860727893835,0,0.00197083169097352,0.00972276967546967,0.00512416239653136,936, 2,$AUDUSD,Backtest,ACE,Long,30000,0.7611,0.7683,8/1/2005 4:25:00 AM,8/3/2005 7:53:00 AM,Buy,Sell,0.00945999211667321,0.014102102184218,0,0.00197083169097352,0.00972276967546967,0.000262777558796451,2131, 3,$AUDUSD,Backtest,ACE,Short,30000,0.7711,0.7612,8/4/2005 7:25:00 PM,8/9/2005 5:50:00 AM,Sell short,Buy to cover,0.0128388017118403,0.0271219579897215,0,0.00557644922837501,0.018155881208663,0.00531707949682271,2546,
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab;namespace WealthLab.Strategies { public class RealTradesDemo : WealthScript { protected override void Execute() { // One position (roundtrip) per line: this.ImportHistoricalTrades(@"C:\Data\Trades.csv", @"dd-MM-yyyy", TradeFileImportMode.Format1); //this.SimTradeFile(@"C:\Data\Trades.csv", @"dd-MM-yyyy"); // Try it with file containing the following lines: //Short,QQQQ,25-06-2009,36,25-06-2009,35.5 //Long,AAPL,12-05-2009,124,26-05-2009,130.4 // One trade per line: //this.ImportHistoricalTrades(@"C:\Data\Trades2.txt", @"dd-MM-yyyy", TradeFileImportMode.Format2); //this.SimTradeFile2(@"C:\Data\Trades2.txt", @"dd-MM-yyyy"); // Try it with file containing the following lines: //AAPL;12-05-2009;Buy;124 //AAPL;26-05-2009;Sell;130.4 //QQQQ;25-06-2009;Short;36 //QQQQ;25-06-2009;Cover;35.5 // Import from Accounts tool // Notes: // 1. Path is not used. Pass a string.Empty or anything // 2. Date/Time format string MUST be "dd-MM-yyyy HH:mm:ss" // 3. Optionally, specify account name e.g. "PaperAccount1" this.ImportHistoricalTrades(string.Empty, @"dd-MM-yyyy HH:mm:ss", TradeFileImportMode.AccountsFile); //this.ImportHistoricalTrades(string.Empty, @"dd-MM-yyyy HH:mm:ss", TradeFileImportMode.AccountsFile, "PaperAccount1"); // NinjaTrader files //this.ImportHistoricalTrades(@"C:\Data\Trades2.txt", @"dd-MM-yyyy", TradeFileImportMode.NinjaTrader7); //this.SimTradeFile_NT(@"C:\Data\Trades_NT7.txt", @"M/d/yyyy H:mm:ss tt"); } } }