using System;
using ZuluTradingSampleApp.Model;

namespace ZuluTradingSampleApp.Trading
{
    /// <summary>
    /// Available trading methods
    /// exposed by zulutrade, in case of an exception, exception's
    /// message will hold server's response if available
    /// </summary>
    public interface IZuluTradingGateway
    {

        /// <summary>
        /// Opens a market trade at current market rate, new trade will be assigned the uniqueId specified in this call
        /// so you are able to modify/close in the future
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="buy">buy BUY/SELL</param>
        /// <param name="requestedPrice">indicative price, ZuluTrade will open at current market rate</param>
        /// <param name="uniqueId">Id of the trading request, in case call is successful, you'll be able to close/modify the trade using this id</param>
        /// <returns>NewMarketTradeResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        NewMarketTradeResponseMessage OpenMarket(string currencyName, double lots, bool buy, double requestedPrice, string uniqueId);

        /// <summary>
        /// Opens a pending order, new pending order will be assigned the uniqueId specified in this call
        /// so you are able to modify/close in the future
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="lots">Volume in standard lots</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="requestedPrice">execution price</param>
        /// <param name="uniqueId">Id of the trading request, in case call is successful, you'll be able to close/modify the trade using this id</param>
        /// <returns>NewOrderResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        NewOrderResponseMessage OpenOrder(string currencyName, double lots, bool buy, double requestedPrice, string uniqueId);

        /// <summary>
        /// Cancels a pending order with the provided uniqueId
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="lots">Volume in standard lots</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="uniqueId">the id provided in relevant openOrder request</param>
        /// <returns>OrderCanceledResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        OrderCanceledResponseMessage CancelOrder(string currencyName, double lots, bool buy, string uniqueId);

        /// <summary>
        /// Closes a  market trade with the provided uniqueId
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="lots">Volume in standard lots</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="requestedPrice">indicative request price, Zulutrade will execute at current market rate</param>
        /// <returns>TradeClosedResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        TradeClosedResponseMessage CloseMarket(string currencyName, double lots, bool buy, string uniqueId, double requestedPrice);

        /// <summary>
        /// Updates the stop value of a pending order/market trade
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="stopValue">the new stop value</param>
        /// <returns>UpdateValueResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        UpdateValueResponseMessage UpdateStop(string currencyName, bool buy, double lots, string uniqueId, double stopValue);

        /// <summary>
        /// Updates the trailing stop value of a pending order/market trade
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="trailingStopValue">the trailing stop value</param>
        /// <returns>UpdateTrailingStopValueResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        UpdateTrailingStopValueResponseMessage UpdateTrailingStop(string currencyName, bool buy, double lots, string uniqueId, int trailingStopValue);

        /// <summary>
        /// Updates the traling stop value of a pending order/market trade when profit reaches a certain profit in pips
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="trailingStopValue">the trailing stop value</param>
        /// <param name="trailingStopConditionPips">the profit in pips. When this price is reached it will set the trailing stop</param>
        /// <returns>UpdateTrailingStopValueResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        UpdateTrailingStopValueResponseMessage UpdateTrailingStopCondition(string currencyName, bool buy, double lots, string uniqueId, int trailingStopValue, int trailingStopConditionPips);

        /// <summary>
        /// Updates the limit value of a pending order/market trade
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="limitValue">the new limit value</param>
        /// <returns>UpdateValueResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        UpdateValueResponseMessage UpdateLimit(string currencyName, bool buy, double lots, string uniqueId, double limitValue);

        /// <summary>
        /// Updates the entry of a pending order
        /// </summary>
        /// <param name="currencyName">The instrument name to be traded</param>
        /// <param name="buy">BUY/SELL</param>
        /// <param name="lots">lots Volume in standard lots</param>
        /// <param name="uniqueId">the id provided in relevant openOrder/openMarket request</param>
        /// <param name="entryValue">the new entry rate</param>
        /// <returns>UpdateValueResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        UpdateValueResponseMessage UpdateEntryRate(string currencyName, bool buy, double lots, string uniqueId, double entryValue);

        /// <summary>
        /// Returns the open market trades and pending orders in your account 
        /// </summary>
        /// <returns>OpenTradesResponseMessage</returns>
        OpenTradesResponseMessage GetOpenTrades();

        /// <summary>
        /// Returns the minimum amount and minimum amount step available for opening market trades and pending orders
        /// </summary>
        /// <returns>TradingConfigurationResponseMessage</returns>
        TradingConfigurationResponseMessage GetTradingConfiguration();

        /// <summary>
        /// Returns the provider's performance page statistics, if the account is a provider
        /// </summary>
        /// <returns>ProviderStatisticsResponseMessage</returns>
        ProviderStatisticsResponseMessage GetProviderStatistics();

        /// <summary>
        /// Returns the account's historic trades/orders that got closed between the given startDate and endDate
        /// </summary>
        /// <param name="startDate"> StartDate in format yyyy-MM-dd</param>
        /// <param name="endDate">EndDate in format yyyy-MM-dd</param>
        /// <returns>ClosedTradesResponseMessage</returns>
        /// <exception cref="Exception"></exception>
        ClosedTradesResponseMessage GetHistory(string startDate, string endDate);
    }
}
