Skip to content

Commit

Permalink
#12 Initial improvement of design, started fixing class names.
Browse files Browse the repository at this point in the history
  • Loading branch information
archonza committed Jun 22, 2019
1 parent 33f3a21 commit 1ec7c28
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,60 @@

namespace PublicAPIToolkit.Controllers.Toolkit.Tools
{
public class StandardTradeToolController : Controller
public class TradeToolController : Controller
{
public static TradeDataModel exchangeDataModel = new TradeDataModel();
public InfoModel infoModel;
public InfoController infoController;
//public InfoModel infoModel;
//public InfoController infoController;
public TradeOrderController tradeOrderController = new TradeOrderController();
private RestClientController restClientController;
private StandardTradeToolViewModel standardTradeToolViewModel = new StandardTradeToolViewModel();
private TradeToolViewModel tradeToolViewModel = new TradeToolViewModel();

public StandardTradeToolController()
public TradeToolController()
{
infoModel = new InfoModel();
/* Add info messages */
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.EntryGreaterThanTicker,
"Entry price is greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.EntryLessThanTicker,
"Entry price is less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.DetectEntrance,
"Detecting trade entrance." + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.DetectExit,
"Detecting trade exit." + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.BuyOrderEnteredEntryGreaterThanTicker,
"Trade was entered (BUY ORDER) with entry originally greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.BuyOrderEnteredEntryLessThanTicker,
"Trade was entered (BUY ORDER) with entry originally less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.SellOrderEnteredEntryGreaterThanTicker,
"Trade was entered (SELL ORDER) with entry originally greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.SellOrderEnteredEntryLessThanTicker,
"Trade was entered (SELL ORDER) with entry originally less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.ExitedWithProfit,
"Trade was exited with a profit." + " Target profit price: " + exchangeDataModel.ProfitTargetPrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoModel.infoMessageList.Add(new InfoMessage(
EInfoMessageId.ExitedWithLoss,
"Trade was exited with a loss." + " Stop loss price: " + exchangeDataModel.StopLossPrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
);
infoController = new InfoController(infoModel, @"E:\Test.txt");
//infoModel = new InfoModel();
///* Add info messages */
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.EntryGreaterThanTicker,
// "Entry price is greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.EntryLessThanTicker,
// "Entry price is less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.DetectEntrance,
// "Detecting trade entrance." + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.DetectExit,
// "Detecting trade exit." + " Ticker price: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.BuyOrderEnteredEntryGreaterThanTicker,
// "Trade was entered (BUY ORDER) with entry originally greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.BuyOrderEnteredEntryLessThanTicker,
// "Trade was entered (BUY ORDER) with entry originally less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.SellOrderEnteredEntryGreaterThanTicker,
// "Trade was entered (SELL ORDER) with entry originally greater than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.SellOrderEnteredEntryLessThanTicker,
// "Trade was entered (SELL ORDER) with entry originally less than ticker." + " Entrance price: " + exchangeDataModel.EntrancePrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.ExitedWithProfit,
// "Trade was exited with a profit." + " Target profit price: " + exchangeDataModel.ProfitTargetPrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoModel.infoMessageList.Add(new InfoMessage(
// EInfoMessageId.ExitedWithLoss,
// "Trade was exited with a loss." + " Stop loss price: " + exchangeDataModel.StopLossPrice + " TickerPrice: " + exchangeDataModel.TickerPrice + " Date/Time: " + DateTime.Now)
// );
//infoController = new InfoController(infoModel, @"E:\Test.txt");
}

// GET: DataAnalysisTool
Expand All @@ -75,9 +75,9 @@ public ActionResult Index()
}

[HttpPost]
public JsonResult Refresh(StandardTradeToolInputModel standardTradeToolInputModel)
public JsonResult Refresh(TradeToolInputModel tradeToolInputModel)
{
restClientController = new RestClientController(standardTradeToolInputModel.EndPoint, standardTradeToolInputModel.HttpMethod);
restClientController = new RestClientController(tradeToolInputModel.EndPoint, tradeToolInputModel.HttpMethod);
restClientController.MakeRequest();
//ECurrencyPair currencyPair = new ECurrencyPair();
//decimal tickerPrice = 0.0M;
Expand All @@ -89,26 +89,26 @@ public JsonResult Refresh(StandardTradeToolInputModel standardTradeToolInputMode
ECurrencyPair currencyPair = ECurrencyPair.NOT_SELECTED;
decimal amount = 0.0m;
ExchangeController.ProcessRawData(rawTicker, ref currencyPair, ref amount);
standardTradeToolViewModel.CurrencyPair = currencyPair.ToString();
standardTradeToolViewModel.Amount = amount;
return Json(standardTradeToolViewModel, JsonRequestBehavior.AllowGet);
tradeToolViewModel.CurrencyPair = currencyPair.ToString();
tradeToolViewModel.Amount = amount;
return Json(tradeToolViewModel, JsonRequestBehavior.AllowGet);
}

[HttpPost]
public string SubmitUserInput(StandardTradeToolInputModel standardTradeToolInputModel)
public string SubmitUserInput(TradeToolInputModel tradeToolInputModel)
{
TradeOrder tradeOrder = new TradeOrder();
tradeOrder.CurrencyPair = (ECurrencyPair)standardTradeToolInputModel.CurrencyPair;
tradeOrder.EntrancePrice = standardTradeToolInputModel.EntrancePrice;
tradeOrder.StopLossPrice = standardTradeToolInputModel.StopLossPrice;
tradeOrder.ProfitTargetPrice = standardTradeToolInputModel.ProfitTargetPrice;
tradeOrder.Quantity = standardTradeToolInputModel.Quantity;
tradeOrder.TrailingProfitTarget = standardTradeToolInputModel.TrailingProfitTarget;
tradeOrder.TrailingStopLoss = standardTradeToolInputModel.TrailingStopLoss;
tradeOrder.TradeOrderType = (ETradeOrderType)standardTradeToolInputModel.TradeOrderType;
tradeOrder.EntranceTolerance = standardTradeToolInputModel.EntranceTolerance;
tradeOrder.ProfitTargetTolerance = standardTradeToolInputModel.ProfitTargetTolerance;
tradeOrder.StopLossTolerance = standardTradeToolInputModel.StopLossTolerance;
tradeOrder.CurrencyPair = (ECurrencyPair)tradeToolInputModel.CurrencyPair;
tradeOrder.EntrancePrice = tradeToolInputModel.EntrancePrice;
tradeOrder.StopLossPrice = tradeToolInputModel.StopLossPrice;
tradeOrder.ProfitTargetPrice = tradeToolInputModel.ProfitTargetPrice;
tradeOrder.Quantity = tradeToolInputModel.Quantity;
tradeOrder.TrailingProfitTarget = tradeToolInputModel.TrailingProfitTarget;
tradeOrder.TrailingStopLoss = tradeToolInputModel.TrailingStopLoss;
tradeOrder.TradeOrderType = (ETradeOrderType)tradeToolInputModel.TradeOrderType;
tradeOrder.EntranceTolerance = tradeToolInputModel.EntranceTolerance;
tradeOrder.ProfitTargetTolerance = tradeToolInputModel.ProfitTargetTolerance;
tradeOrder.StopLossTolerance = tradeToolInputModel.StopLossTolerance;

tradeOrderController.AddTradeOrder(tradeOrder);

Expand Down Expand Up @@ -149,20 +149,20 @@ private void InitialiseTrade()
if (exchangeDataModel.EntrancePrice > exchangeDataModel.TickerPrice)
{
exchangeDataModel.EntryTickerCompare = EEntryTickerCompareType.EntryGreaterThanTicker;
infoController.Print(EInfoMessageId.EntryGreaterThanTicker);
//infoController.Print(EInfoMessageId.EntryGreaterThanTicker);
}
else
{
exchangeDataModel.EntryTickerCompare = EEntryTickerCompareType.EntryLessThanTicker;
infoController.Print(EInfoMessageId.EntryLessThanTicker);
//infoController.Print(EInfoMessageId.EntryLessThanTicker);
}
}
exchangeDataModel.TradeState = ETradeState.INACTIVE;
}

private void DetectTradeEntrance()
{
infoController.Print(EInfoMessageId.DetectEntrance);
//infoController.Print(EInfoMessageId.DetectEntrance);
/*
When this function is called for the first time, determine if when it is a buy order, whether
entrance price is greater that or less that ticker price in order to determine whether tolerance
Expand All @@ -184,7 +184,7 @@ should be set to be greater than entrance price or less than entrance price.

private void DetectTradeExit()
{
infoController.Print(EInfoMessageId.DetectExit);
//infoController.Print(EInfoMessageId.DetectExit);
DetectProfitTarget();
DetectStopLoss();
}
Expand All @@ -204,7 +204,7 @@ private void DetectBuyOrderTradeEntrance()
(exchangeDataModel.TickerPrice <= (exchangeDataModel.EntrancePrice +
exchangeDataModel.EntranceTolerance)))
{
infoController.Print(EInfoMessageId.BuyOrderEnteredEntryGreaterThanTicker);
//infoController.Print(EInfoMessageId.BuyOrderEnteredEntryGreaterThanTicker);
/* Enter trade */
exchangeDataModel.TradeState = ETradeState.ACTIVE;
exchangeDataModel.EntranceDateTime = DateTime.Now;
Expand All @@ -228,7 +228,7 @@ private void DetectBuyOrderTradeEntrance()
(exchangeDataModel.TickerPrice <= (exchangeDataModel.EntrancePrice +
exchangeDataModel.EntranceTolerance)))
{
infoController.Print(EInfoMessageId.BuyOrderEnteredEntryLessThanTicker);
//infoController.Print(EInfoMessageId.BuyOrderEnteredEntryLessThanTicker);
/* Enter trade */
exchangeDataModel.TradeState = ETradeState.ACTIVE;
exchangeDataModel.EntranceDateTime = DateTime.Now;
Expand Down Expand Up @@ -260,7 +260,7 @@ private void DetectSellOrderTradeEntrance()
exchangeDataModel.EntranceTolerance)) &&
(exchangeDataModel.TickerPrice <= exchangeDataModel.EntrancePrice))
{
infoController.Print(EInfoMessageId.SellOrderEnteredEntryGreaterThanTicker);
//infoController.Print(EInfoMessageId.SellOrderEnteredEntryGreaterThanTicker);
/* Enter trade */
exchangeDataModel.TradeState = ETradeState.ACTIVE;
exchangeDataModel.EntranceDateTime = DateTime.Now;
Expand All @@ -283,7 +283,7 @@ private void DetectSellOrderTradeEntrance()
if ((exchangeDataModel.TickerPrice >= exchangeDataModel.EntrancePrice) &&
(exchangeDataModel.TickerPrice <= (exchangeDataModel.EntrancePrice + exchangeDataModel.EntranceTolerance)))
{
infoController.Print(EInfoMessageId.SellOrderEnteredEntryLessThanTicker);
//infoController.Print(EInfoMessageId.SellOrderEnteredEntryLessThanTicker);
/* Enter trade */
exchangeDataModel.TradeState = ETradeState.ACTIVE;
exchangeDataModel.EntranceDateTime = DateTime.Now;
Expand All @@ -307,7 +307,7 @@ private void DetectProfitTarget()
if (exchangeDataModel.TickerPrice >= exchangeDataModel.ProfitTargetPrice)
{
exchangeDataModel.TradeState = ETradeState.INACTIVE;
infoController.Print(EInfoMessageId.ExitedWithProfit);
//infoController.Print(EInfoMessageId.ExitedWithProfit);
}
}
}
Expand All @@ -319,7 +319,7 @@ private void DetectStopLoss()
if (exchangeDataModel.TickerPrice <= exchangeDataModel.StopLossPrice)
{
exchangeDataModel.TradeState = ETradeState.INACTIVE;
infoController.Print(EInfoMessageId.ExitedWithLoss);
//infoController.Print(EInfoMessageId.ExitedWithLoss);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace PublicAPIToolkit.Models.InputModels.Toolkit.Tools
{
public class StandardTradeToolInputModel
public class TradeToolInputModel
{
public String EndPoint { get; set; } = String.Empty;
public UInt32 HttpMethod { get; set; } = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace PublicAPIToolkit.Models.ViewModels.Toolkit.Tools
{
public class StandardTradeToolViewModel
public class TradeToolViewModel
{
//public string Ticker { get; set; }
public string CurrencyPair { get; set; }
Expand Down
8 changes: 4 additions & 4 deletions PublicAPIToolkit/PublicAPIToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<Compile Include="Controllers\ExchangeController.cs" />
<Compile Include="Controllers\InfoController.cs" />
<Compile Include="Controllers\RestClientController.cs" />
<Compile Include="Controllers\Toolkit\Tools\StandardTradeToolController.cs" />
<Compile Include="Controllers\Toolkit\Tools\TradeToolController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="Controllers\Toolkit\ToolkitController.cs" />
<Compile Include="Controllers\TradeOrderController.cs" />
Expand All @@ -206,14 +206,14 @@
<Compile Include="Models\DomainModels\Trade\ETradeState.cs" />
<Compile Include="Models\InfoModel.cs" />
<Compile Include="Models\InputModels\Toolkit\ToolkitInputModel.cs" />
<Compile Include="Models\InputModels\Toolkit\Tools\StandardTradeToolInputModel.cs" />
<Compile Include="Models\InputModels\Toolkit\Tools\TradeToolInputModel.cs" />
<Compile Include="Models\ViewModels\DebugInformation.cs" />
<Compile Include="Models\ViewModels\Ticker.cs" />
<Compile Include="Models\TradeDataModel.cs" />
<Compile Include="Models\TickerModel.cs" />
<Compile Include="Models\UserInputModel.cs" />
<Compile Include="Models\ViewModels\Toolkit\ToolkitViewModel.cs" />
<Compile Include="Models\ViewModels\Toolkit\Tools\StandardTradeToolViewModel.cs" />
<Compile Include="Models\ViewModels\Toolkit\Tools\TradeToolViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -271,7 +271,7 @@
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\Toolkit\Index.cshtml" />
<Content Include="Views\StandardTradeTool\Index.cshtml" />
<Content Include="Views\TradeTool\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
Expand Down
4 changes: 2 additions & 2 deletions PublicAPIToolkit/Views/Toolkit/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
</script>
<div class="row">
<div class="col-md-2">
<ul><li>Standard Trade Tool:</li></ul>
<ul><li>t Trade Tool:</li></ul>
</div>
<div class="col-md-2">
<button class="btn-default" id="btn-standard-trade-tool" style="width:150px" onclick="location.href='@Url.Action("Index", "StandardTradeTool")#StandardTradeTool'">&laquo; START &raquo;</button>
<button class="btn-default" id="btn-standard-trade-tool" style="width:150px" onclick="location.href='@Url.Action("Index", "tTradeTool")#tTradeTool'">&laquo; START &raquo;</button>
</div>
</div>
Loading

0 comments on commit 1ec7c28

Please sign in to comment.