コード例 #1
0
ファイル: poll_price_event.py プロジェクト: canl/algo-trading
    def __init__(self,
                 instruments: list,
                 events: queue.Queue,
                 heartbeat: int = 10,
                 account: str = 'mt4'):
        """

        :param instruments: instrument list: ['GBP_USD', 'GBP_AUD', 'EUR_GBP', 'EUR_USD']
        :param events: shared event queue for processing the events
        :param heartbeat: frequency in seconds between polling
        :param account: trading account
        """
        self.instruments = instruments
        self.events = events
        self.heartbeat = heartbeat
        self.account_id = RUNNING_ENV.get_account(account)
コード例 #2
0
ファイル: api.py プロジェクト: canl/algo-trading
def valid_env(env):
    if env == 'live':
        if RUNNING_ENV.is_practice():
            RUNNING_ENV.load_config('live')
    elif env == 'practice':
        if RUNNING_ENV.is_live():
            RUNNING_ENV.load_config('practice')
    else:
        return {
            'error': f'Invalid env {env}! Env mush be either practice or live'
        }, HTTPStatus.BAD_REQUEST
コード例 #3
0
 def __init__(self,
              events: queue.Queue,
              instruments: list,
              feeds_loc: str,
              max_orders: int = 4,
              account: str = 'mt4',
              entry_adj: float = 0.0005,
              adj_btw_orders: float = 0.0025,
              expiry_hours: int = 3,
              risk_pct: float = 0.02,
              live_run: bool = False,
              heartbeat: int = 1):
     """
     Mean reversion auto trader
     :param events: Tick price event queue
     :param instruments: list of currency pairs
     :param feeds_loc: Location to read daily price feed
     :param max_orders: maximum order allowed for LONG or SHORT
     :param account: Oanda account name: primary or mt4
     :param entry_adj: entry adjustment, default to 5 pips
     :param adj_btw_orders: entry adjustment between orders, default to 25 pips
     :param expiry_hours: expiry hours for GTD trades (Good Till Date)
     :param risk_pct: risk percentage for each trade
     :param live_run: live or dry run, default to false
     """
     self.events = events
     self.instruments = instruments
     self.feeds_loc = feeds_loc
     self.max_orders = max_orders
     self.account_id = RUNNING_ENV.get_account(account)
     self.entry_adj = entry_adj
     self.adj_btw_orders = adj_btw_orders
     self.expiry_hours = expiry_hours
     self.risk_pct = risk_pct
     self.om = OrderManager(account)
     self.am = AccountManager(account)
     self.live_run = live_run
     self.heartbeat = heartbeat
     # Order stats initialization
     self.cache = self.initialize_cache()
コード例 #4
0
    logger.info(f'output feeds complete for [{instrument}]!')
    return pd_d


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="Output daily price feeds to CSV")
    parser.add_argument('--env',
                        action="store",
                        dest="env",
                        default='practice')
    parser.add_argument('--saveDir',
                        action="store",
                        dest="saveDir",
                        default='c:/temp/prices')
    args = parser.parse_args()
    if args.env == 'live':
        RUNNING_ENV.load_config('live')

    instruments = ('GBP_USD', 'EUR_USD', 'AUD_USD', 'USD_SGD', 'USD_JPY',
                   'GBP_AUD', 'USD_CAD', 'EUR_GBP', 'USD_CHF', 'BCO_USD')
    for inst in instruments:
        # Output feeds from 2020
        output_feeds(instrument=inst,
                     st=datetime(2020, 1, 1),
                     et=None,
                     short_win=20,
                     long_win=10,
                     ema_period=55,
                     save_dir=args.saveDir)
コード例 #5
0
 def __init__(self, account):
     self.account_id = RUNNING_ENV.get_account(account)
コード例 #6
0
ファイル: stream.py プロジェクト: yanwang217/algo-trading
 def __init__(self, instruments, callback, max_rec=None, account='mt4'):
     self.instruments = instruments
     self.max_rec = max_rec
     self.callback = callback
     self.account_id = RUNNING_ENV.get_account(account)