public BarRow(Timeframes tf, ITickDispatcher tickDisp, int insID) : this(tf, insID) { _tDisp = tickDisp; _insID = insID; _tDisp.Subscribe(this, insID, Td_Tick); }
public LeechApp(ILeechConfig config, IBotManager botManager, IBotsConfiguration botsConfig, ITickDispatcher tickDisp, IDataStorage dataStorage, IInstrumTable insTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable, IHoldingTable holdingTable, ICashTable positionTable, AccountTable accountTable, IInsStoreData insStoreData, ILogger logger) { _config = config; _scheduler = new Scheduler(logger); _botsConfig = botsConfig; _tickDispatcher = tickDisp; _botManager = botManager; _dataStorage = dataStorage; _accountTable = accountTable; _instrumTable = insTable; _orderTable = orderTable; _tradeTable = tradeTable; _stopOrderTable = stopOrderTable; _holdingTable = holdingTable; _cashTable = positionTable; _insStoreData = insStoreData; _logger = logger; _dataProtect = IoC.Resolve <DataProtect>(); _lpClientApp = new LpClientApp(_dataProtect, _instrumTable, _accountTable, _stopOrderTable, _orderTable, _tradeTable, _cashTable, _holdingTable, _tickDispatcher, _logger); _allTradesData = new AllTradesData(_instrumTable, _insStoreData, _logger); _alorTrade = new AlorTradeWrapper(_instrumTable, _stopOrderTable, _orderTable, _tradeTable, _holdingTable, _cashTable, _accountTable, _tickDispatcher, _config, _logger); }
public ChartController(ITickDispatcher tickDisp, LeechServerManager lsm, ChartSystem chartSys, IInstrumBL instrumBL) { _tickDisp = tickDisp; _lsm = lsm; _chartSystem = chartSys; _instrumBL = instrumBL; }
public BotManager(IBotsConfiguration botsConfig, ITickDispatcher tickDisp, ILogger logger) { _botsConfig = botsConfig ?? throw new ArgumentNullException("botsConfig"); _tickDispatcher = tickDisp; _logger = logger; _key_bots = new Dictionary <string, IBot>(); _bot_platform = new Dictionary <IBot, ILeechPlatform>(); }
/// <summary> /// Сохранение данных по всем сделкам для всех инструментов /// </summary> /// <param name="tickDispatcher">Диспетчер тиковых данных</param> /// <param name="sessionDbPath">Каталог данных текущей сессии (определяется датой)</param> public void SaveData(ITickDispatcher tickDispatcher, string sessionDbPath) { if (tickDispatcher == null) { throw new ArgumentNullException("tickDispatcher"); } if (string.IsNullOrWhiteSpace(sessionDbPath)) { throw new ArgumentException("SessionDbPath is empty, session not opened."); } _logger.AddInfo("AllTradesData", "Save data ..."); try { var allTradesDir = Path.Combine(sessionDbPath, "AllTrades"); if (!Directory.Exists(allTradesDir)) { Directory.CreateDirectory(allTradesDir); } var insIDs = tickDispatcher.GetInstrumIDs(); foreach (var insID in insIDs) { Instrum ins = _instrumTable.GetInstrum(insID); if (ins == null) { continue; } var ticks = tickDispatcher.GetTicks(insID); if (ticks == null || !ticks.Any()) { continue; } var encoder = new AllTradesEncoder(ins.Decimals); var persist = new AllTradesPersist(); persist.Initialize(allTradesDir, ins.Ticker); _insStoreData.InitInsStores(insID); foreach (Tick tick in ticks) { uint seconds = (uint)(tick.Time.Hour * 60 * 60 + tick.Time.Minute * 60 + tick.Time.Second); byte[] buf = encoder.AddTick(seconds, tick.Price, tick.Lots); persist.Write(buf); _insStoreData.AddTick(insID, tick.Time, tick.Price, tick.Lots); } persist.Close(); } _insStoreData.SaveData(); } catch (Exception ex) { _logger.AddException("AllTradesData", ex); } _logger.AddInfo("AllTradesData", "Data saved"); }
/// <summary> /// Используется для динамических графиков. /// То есть предусмотрено динамическое изменение цен. /// </summary> /// <param name="instrumBL">Подсистема фин. инструментов</param> /// <param name="td">Диспетчер потока данных по сделкам</param> public ChartManager(IInstrumBL instrumBL, IInsStoreBL insStoreBL, IAccountDA accountDA, ITickDispatcher td) { _instrumBL = instrumBL; _insStoreBL = insStoreBL; _accountDA = accountDA; _tickDispatcher = td; _depManager = new DependencyManager(); _factory = new Factory(_srcProv, _depManager); _isDynamic = true; }
public ChartSystem(IChartDA chartDA, IInstrumBL instrumBL, IInsStoreBL insStoreBL, IAccountDA accountDA, IRepositoryBL reposBL, ChartManagerCache cmCache, ITickDispatcher tickDisp) { _chartDA = chartDA; _instrumBL = instrumBL; _insStoreBL = insStoreBL; _accountDA = accountDA; _reposBL = reposBL; _cmCache = cmCache; _tickDisp = tickDisp; }
public LpClientApp(DataProtect dataProtect, IInstrumTable instrumTable, IAccountTable accountTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable, ICashTable positionTable, IHoldingTable holdingTable, ITickDispatcher tickDisp, ILogger logger) { _dataProtect = dataProtect; _socket = new LpClientSocket(); _core = new LpCore(_socket, false); // клиент _pipeFactory = new LpAppFactory(_core, instrumTable, accountTable, stopOrderTable, orderTable, tradeTable, positionTable, holdingTable, tickDisp); _sysPipe = new SystemLp(_pipeFactory, _core); _logger = logger; }
public LpAppFactory(ILpCore core, IInstrumTable instrumTable, IAccountTable accountTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable, ICashTable positionTable, IHoldingTable holdingTable, ITickDispatcher tickDisp) { _core = core; _instrumTable = instrumTable; _accountTable = accountTable; _stopOrderTable = stopOrderTable; _orderTable = orderTable; _tradeTable = tradeTable; _positionTable = positionTable; _holdingTable = holdingTable; _tickDisp = tickDisp; }
public void CloseBarRow() { if (_tSource != null) { _tSource.OnTick -= TSource_Tick; } if (_tDisp != null) { _tDisp.Unsubscribe(this, _insID); } _tSource = null; _tDisp = null; }
public LeechPlatform(ITickDispatcher tickDisp, IInstrumTable insTable, IHoldingTable holdTable, IOrderTable orderTable, IAccountTable accountTable, AlorTradeWrapper alorTrade, ILogger logger, IInsStoreBL insStoreBL, ILeechConfig leechConfig) { _tickDisp = tickDisp; _instrumTable = insTable; _holdingTable = holdTable; _orderTable = orderTable; _accountTable = accountTable; _alorTrade = alorTrade; _logger = logger; _insStoreBL = insStoreBL; _leechConfig = leechConfig; _barRows = new List <BarRow>(); _onTimer = null; _onTimerTask = null; _ins_onTick = new Dictionary <int, OnTickDelegate>(); _insID_pm = new Dictionary <int, IPosManager>(); }
public AlorTradeWrapper(IInstrumTable insTable, IStopOrderTable stopOrderTable, IOrderTable orderTable, ITradeTable tradeTable, IHoldingTable holdingTable, ICashTable positionTable, IAccountTable accountTable, ITickDispatcher tickDisp, ILeechConfig config, ILogger logger) { _instrumTable = insTable; _stopOrderTable = stopOrderTable; _orderTable = orderTable; _tradeTable = tradeTable; _holdingTable = holdingTable; _positionTable = positionTable; _accountTable = accountTable; _tickDispatcher = tickDisp; _leechConfig = config; _logger = logger; _secBoard = _leechConfig.SecBoard; _addHours = _leechConfig.CorrectHours; _startSessionMskTime = _leechConfig.StartSessionMskTime; _endSessionMskTime = _leechConfig.EndSessionMskTime; }
public SchedulerService(ITickDispatcher tickDisp, ChartManagerCache cmCache, ILogger <SchedulerService> logger, IConfiguration config, IServiceProvider services, Scheduler scheduler) { _tickDisp = tickDisp; _cmCache = cmCache; _services = services; _logger = logger; _scheduler = scheduler; var section = config.GetSection("Scheduler"); if (section != null) { var tasks = section.GetSection("tasks"); if (tasks != null) { foreach (var task in tasks.GetChildren()) { int time; if (!int.TryParse(task["time"], out time)) { continue; } string action = task["action"]; if (action.ToLower() == "initialize") { _scheduler.AddItem(time, OpenSession); } } } var delaySection = section.GetSection("downloadall-timeout"); int timeout; if (int.TryParse(delaySection.Value, out timeout)) { _downloadAllTimeout = timeout; } } }
public TickPipe(ILpCore core, ITickDispatcher tickDisp, IInstrumTable instrumTable) { _core = core; _tickDisp = tickDisp; _instrumTable = instrumTable; }