Profile Picture

RightEdge showing account value of simulation system instead of live system

Posted By geddie212 Last Year

RightEdge showing account value of simulation system instead of live...

Message
Crazy Posted Wednesday March 02 2016
I'm using a paper trading account provided by Interactive Brokers and I'm using the TWS. I have a blank system on RightEdge where the only thing that the system does is show the output message of the Account Value & Buying Power.

On Tools>Options>Live, I have ticked the Use Broker Account Balance box

On Both StartUp Methods I've added:
SystemData.UseBrokerAccountBalance = true;


Here is the full code of the empty strategy below, I've also added the using statements in case i'm missing a namespace or something. If more info is required, let me know. Cheers.

#region Using statements
using System;
using System.Drawing;
using System.Collections.Generic;
using RightEdge.Common;
using RightEdge.Common.ChartObjects;
using RightEdge.Indicators;
#endregion

#region System class
public class MySystem : MySystemBase
{
public override void Startup()
{
// Perform initialization or set system wide options here

   SystemData.UseBrokerAccountBalance = true;
}
}
#endregion

public class MySymbolScript : MySymbolScriptBase
{
public override void Startup()
{
SystemData.UseBrokerAccountBalance = true;

  OutputMessage(SystemData.SystemStatistics.CurStat.AccountValue.ToString());
  OutputMessage(SystemData.AccountValue.ToString());
  OutputMessage(SystemData.Broker.GetBuyingPower().ToString());
  OutputMessage(SystemData.SystemStatistics.CurStat.AccountValue.ToString());
}

public override void NewBar()
{
//
}

public override void OrderFilled(Position position, Trade trade)
{
// This method is called when an order is filled
}

public override void OrderCancelled(Position position, Order order, string information)
{
// This method is called when an order is cancelled or rejected
position.CloseAtMarket();
}
}



Posted Sunday March 13 2016
When RightEdge runs a live system, it can first simulate historical data so that you have some history when it starts processing live data.  Because of this, when the system is created, it doesn't use the live broker immediately.  It will switch to the live broker immediately before it starts sending you live data.

This means that in the Startup method, the AccountValue will still come from the simulation broker, not from the live broker.  You will need to wait until you start getting live ticks (check SystemData.LiveMode && !SystemData.InLeadBars) to get the account value from the broker.

FYI, by default the TWS plugin uses the "BuyingPower" value as the account value.  You may wish to use "NetLiquidation" instead.  You can change this behavior in the client_UpdateAccountValue method of the TWS Plugin.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems