Manager
This function return the information if your algotrading is allowed to trade or not, it is controled by the manager class. |
|
This function will use the platform attribute to return the correct class between the options in the Class Platforms. |
|
This function will use the platform attribute to return the correct class between the options in the Class Platforms. |
|
This function will use the platform attribute to return the correct class between the options in the Class Platforms. |
|
This function will use the platform attribute to return the correct class between the options in the Class Platforms. |
|
This function is used to set the platform to the manager, the platform will be used for many functions to know witch class to return and more. |
|
These functions should be calling inside the while True looping, it is responsible to updates information like |
- class easyT.manager.Manager[source]
- _supervise_trading_time()[source]
It checks the trading time window to see if the algotrading is allowed to trade or if it should close opened position.
There is no need to inform this information, but keep in mid the Algotrading might not work as expected.
- Returns
It updates the trade class, informing if it is allowed to trade or not, and, close position if the time passed a determined time that you set to have position opened.
- _supervise_updates()[source]
This class call the updates for Tick and Rates if they exist, that mean, there are NOT None!
- Returns
It updates the Tick and Rates if possible.
- allowed_to_trade() bool [source]
This function return the information if your algotrading is allowed to trade or not, it is controled by the manager class.
- Returns
It returns True or False, True if your algotrading is allowed to trade or False if not.
- Raises
ClassNotInvoked() – The error occur when it tries tro return the trade._trade_allowed information before the trade be invoked, call the get_trade() first.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> # The Trade class need to be invoked to test the allowed_to_trade(), if it was not done, an error will >>> # occur >>> manager.allowed_to_trade() easyT.manager.ClassNotInvoked >>> manager.get_trade(symbol=symbol, lot=0.01, stop_loss=0.00, take_profit=0.00) <binanceSpotEasyT.trade.Trade object> >>> manager.allowed_to_trade() False
- get_initialize()[source]
This function will use the platform attribute to return the correct class between the options in the Class Platforms.
- Returns
It returns the class already invoked.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object>
- get_rates(count: int, symbol: str, timeframe: str)[source]
This function will use the platform attribute to return the correct class between the options in the Class Platforms.
- Parameters
symbol – The symbol you want to retrieve previous data.
timeframe (TimeFrame) – The timeframe you want information, like 1 minute, 5 minute, 1 week.
count – It is the amount of information in the past you want. If your time frame is 5 minutes and your count is 4, it will return 4 values containing time, open, high, low, close, tick_volume information of this past 4 candlesticks.
- Returns
It returns the class already invoked.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object> >>> manager.get_rates(symbol=symbol, count=20, timeframe='1m') <binanceSpotEasyT.rates.Rates object>
- get_tick(symbol: str)[source]
This function will use the platform attribute to return the correct class between the options in the Class Platforms.
- Parameters
symbol – It is the symbol you want information about. You can have information about time, bid, ask, last, volume.
- Returns
It returns the class already invoked.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object> >>> manager.get_tick(symbol=symbol) <binanceSpotEasyT.tick.Tick object>
- get_timeframe()[source]
This function will use the platform attribute to return the correct class between the options in the Class Platforms.
- Returns
It returns the class already invoked.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object> >>> manager.get_timeframe() <binanceSpotEasyT.timeframe.TimeFrame object>
- get_trade(symbol, lot, stop_loss, take_profit)[source]
This function will use the platform attribute to return the correct class between the options in the Class Platforms.
- Parameters
symbol – It is the symbol you want to open or close or check if already have an operation opened.
lot – It is how many shares you want to trade, many symbols allow fractions and others requires a certain amount. It can be 0.01, 100.0, 1000.0, 10000.0.
stop_loss – It is how much you accept to lose. Example: If you buy a share for US$10.00, and you accept to lose US$1.00 you set this variable at 1.00, you will be out of the operation at US$9.00 (sometimes more, somtime less, the US$9.00 is the trigger). Keep in mind that some symbols has different points metrics, US$1.00 sometimes can be 1000 points.
take_profit – It is how much you accept to win. Example: If you buy a share for US$10.00, and you accept to win US$1.00 you set this variable at 1.00, you will be out of the operation at US$11.00 (sometimes more, somtime less, the US$11.00 is the trigger). Keep in mind that some symbols has different points metrics, US$1.00 sometimes can be 1000 points.
- Returns
It returns the class already invoked.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object> >>> manager.get_trade(symbol=symbol, lot=0.01, stop_loss=0.00, take_profit=0.00) <binanceSpotEasyT.trade.Trade object>
- set_platform(platform: str) None [source]
This function is used to set the platform to the manager, the platform will be used for many functions to know witch class to return and more.
- Parameters
platform – It can be of type Platforms, or it can be a string. It is up to you to decide. The class Platform was created to reduce the errors possibilities when writing the correct name of the platform.
- Returns
It returns None, but it saves the platform in an attribute.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot'
- set_trading_time(time_trade_start: str, time_trade_stop: str, time_position_close: str)[source]
This function is responsible to set the trading time, when the time is in between the start and stop, trade is alowed, when in between in stop and position close, it is allowed to have a position opened, but it can not open a new one anymore.
After the position close, it closes the position.
Please, pay attention to the string time format, it uses a 24h format.
- Parameters
time_trade_start – The time that the algotrading can starts to trade.
time_trade_stop – The time that the algotrading stops to open position.
time_position_close – The time the algotrading closes opened position.
- Returns
It updates the atributes in constructors, returns None
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_trading_time(time_trade_start='09:00', time_trade_stop='17:30', time_position_close='17:45')
- supervise()[source]
These functions should be calling inside the while True looping, it is responsible to updates information like if the AlgoTrading is allowed to trade, if it needs to close the position, and to update the tick and the rates’ information.
- Returns:
It updates attribute values.
Examples
>>> from easyT.manager import Manager >>> symbol = 'BTCUSDT' >>> manager = Manager() >>> manager.set_platform('binance-spot') 'binance-spot' >>> manager.get_initialize() <binanceSpotEasyT.initialization.Initialize object> >>> # It is important to know that the supervise needs the time set. >>> manager.supervise() TypeError: '<=' not supported between instances of 'datetime.datetime' and 'NoneType' >>> manager.set_trading_time(time_trade_start='09:00', time_trade_stop='17:30', time_position_close='17:45') >>> # It is important to know that it do not only need the trading time, but also, it needs the Tick() class >>> # to retrieve the time! >>> manager.get_tick(symbol=symbol) <binanceSpotEasyT.tick.Tick object> >>> manager.supervise()