RightEdge示范代码

Discussion in 'RightEdge' started by windspeedo, Feb 11, 2009.

  1. 这个帖子汇集RightEdge示范代码。方便大家查询、自学。
    需要注意,RightEdge还在不断前进,所以,有时候,一些早期的代码,可能需要根据最新的RightEdge架构适当修订。
     
  2. RightEdge下达交易指令后的跟踪处理。

    It looks like there is an error most of the time when you try to open a position. Use the following code to see what it is:
    Position pos = OpenPosition(...);
    if (pos.Error != null)
    {
    OutputMessage("order failed : " + pos.Error);
    }

    Also, you don't need to call PositionManager.GetPosition(ID), the return value from OpenPosition will be the same object.

    来源:dplaisted 对一个RightEdge-IB用户问题的回答。
     
  3. 浮动/跟踪止损/止盈指令的下达。

    When you open a position, you can create a PositionSettings object, and set the TrailingStop and TrailingStopType properties. This will cause the trailing stop to be created once the position is opened. If you would like to create or modify the trailing stop for an existing position, you can use the PositionManager.SetTrailingStop method. For example, to set a trailing stop of $1 on an existing position, you would use PositionManager.SetTrailingStop(pos.ID, 1, TargetPriceType.Price); The trailing stop type can also be Percentage instead of price, but your broker may or may not support that if you are trading live.

    You need to set the TrailingStop and the TrailingStop type on the order that is submitted to open the position, but the PositionSettings doesn't have properties for those values. The TrailingStop properties on PositionSettings are for the trailing stop to be used after the position is opened.

    来源:dplaisted
     
  4. 风哥很勤奋的,真是大好人!