/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.Collections.Generic;
namespace QuantConnect.Packets
{
///
/// Packet for history jobs
///
public class HistoryPacket : Packet
{
///
/// The queue where the data should be sent
///
public string QueueName { get; set; }
///
/// The individual requests to be processed
///
public List Requests { get; set; } = new List();
///
/// Initializes a new instance of the class
///
public HistoryPacket()
: base(PacketType.History)
{
}
}
///
/// Specifies request parameters for a single historical request.
/// A HistoryPacket is made of multiple requests for data. These
/// are used to request data during live mode from a data server
///
public class HistoryRequest
{
///
/// The start time to request data in UTC
///
public DateTime StartTimeUtc { get; set; }
///
/// The end time to request data in UTC
///
public DateTime EndTimeUtc { get; set; }
///
/// The symbol to request data for
///
public Symbol Symbol { get; set; }
///
/// The requested resolution
///
public Resolution Resolution { get; set; }
///
/// The type of data to retrieve
///
public TickType TickType { get; set; }
}
///
/// Specifies various types of history results
///
public enum HistoryResultType
{
///
/// The requested file data
///
File,
///
/// The request's status
///
Status,
///
/// The request is completed
///
Completed,
///
/// The request had an error
///
Error
}
///
/// Provides a container for results from history requests. This contains
/// the file path relative to the /Data folder where the data can be written
///
public abstract class HistoryResult
{
///
/// Gets the type of history result
///
public HistoryResultType Type { get; private set; }
///
/// Initializes a new instance of the class
///
/// The type of history result
protected HistoryResult(HistoryResultType type)
{
Type = type;
}
}
///
/// Defines requested file data for a history request
///
public class FileHistoryResult : HistoryResult
{
///
/// The relative file path where the data should be written
///
public string Filepath { get; set; }
///
/// The file's contents, this is a zipped csv file
///
public byte[] File { get; set; }
///
/// Default constructor for serializers
///
public FileHistoryResult()
: base(HistoryResultType.File)
{
}
///
/// Initializes a new instance of the class
///
/// The relative file path where the file should be written, rooted in /Data, so for example ./forex/fxcm/daily/eurusd.zip
/// The zipped csv file content in bytes
public FileHistoryResult(string filepath, byte[] file)
: this()
{
Filepath = filepath;
File = file;
}
}
///
/// Specifies the completed message from a history result
///
public class CompletedHistoryResult : HistoryResult
{
///
/// Initializes a new instance of class
///
public CompletedHistoryResult()
: base(HistoryResultType.Completed)
{
}
}
///
/// Specfies an error message in a history result
///
public class ErrorHistoryResult : HistoryResult
{
///
/// Gets the error that was encountered
///
public string Message { get; set; }
///
/// Default constructor for serializers
///
public ErrorHistoryResult()
: base(HistoryResultType.Error)
{
}
///
/// Initializes a new instance of the class
///
/// The error message
public ErrorHistoryResult(string message)
: this()
{
Message = message;
}
}
///
/// Specifies the progress of a request
///
public class StatusHistoryResult : HistoryResult
{
///
/// Gets the progress of the request
///
public int Progress { get; set; }
///
/// Default constructor for serializers
///
public StatusHistoryResult()
: base(HistoryResultType.Status)
{
}
///
/// Initializes a new instance of the class
///
/// The progress, from 0 to 100
public StatusHistoryResult(int progress)
: this()
{
Progress = progress;
}
}
}