Example #1
0
 def trade(self, ticker: Ticker, ai: AI):
     logger.info(f'action=trade ticker={ticker.__dict__}')
     for duration in constants.DURATIONS:
         is_created = create_candle_with_duration(ticker.product_code, duration, ticker)
         if is_created and duration == settings.trade_duration:
             thread = Thread(target=self._trade, args=(ai,))
             thread.start()
Example #2
0
 def trade(self, ticker: Ticker, ai: AI):
     logger.info(f'action=trade ticker={ticker.__dict__}')
     for duration in constants.DURATIONS:
         is_created = create_candle_with_duration(ticker.product_code,
                                                  duration, ticker)
         # if true_range > 2 * atr and self.trade_duration == "15m":
         #     self.trade_duration = "5m"
         #     self.change_time = time.time()
         # elif true_range > 2 * atr and self.trade_duration == "5m":
         #     self.trade_duration = "1m"
         #     self.change_time = time.time()
         # if self.trade_duration == "1m" and time.time() - self.change_time > 840:
         #     self.trade_duration = "5m"
         #     self.change_time = time.time()
         # elif self.trade_duration == "5m" and time.time() - self.change_time > 3200:
         #     self.trade_duration = "15m"
         if is_created and duration == settings.trade_duration:
             thread = Thread(target=self._trade, args=(
                 ai,
                 ticker,
             ))
             thread.start()
Example #3
0
import app.models
from app.models.candle import create_candle_with_duration
from app.models.candle import factory_candle_class
from oanda.oanda import Ticker

import settings

logging.basicConfig(level=logging.INFO, stream=sys.stdout)


if __name__ == "__main__":

    now1 = datetime.timestamp(datetime(2020, 1, 1, 1, 0, 0))
    now2 = datetime.timestamp(datetime(2020, 1, 1, 1, 0, 1))
    now3 = datetime.timestamp(datetime(2020, 1, 1, 1, 0, 2))
    now4 = datetime.timestamp(datetime(2020, 1, 1, 1, 1, 0))

    # ticker = Ticker(settings.product_code, now1, 100, 100, 1)
    # create_candle_with_duration(settings.product_code, '1m', ticker)

    # ticker = Ticker(settings.product_code, now2, 110, 110, 1)
    # create_candle_with_duration(settings.product_code, '1m', ticker)

    # ticker = Ticker(settings.product_code, now3, 80, 80, 1)
    # create_candle_with_duration(settings.product_code, '1m', ticker)

    ticker = Ticker(settings.product_code, now4, 200, 200, 1)
    create_candle_with_duration(settings.product_code, '1m', ticker)

Example #4
0
 def trade(self, ticker: Ticker):
     logger.info(f'action=trade ticker={ticker.__dict__}')
     for duration in constants.DURATIONS:
         is_created = create_candle_with_duration(ticker.product_code, duration, ticker)
         print(is_created)