SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Dec 07, 2019 8:12 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: IB AlgoStrategy
PostPosted: Fri Aug 09, 2019 4:28 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Hi,
we have updated IB provider to allow setup custom fields of AlgoStrategy. Release 1.0.7160.
Old code obsolete, because IB constantly changing their API for algos.

Reference API:
https://interactivebrokers.github.io/tws-api/ibalgos.html

Example usage in strategy:
Code:
using System;
using System.Collections.Generic;
using SmartQuant.IB.Messages;

using SmartQuant;

namespace OpenQuant
{
   //see IB docs for details:
   //https://interactivebrokers.github.io/tws-api/ibalgos.html
   
    public class IBAlgos : InstrumentStrategy
    {
      Order order_vwap;
      Order order_adaptive;
      
        public IBAlgos(Framework framework, string name)
            : base(framework, name)
        {
        }

      protected override void OnBar(Instrument instrument, Bar bar)
      {
         //
         if (order_adaptive == null)
         {
            order_adaptive = BuyOrder(instrument, 400, "IB-Adaptive");
            
            List<TagValue> values = new List<TagValue>();
            
            order_adaptive[SmartQuant.EFIXField.IBalgoStrategy] = "Adaptive";
            order_adaptive[SmartQuant.EFIXField.IBalgoParams] = values;
            
            values.Add(new TagValue() { Tag = "adaptivePriority", Value = "Normal" });
            
            Send(order_adaptive);
            
            return;
         }
         
         //
         if (order_vwap == null)
         {
            order_vwap = BuyOrder(instrument, 400, "IB-Vwap");
            
            List<TagValue> values = new List<TagValue>();
            
            order_vwap[SmartQuant.EFIXField.IBalgoStrategy] = "Vwap";
            order_vwap[SmartQuant.EFIXField.IBalgoParams] = values;
            
            values.Add(new TagValue() { Tag = "maxPctVol", Value = "0.1" });
            values.Add(new TagValue() { Tag = "startTime", Value = "09:00:00 CET" });
            values.Add(new TagValue() { Tag = "endTime", Value = "16:00:00 CET" });
            values.Add(new TagValue() { Tag = "allowPastEndTime", Value = "1" });
            values.Add(new TagValue() { Tag = "noTakeLiq", Value = "1" });
            values.Add(new TagValue() { Tag = "speedUp", Value = "1" });
            values.Add(new TagValue() { Tag = "monetaryValue", Value = "100000" });
            
            Send(order_vwap);
            
            return;
         }
        }
    }
}


As you can see, there are two required fields in algo order:
Code:
SmartQuant.EFIXField.IBalgoStrategy
SmartQuant.EFIXField.IBalgoParams


TagValue is placed in SmartQuant.IB.dll, therefore it requires a direct reference in strategy project:
Attachment:
ibalgo.png
ibalgo.png [ 9.51 KiB | Viewed 385 times ]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group