Exemple #1
0
    def add_account(self, id, url, delta_minutes, notes, wave_url):
        try:
            delta = int(delta_minutes)
        except:
            delta = 0

        if account.by_id(id):
            self.redirect_message("Account %s already exists" % id)
            return
        acc = account.MyFXAccount(id=id, url=url, delta_minutes=delta, notes=notes, wave_url=wave_url)
        acc.put()
        # schedule account fetch
        account.schedule_fetch(id)
        self.redirect_message("Account %s created" % id)
Exemple #2
0
        for order in fetcher.orders[acc.orders:]:
            pair = fetcher.get ('symbol', order)
            rec = history.MyFXHistoryRecord (account = acc,
                                             open_at = history.parse_date (fetcher.get ('open date', order)),
                                             closed_at = history.parse_date (fetcher.get ('close date', order)),
                                             pair = pair,
                                             long = fetcher.get ('action', order) == "Buy",
                                             size = float (fetcher.get ('lots', order)),
                                             sl_price = float (fetcher.get ('sl', order)),
                                             tp_price = float (fetcher.get ('tp', order)),
                                             open_price = float (fetcher.get ('open price', order)),
                                             close_price = float (fetcher.get ('close price', order)),
                                             pips = float (fetcher.get ('pips', order)),
                                             profit = float (fetcher.get ('profit', order)),
                                             comment = fetcher.get ('comment', order))
            if not pair in pairs_map:
                pairs_map[pair] = 0
            rec.put ()
            pairs.add (pair)
            acc.orders += 1
            pairs_map[pair] += 1
    except:
        account.schedule_fetch (acc_id)
    acc.pairs_map = pickle.dumps (pairs_map)
    acc.put ()
    # wipe cache for affected pairs and update timestamp
    for pair in pairs:
        cache = history.HistoryDataCache (acc_id, pair)
        cache.delete ()
        account.set_last_update (acc_id, pair)