SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Sep 18, 2024 7:01 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: More samples?
PostPosted: Mon Oct 18, 2010 6:02 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
I would appreciate a few more snippets and sample-code (or docs). Simple things, like for example a quote-filter block. Also, a sample marketdata and execution provider would be nice.

Do you plan on make the blocks, that are now only available in binary, editable? That way users could look at the code and either modify them to their needs or build new ones based on your code.


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Mon Oct 18, 2010 8:07 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

have you looked through this doc

http://www.smartquant.com/visualquant/d ... tation.pdf ?

There is a simple trade filter example discussed there. Something like this

Code:
using System;
using SmartQuant.Blocks;
using SmartQuant.Framework;

[Name("My Simple Filter")]
public class SimpleFilter : Block
{
  [Output("Good Trade")]
  public event OutputEventHandler GoodTrade;

  [Output("Bad Trade")]
  public event OutputEventHandler BadTrade;

  public SimpleFilter()
  {
  }

  [Input("Trade")]
  public void OnInput(EventInfo eventInfo, object data)
  {
    Trade trade = data as Trade;

    if (trade.Price > 0 && trade.Size > 0)
      GoodTrade(trade);
    else
      BadTrade(trade);
  }
}


Sure, we are planning to publish templates and actual source code examples for data and execution providers. We are finalizing FIX engine block / TT FIX provider this week and will write some docs regarding FIX as well.

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Tue Oct 19, 2010 6:32 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Thanks for that. What would also be helpful would be an example-block with buttons/labels on it (like the simple order-entry block that is now there in binary form).


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Thu Oct 21, 2010 7:01 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Some more questions:

How can i definde the type of the output of a block? It shows up as undefined or object, when i hover above it in the diagram. I see how to do it for inputs in the samples, but not for the output.

Will there or is there some sort of form designer, to arrange the GUI in the compiled application?


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Fri Oct 22, 2010 11:04 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

The type of an output is specified as a parameter of the attribute:

[Output("Report", typeof(ExecutionReport))]
public event OutputEventHandler ExecutionReport;

As to the blocks with some GUI inside, you should implement 2 things:
1) the block itself
2) GUI part - class that implements the SmartQuant.Blocks.IViewControl interface and derives from the System.Windows.Controls.UserControl class.

So, here is a sample of a block with 1 button that raises an event (signal) as soon as the button is clicked:

Block:
Code:
[Name("MyButton")]   
class ButtonBlock : Block
   {
      [Output("Click")]
      public event OutputEventHandler Signal;
      
      [ViewControl(ViewControlMode.Instance)]
      public ButtonControl myControl;

      [ParameterInput("Text", "Signal", false)]
      public string Text;

      public override void OnInit()
      {
         myControl.Init(Text);

         myControl.button.Click += new System.Windows.RoutedEventHandler(button_Click);
      }

      void button_Click(object sender, System.Windows.RoutedEventArgs e)
      {
         Signal(null);
      }
   }


GUI control (with one Button named "button" defined in xaml) :
Code:
public partial class ButtonControl : UserControl, IViewControl
   {
      public ButtonControl()
      {
         InitializeComponent();

         Key = "Button";

         DesiredWidth = 80;
         DesiredHeight = 30;
      }

      public void Init(string text)
      {
         button.Content = text;
      }

      #region IViewControl Members

      /// <summary>
      ///
      /// </summary>
      public object Key { get; private set; }

      public bool IsResizable
      {
         get { return true; }
      }
      
      /// <summary>
      ///
      /// </summary>
      public DockSite DockSite
      {
         get { return DockSite.Float; }
      }

      /// <summary>
      ///
      /// </summary>
      public double DesiredWidth { get; private set; }

      /// <summary>
      ///
      /// </summary>
      public double DesiredHeight { get; private set; }

      #endregion

   }


Please pay your attention that the instance of the ButtonControl class is defined in the MyButton class and is marked with the ViewControl attribute.

Regards,
Sergey.


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Fri Oct 22, 2010 4:57 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Hello,

thanks for the sample. However i have problems building it. I dont appear to have access to namespace System.Windows.Controls and type System.Windows.RoutedEventArgs from within VisualQuant.

Do i have to build this in VisualStudio?


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Fri Oct 22, 2010 5:12 pm 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

The best way is to develop the GUI control in VisualStudio, reference the result dll from the VQ ([Main Menu] -> Tools -> Optins, Build tab) and use it in the MyButton block which you develop in VQ. When developing GUI blocks you should probably need to reference at least the following .NET dlls - WindowsBase, PresentationFramework and PresentationCore (System.Windows.Controls and System.Windows.RoutedEventArgs are inside one of them).

Regards,
Sergey.


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Mon Oct 25, 2010 1:00 am 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Hi,

im still having problems with this. I made an even simpler usercontrol, with just a label on it. I implemented IViewcontrol as per your example above, and it builds fine in VS (im using vs2008 if this matters).

Here is the xaml and c# code of the usercontrol:

Code:
<UserControl x:Class="WpfControlLibrary1.UserControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="40" Width="60">
    <Grid Height="40" Width="60">
        <Label Name="label1" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50">Label</Label>
    </Grid>
</UserControl>


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using SmartQuant.Blocks;
using SmartQuant.Framework;

namespace WpfControlLibrary1
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl, IViewControl
    {
        public UserControl1()
        {
            InitializeComponent();

            Key = "Label";

            DesiredWidth = 200;
            DesiredHeight = 200;
        }

        public void Init(string text)
        {
            label1.Content = text;
        }

        public object Key { get; private set; }
        public bool IsResizable { get { return true; } }
        public DockSite DockSite { get { return DockSite.Float; } }
        public double DesiredWidth { get; private set; }
        public double DesiredHeight { get; private set; }
     }
}


And here is the block in vq:

Code:
using System;
using System.Windows;


using SmartQuant.Blocks;
using SmartQuant.Framework;

using WpfControlLibrary1;

[Name("MyLabel")]   
class LabelBlock : Block
{
   [ViewControl(ViewControlMode.Instance)]
   public UserControl1 myControl;

   [ParameterInput("Text", "defaultText")]
   public string Text;

   public override void OnInit()
   {
      myControl.Init("TestInit");
   }
}


The block builds in VQ too, but when i run the diagram i get a System.Reflection.TargetInvocationException.
Also, i dont appear to have access to the usercontrol members from inside the block. Thats probably the reason why i also get a NullReferenceException when the block tries to use the Init method of the usercontrol.

What am i doing wrong?


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Wed Oct 27, 2010 2:17 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
:(


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Wed Oct 27, 2010 6:40 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

it turned out that this issue is a bit more complex than we thought and we need some time to fix it. I hope we will publish an update tomorrow.

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Wed Oct 27, 2010 7:42 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Thanks for the update,
J.


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Mon Nov 01, 2010 4:24 pm 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Is there an update for this yet?


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Tue Nov 02, 2010 12:49 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

we are still fighting with this issue but I hope there will be an intermediate update tomorrow (or day after tomorrow). This update will include other interesting new features as well.

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Thu Nov 04, 2010 1:33 am 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6817
Hi,

we've published an update. You are welcome to download it from the same location.

Here is a link to the demo video

http://www.smartquant.com/visualquant/v ... trols.html

Regards,
Anton


Top
 Profile  
 
 Post subject: Re: More samples?
PostPosted: Thu Nov 04, 2010 5:27 am 
Offline

Joined: Wed Jul 18, 2007 3:39 pm
Posts: 36
Hi,

any chance you can upload the complete eventcounter sample somewhere? I cant find it in the vq-folder..

Regards,
J


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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