using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 StockSharp.Quik;
using StockSharp.Algo;
using StockSharp.BusinessEntities;
using StockSharp.Localization;
using StockSharp.Logging;
using StockSharp.Messages;
using MoreLinq;
using Ecng.Common;
using Ecng.Xaml;
using Ecng.ComponentModel;
using System.Security;
using System.Net;
namespace WpfApplication3
{
///
/// Логика взаимодействия для MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
QuikTrader connect;
private readonly LogManager logger = new LogManager();
private void button_Click_1(object sender, RoutedEventArgs e)
{
connect = new QuikTrader()
{
LuaLogin = "quik",
LuaPassword = "quik".To(),
LuaFixServerAddress = "127.0.0.1:5001".To()
};
var Listen = new FileLogListener("log.txt");
logger.Listeners.Add(Listen);
logger.Sources.Add(connect);
connect.Connected += () =>
{
Console.WriteLine("Подключено");
//textBlock.Text = "Подк";
};
connect.ConnectionError += ex =>
{
Console.WriteLine("Ошибка" + ex.ToString());
//textBlock.Text = "О";
};
connect.Disconnected += () =>
{
Console.WriteLine("Отключено");
//textBlock.Text = "От";
};
connect.TimeOut += () =>
{
Console.WriteLine("Истекло время ожидания");
// textBlock.Text = "и";
};
connect.NewPortfolios += portfolios => this.GuiAsync(() =>//подписываемя на событие получения нового портфеля
//
{
comboBox.ItemsSource = connect.Portfolios;
});
connect.NewSecurities += Securities => this.GuiAsync(() =>
{
comboBox1.ItemsSource = connect.Securities;
});
connect.Connect();
}
Order order1;
private void button1_Click(object sender, RoutedEventArgs e)
{
Order order1 = new Order()//создаем заявку
{ //заполняем поля заявки
Portfolio = (Portfolio)comboBox.SelectedItem,
Security = (Security)comboBox1.SelectedItem,
Price = decimal.Parse(textBox.Text),
Volume = 1,
Direction=Sides.Buy
};
connect.RegisterOrder(order1);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
//connect.CancelOrder()
}
}
}