/// <summary> /// Closes the trade if price crosses the upper/lower bollinger band. /// </summary> /// <param name="candles">candle history</param> /// <param name="bar">currentcandle</param> /// <param name="tradeManager">tradeManager</param> private void CloseTradeIfPossible(List <MarketCandle> candles, int bar, ITradeManager tradeManager) { var candle = candles[bar]; var bbands = new BollingerBands(candles, bar); // for long we close the trade if price gets above the upper bollinger bands if (_trade.TradeType == TradeType.Long && candle.HighPrice > bbands.Upper) { if (tradeManager.Close(_trade, candle.HighPrice)) { _state = StrategyState.Scanning; _trade = null; return; } } // for short we close the trade if price gets below the lowe bollinger bands if (_trade.TradeType == TradeType.Short && candle.LowPrice < bbands.Lower) { if (tradeManager.Close(_trade, candle.LowPrice)) { _state = StrategyState.Scanning; _trade = null; return; } } }
public StatisticsEvent(IUserManager userManager, IUserServiceStateManager userServiceStateManager, ITradeManager tradeManager, IFootPrintManager footPrintManager, IUserStatisticsManager userStatisticsManager, IFootPrintStatisticsManager footPrintStatisticsManager, IAddressBookManager addressBookManager, IAttentionStatisticsManager attentionStatisticsManager, ICallRecordManager callRecordManager, IInteractionStatisticsManager interactionStatisticsManager, IDockedManager dockedManager, IDockedStatisticsManager dockedStatisticsManager ) { _UserManager = userManager; _UserServiceStateManager = userServiceStateManager; _TradeManager = tradeManager; _FootPrintManager = footPrintManager; _UserStatisticsManager = userStatisticsManager; _FootPrintStatisticsManager = footPrintStatisticsManager; _AddressBookManager = addressBookManager; _AttentionStatisticsManager = attentionStatisticsManager; _CallRecordManager = callRecordManager; _InteractionStatisticsManager = interactionStatisticsManager; _DockedManager = dockedManager; _DockedStatisticsManager = dockedStatisticsManager; }
public TradeAppService(ITradeManager tradeManager, IRepository <FinanceAccount, long> financeAccount, ICacheManager cacheManager, IRepository <FinanceTradeDetail, long> financeTradeDetail) { _tradeManager = tradeManager; _financeAccount = financeAccount; _cacheManager = cacheManager; _financeTradeDetail = financeTradeDetail; }
public OrderAppService(ICustomerManager customerManager, IOrderRepository orderRepository, ICacheManager cacheManager, ITradeManager tradeManager) { _customerManager = customerManager; _orderRepository = orderRepository; _cacheManager = cacheManager; _tradeManager = tradeManager; }
public ServiceFactory( IAccessTokenRepository a1, ITradeManager a2 ) { accessTokenRepository = a1; tradeManager = a2; }
public override void Configuration(Action <StrategyOption> config) { var options = new StrategyOption(); config?.Invoke(options); _tradeManager = options.TradeManager ?? throw new ArgumentNullException(nameof(options.TradeManager)); _volumeBase = options.Volume ?? 1; }
public AlibabaTradeGetSellerOrderListService( IAccessToken a0, ITradeManager a1 ) { accessToken = a0; tradeManager = a1; }
public Trader( IStockCommunity stockCommunity, IMarketInfo marketInfo) { _marketInfo = marketInfo; stockCommunity.RegisterTrader(this); _tradeManager = new TradeManager(_marketInfo.SymbolInfo, DefaultBalance); }
public AlibabaCallbackMessageProcess( IAccessTokenRepository _accessTokenRepository , IAccessTokenManager _accessTokenManager , IDataSyncServiceRepository _dataSyncServiceRepository , ITradeManager _tradeManager ) { dataSyncServiceRepository = _dataSyncServiceRepository; tradeManager = _tradeManager; }
public AccessTokenAppService( IAccessTokenRepository repository , IAccessTokenManager accessTokenManager , IUnitOfWorkManager unitOfWorkManager , ITradeManager tradeManager ) : base(repository) { _accessTokenManager = accessTokenManager; base.UnitOfWorkManager = unitOfWorkManager; _tradeManager = tradeManager; }
public ServiceEvent( IMessageService messageService, ITradeManager tradeManager, IUserServiceStateRepository userServiceStateRepository, INotifyServiceProxy notifyServiceProxy) { _MessageService = messageService; _TradeManager = tradeManager; _UserServiceStateRepository = userServiceStateRepository; _NotifyServiceProxy = notifyServiceProxy; }
public DataSyncServiceManager( IAccessTokenManager _accessTokenManager, IDataSyncServiceRepository _dataSyncServiceRepository, ITradeManager _tradeManager, IAccessTokenRepository _accessTokenRepository ) { accessTokenManager = _accessTokenManager; dataSyncServiceRepository = _dataSyncServiceRepository; tradeManager = _tradeManager; accessTokenRepository = _accessTokenRepository; }
public void TestSetUp() { _container = new WindsorContainer(); RegisterDynamicInterceptor(); RegisterAllTypesInAssembly(); // Get the current implementation of ITradeManager from the IoC container. // We must use DI in order to add the dynamic proxy to the methods. _tradeManager = _container.Resolve <ITradeManager>(); }
public AccountController(IUserManager userManager, IMobileManager mobileManager, IClassesManager classesManager, ITradeManager tradeManager, IAreaManager areaManager) { _UserManager = userManager; _MobileManager = mobileManager; _ClassesManager = classesManager; _TradeManager = tradeManager; _AreaManager = areaManager; }
public AccountController(IUserManager userManager, IMobileManager mobileManager, IClassesManager classesManager, ITradeManager tradeManager, IAreaManager areaManager) { _UserManager = userManager; _MobileManager = mobileManager; _ClassesManager = classesManager; _TradeManager = tradeManager; _AreaManager = areaManager; }
public DataSyncServiceAppService( IDataSyncServiceRepository repository , IAccessTokenRepository accessTokenRepository , IAccessTokenManager accessTokenManager , IDataSyncServiceRepository dataSyncServiceRepository , ITradeManager tradeManager ) : base(repository) { _accessTokenRepository = accessTokenRepository; _accessTokenManager = accessTokenManager; _dataSyncServiceRepository = dataSyncServiceRepository; _tradeManager = tradeManager; }
/// <summary> /// Adds more to the current position by buying (or selling) more coins. /// </summary> /// <param name="tradeManager">tradeManager</param> /// <returns><c>true</c>, if rebuy was done, <c>false</c> otherwise.</returns> private bool DoRebuy(MarketCandle candle, decimal factor, ITradeManager tradeManager) { var investment = factor * _bundleSize; var coins = investment / candle.ClosePrice; switch (_trade.TradeType) { case TradeType.Long: return(tradeManager.BuyMore(_trade, coins)); case TradeType.Short: return(tradeManager.SellMore(_trade, coins)); } return(false); }
public AlibabaCallbackOnOrderPayJob( ICallbackMessageRepository _callbackMessageRepository, IAlibabaMessageRepository _alibabaMessageRepository, IAccessTokenRepository _accessTokenRepository, IDataSyncServiceRepository _dataSyncServiceRepository, IAlibabaProductCategoryRepository _alibabaProductCategoryRepository, ITradeManager _tradeManager, IOrderManager _orderManager, IUnitOfWorkManager _unitOfWorkManager) { callbackMessageRepository = _callbackMessageRepository; alibabaMessageRepository = _alibabaMessageRepository; accessTokenRepository = _accessTokenRepository; dataSyncServiceRepository = _dataSyncServiceRepository; alibabaProductCategoryRepository = _alibabaProductCategoryRepository; tradeManager = _tradeManager; orderManager = _orderManager; unitOfWorkManager = _unitOfWorkManager; }
public void Configuration(Action <TraderOptions> config) { var traderOptions = new TraderOptions(); config?.Invoke(traderOptions); if (traderOptions.Balance != null) { _tradeManager = new TradeManager(_marketInfo.SymbolInfo, traderOptions.Balance.Value); } _strategies = traderOptions.Strategies ?? Array.Empty <Strategy>(); foreach (var strategy in _strategies) { strategy.Configuration(strategyOption => { strategyOption.TradeManager = _tradeManager; strategyOption.Volume = 1; }); } }
public void Initialize() { manager = new TradeManager(new NullUnitOfWork()); players = new List <IGamePlayer> { new TurnPlayer("angel"), new TurnPlayer("joseph"), new TurnPlayer("tina"), new TurnPlayer("laura"), new TurnPlayer("larry"), }; players[0].SetWonder(WonderFactory.CreateWonder(WonderName.ColossusOfRhodes, WonderBoardSide.B)); players[1].SetWonder(WonderFactory.CreateWonder(WonderName.HangingGardensOfBabylon, WonderBoardSide.A)); players[2].SetWonder(WonderFactory.CreateWonder(WonderName.LighthouseOfAlexandria, WonderBoardSide.A)); players[3].SetWonder(WonderFactory.CreateWonder(WonderName.MausoleumOfHalicarnassus, WonderBoardSide.A)); players[4].SetWonder(WonderFactory.CreateWonder(WonderName.PyramidsOfGiza, WonderBoardSide.A)); CreateCards(); }
public DuelManager(ILogger <DuelManager> logger, IGameWorld gameWorld, ITradeManager tradeManager, IMovementManager movementManager, IHealthManager healthManager, IKillsManager killsManager, IMapProvider mapProvider, IInventoryManager inventoryManager, ITeleportationManager teleportationManager) { _logger = logger; _gameWorld = gameWorld; _tradeManager = tradeManager; _movementManager = movementManager; _healthManager = healthManager; _killsManager = killsManager; _mapProvider = mapProvider; _inventoryManager = inventoryManager; _teleportationManager = teleportationManager; _duelRequestTimer.Interval = 10000; // 10 seconds. _duelRequestTimer.Elapsed += DuelRequestTimer_Elapsed; _duelRequestTimer.AutoReset = false; _duelStartTimer.Interval = 5000; // 5 seconds. _duelStartTimer.Elapsed += DuelStartTimer_Elapsed; _duelStartTimer.AutoReset = false; #if DEBUG _logger.LogDebug("DuelManager {hashcode} created", GetHashCode()); #endif }
/// <summary> /// Initializes a new instance of the <see cref="HomeController"/> class. /// </summary> /// <param name="tradeManager">The trade manager.</param> /// <param name="profileManager">The profile manager.</param> /// <param name="userManager">The user manager.</param> /// <exception cref="ArgumentNullException"> /// tradeManager /// or /// profileManager /// or /// userManager /// </exception> public HomeController( ITradeManager tradeManager, IProfileManager profileManager, ApplicationUserManager userManager) { if (tradeManager == null) { throw new ArgumentNullException("tradeManager"); } if (profileManager == null) { throw new ArgumentNullException("profileManager"); } if (userManager == null) { throw new ArgumentNullException("userManager"); } _tradeManager = tradeManager; _profileManager = profileManager; _userManager = userManager; }
/// <summary> /// Scans for possibility to open a new trade. /// </summary> /// <param name="candles">candle history</param> /// <param name="bar">currentcandle</param> /// <param name="tradeManager">tradeManager</param> private void ScanForEntry(List <MarketCandle> candles, int bar, ITradeManager tradeManager) { TradeType tradeType; if (IsValidEntry(candles, bar, out tradeType)) { var candle = candles[bar]; var totalRebuy = 1m; if (MaxTimesRebuy >= 1) { totalRebuy += FirstRebuyFactor; } if (MaxTimesRebuy >= 2) { totalRebuy += SecondRebuyFactor; } if (MaxTimesRebuy >= 3) { totalRebuy += ThirdRebuyFactor; } _bundleSize = tradeManager.AccountBalance / totalRebuy; var coins = _bundleSize / candle.ClosePrice; switch (tradeType) { case TradeType.Long: _trade = tradeManager.BuyMarket(Symbol, coins); break; case TradeType.Short: _trade = tradeManager.SellMarket(Symbol, coins); break; } if (_trade != null) { _state = StrategyState.Opened; } } }
public MyntHostedService(ITradeManager tradeManager, MyntHostedServiceOptions options) { _tradeManager = tradeManager; _options = options ?? throw new ArgumentNullException(nameof(options)); }
public Character(ILogger <Character> logger, IDatabasePreloader databasePreloader, IGuildManager guildManager, ICountryProvider countryProvider, ISpeedManager speedManager, IStatsManager statsManager, IAdditionalInfoManager additionalInfoManager, IHealthManager healthManager, ILevelProvider levelProvider, ILevelingManager levelingManager, IInventoryManager inventoryManager, IStealthManager stealthManager, IAttackManager attackManager, ISkillsManager skillsManager, IBuffsManager buffsManager, IElementProvider elementProvider, IKillsManager killsManager, IVehicleManager vehicleManager, IShapeManager shapeManager, IMovementManager movementManager, ILinkingManager linkinManager, IMapProvider mapProvider, ITeleportationManager teleportationManager, IPartyManager partyManager, ITradeManager tradeManager, IFriendsManager friendsManager, IDuelManager duelManager, IBankManager bankManager, IQuestsManager questsManager, IUntouchableManager untouchableManager, IWarehouseManager warehouseManager, IShopManager shopManager, ISkillCastingManager skillCastingManager, ICastProtectionManager castProtectionManager, IGameSession gameSession, IGamePacketFactory packetFactory) : base(databasePreloader, countryProvider, statsManager, healthManager, levelProvider, buffsManager, elementProvider, movementManager, untouchableManager, mapProvider) { _logger = logger; _packetFactory = packetFactory; AdditionalInfoManager = additionalInfoManager; InventoryManager = inventoryManager; StealthManager = stealthManager; LevelingManager = levelingManager; SpeedManager = speedManager; AttackManager = attackManager; SkillsManager = skillsManager; KillsManager = killsManager; VehicleManager = vehicleManager; ShapeManager = shapeManager; LinkingManager = linkinManager; TeleportationManager = teleportationManager; PartyManager = partyManager; TradeManager = tradeManager; FriendsManager = friendsManager; DuelManager = duelManager; GuildManager = guildManager; BankManager = bankManager; QuestsManager = questsManager; WarehouseManager = warehouseManager; ShopManager = shopManager; SkillCastingManager = skillCastingManager; CastProtectionManager = castProtectionManager; GameSession = gameSession; HealthManager.MP_SP_Used += SendUseMPSP; HealthManager.OnCurrentHitpointsChanged += SendCurrentHitpoints; StatsManager.OnAdditionalStatsUpdate += SendAdditionalStats; StatsManager.OnResetStats += SendResetStats; BuffsManager.OnBuffAdded += SendAddBuff; BuffsManager.OnBuffRemoved += SendRemoveBuff; AttackManager.OnStartAttack += SendAttackStart; VehicleManager.OnUsedVehicle += SendUseVehicle; SkillsManager.OnResetSkills += SendResetSkills; InventoryManager.OnAddItem += SendAddItemToInventory; InventoryManager.OnRemoveItem += SendRemoveItemFromInventory; InventoryManager.OnItemExpired += SendItemExpired; AttackManager.TargetOnBuffAdded += SendTargetAddBuff; AttackManager.TargetOnBuffRemoved += SendTargetRemoveBuff; DuelManager.OnDuelResponse += SendDuelResponse; DuelManager.OnStart += SendDuelStart; DuelManager.OnCanceled += SendDuelCancel; DuelManager.OnFinish += SendDuelFinish; LevelingManager.OnExpChanged += SendExperienceGain; QuestsManager.OnQuestMobCountChanged += SendQuestCountUpdate; QuestsManager.OnQuestFinished += SendQuestFinished; ShopManager.OnUseShopClosed += SendUseShopClosed; ShopManager.OnUseShopItemCountChanged += SendUseShopItemCountChanged; ShopManager.OnSoldItem += SendSoldItem; Bless.Instance.OnDarkBlessChanged += OnDarkBlessChanged; Bless.Instance.OnLightBlessChanged += OnLightBlessChanged; }
public TradeAddMoneyHandler(IGamePacketFactory packetFactory, IGameSession gameSession, ITradeManager tradeManager, IGameWorld gameWorld) : base(packetFactory, gameSession) { _tradeManager = tradeManager; _gameWorld = gameWorld; }
public CommonDataController(IClassesManager classesManager, ITradeManager tradeManager, IAreaManager areaManager) { _ClassesManager = classesManager; _TradeManager = tradeManager; _AreaManager = areaManager; }
public TradeController(ITradeManager tradeManager) { _tradeManager = tradeManager; }
public TradeManager(ITradeManager tradeManager) { this.tradeManager = tradeManager; }
public TradeController(ITradeManager tradeManager) { _TradeManager =tradeManager; }
/// <summary> /// Perform strategy /// </summary> /// <param name="candles">candle history</param> /// <param name="bar">currentcandle</param> /// <param name="tradeManager">tradeManager</param> public void OnCandle(List <MarketCandle> candles, int bar, ITradeManager tradeManager) { switch (_state) { case StrategyState.Scanning: ScanForEntry(candles, bar, tradeManager); break; case StrategyState.Opened: CloseTradeIfPossible(candles, bar, tradeManager); if (_trade == null) { return; } if (MaxTimesRebuy >= 1) { if (CanRebuy(candles, bar)) { var candle = candles[bar]; if (DoRebuy(candle, FirstRebuyFactor, tradeManager)) { _state = StrategyState.Rebuy1; } } } break; case StrategyState.Rebuy1: CloseTradeIfPossible(candles, bar, tradeManager); if (_trade == null) { return; } if (MaxTimesRebuy >= 2) { if (CanRebuy(candles, bar)) { var candle = candles[bar]; if (DoRebuy(candle, SecondRebuyFactor, tradeManager)) { _state = StrategyState.Rebuy2; } } } break; case StrategyState.Rebuy2: CloseTradeIfPossible(candles, bar, tradeManager); if (_trade == null) { return; } if (MaxTimesRebuy >= 3) { if (CanRebuy(candles, bar)) { var candle = candles[bar]; if (DoRebuy(candle, ThirdRebuyFactor, tradeManager)) { _state = StrategyState.Waiting; } } } break; case StrategyState.Waiting: CloseTradeIfPossible(candles, bar, tradeManager); break; } }
public CommonDataController(IClassesManager classesManager,ITradeManager tradeManager,IAreaManager areaManager) { _ClassesManager = classesManager; _TradeManager = tradeManager; _AreaManager = areaManager; }
public MyntHostedService(ITradeManager tradeManager, IOptions <MyntHostedServiceOptions> options, ILogger <MyntHostedService> logger) { _logger = logger; _tradeManager = tradeManager; _options = options ?? throw new ArgumentNullException(nameof(options)); }