예제 #1
0
 def generate_fill_type_field(self, trade):
     if trade['type'] == 'buy':
         return 'sell'
     elif trade['type'] == 'sell':
         return 'buy'
     else:
         raise NotATradeException("Trade is not a buy or sell", trade)
예제 #2
0
    def process_row(self, row):
        #  Binance XLSX file contains "overview" rows that aggregate trade activity, and
        #  header rows under each aggregate row.
        is_trade = self.is_row_a_trade(row)
        if not is_trade:
            if row['_extras']['Pair'] == 'Date(UTC)':
                raise NotATradeException("Binance trade is an Intermediate Overview Row and not a specific trade", row)
            else:
                self.set_current_trade_pair_and_type(row)
                raise NotATradeException("Binance trade is an Overview Row and not a specific trade", row)

        self.check_current_trade_pair_and_type()
        row['created_at'] = self.process_date(row)
        row['currency_pair'] = self.process_currency_pair()
        row['type'] = self.current_trade_type.lower()
        row['price'] = self.process_price(row)
        row['amount'] = self.process_amount(row)
        row['fill_amount'] = self.process_fill_amount(row)
        return row
예제 #3
0
    def process_row(self, row):
        if row['type'].lower() not in ['buy', 'sell']:
            raise NotATradeException("Gemini trade is not a buy or sell", row)

        if len(row['_extras']['Symbol']) > 6:
            raise Exception("Gemini currency is not three letters. \
                Refactor of gemini currency pair is needed: {}".format(row['_extras']['Symbol']))

        row['type'] = row['type'].lower()
        row['created_at'] = self.process_date(row)
        row['amount'] = self.process_amount(row)
        row['fill_amount'] = self.process_fill_amount(row)
        row['currency_pair'] = self.process_currency_pair(row)
        row['price'] = self.process_price(row)
        return row
예제 #4
0
    def process_row(self, row):
        if row['type'].lower() not in ['buy', 'sell']:
            raise NotATradeException("Gemini trade is not a buy or sell", row)

        if len(row['_extras']['Symbol']) > 6:
            raise Exception(
                "Gemini currency cannot be split evenly by 3: {}".format(
                    currency))

        row['type'] = row['type'].lower()
        row['created_at'] = self.process_date(row)
        row['amount'] = self.process_amount(row)
        row['fill_amount'] = self.process_fill_amount(row)
        row['currency_pair'] = self.process_currency_pair(row)
        row['price'] = self.process_price(row)
        return row
예제 #5
0
 def validate_trade_type(self, trade):
     if trade['type'] not in ['buy', 'sell']:
         raise NotATradeException("Trade is not a buy or sell", trade)