-
Notifications
You must be signed in to change notification settings - Fork 343
/
CurrencyMoveExplorer.cs
102 lines (76 loc) · 3.13 KB
/
CurrencyMoveExplorer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Your rights to use code governed by this license https://github.com/AlexWan/OsEngine/blob/master/LICENSE
* Ваши права на использование кода регулируются данной лицензией http://o-s-a.net/doc/license_simple_engine.pdf
*/
using OsEngine.Entity;
using OsEngine.OsTrader.Panels;
using OsEngine.OsTrader.Panels.Attributes;
using OsEngine.OsTrader.Panels.Tab;
using System;
using System.Threading;
namespace OsEngine.Robots.CurrencyArbitrage
{
[Bot("CurrencyMoveExplorer")]
public class CurrencyMoveExplorer : BotPanel
{
public CurrencyMoveExplorer(string name, StartProgram startProgram) : base(name, startProgram)
{
TabCreate(BotTabType.Polygon);
_tabPolygon = this.TabsPolygon[0];
_tabPolygon.ProfitGreaterThanSignalValueEvent += _tabPolygon_ProfitGreaterThanSignalValueEvent;
Regime = CreateParameter("Regime", "Off", new[] { "Off", "On" });
Thread worker = new Thread(ThreadWorkerArea);
worker.Start();
Description = "Robot for research. Saves slices of the situation on the bundle of instruments within 3 seconds after receiving a signal that there is profit on the sequence.";
}
public override string GetNameStrategyType()
{
return "CurrencyMoveExplorer";
}
public override void ShowIndividualSettingsDialog()
{
}
private BotTabPolygon _tabPolygon;
public StrategyParameterString Regime;
private void _tabPolygon_ProfitGreaterThanSignalValueEvent(decimal profit, PolygonToTrade sequence)
{
if (Regime.ValueString == "Off")
{
return;
}
if(_polygonToWatch != null)
{
return;
}
_lastTimePolygonStartWatch = DateTime.Now;
_polygonToWatch = sequence;
DateTime time = DateTime.Now;
string message = "Start watch " + _polygonToWatch.SecuritiesInSequence + "\n";
message += "Start profit " + profit.ToString();
SendNewLogMessage(message, Logging.LogMessageType.System);
}
PolygonToTrade _polygonToWatch;
DateTime _lastTimePolygonStartWatch;
private void ThreadWorkerArea()
{
while(true)
{
Thread.Sleep(200);
if(_polygonToWatch == null)
{
continue;
}
if(_lastTimePolygonStartWatch.AddSeconds(3) < DateTime.Now)
{
SendNewLogMessage("End watch " + _polygonToWatch.SecuritiesInSequence, Logging.LogMessageType.System);
_polygonToWatch = null;
continue;
}
DateTime time = DateTime.Now;
string message = time.ToLongTimeString() + "." + time.Millisecond;
message += "Profit: " + _polygonToWatch.ProfitToDealPercent.ToString();
SendNewLogMessage(message, Logging.LogMessageType.System);
}
}
}
}