示例#1
0
            "____Placing SELL order: %f BTC for %f USD. Price %f____" %
            (sum_to_sell, sum_to_get, price))
        result = self.api.trade(pair, "sell", price, sum_to_sell,
                                shared_data.conn)
        print(result.received, result.remains, result.order_id)
        self.update_balance(prnt=True)
        self.next_action = "buy"


# Calculate start time for building average
start_time = now() - res_value * slow
#print("Lookback time:", dt.datetime.fromtimestamp(start_time))

# Fill in initial data from bitcoincharts.com
working_dataset = Data(res_value)
new_data, last_timestamp = dd.btccharts(start_time)
for value in new_data:
    time = value.split(',')[0]
    price = value.split(',')[1]
    working_dataset.append(time, price)

# Explicitly update dataset with last values
working_dataset.update(time, price)

# Record last price
shared_data.price = working_dataset.price[-1]

if shared_data.real_trading:
    # Activate trading object
    trade = Trading(keyfile, shared_data)
示例#2
0
        print("Error: file is empty.")
        sys.exit(1)

    # Read from the end and split into lines
    f.seek(-1*offset, os.SEEK_END)
    raw_data = f.read().decode()
    lines = raw_data.split('\n')
    # Get last line
    last_line = lines[-1]
    # If last line is empty
    if last_line == "":
        last_line = lines[-2]
        newline_before = False
    else:
        newline_before = True
    last_timestamp = int(last_line.split(',')[0])
    print("Last available point is at %s" % dt.datetime.fromtimestamp(last_timestamp))

new_data, newest_timestamp = datadownload.btccharts(last_timestamp)

# Append data to file
print("Appending %s lines to file. Last point is at %s" % (len(new_data), dt.datetime.fromtimestamp(newest_timestamp)))

with open(args.datafile_path, 'a') as f:
    for line in new_data:
        if newline_before:
            f.write("\n"+line)
        else:
            f.write(line+"\n")

示例#3
0
        print(dt_date(now()),
            "____Placing SELL order: %f BTC for %f USD. Price %f____"
            % (sum_to_sell, sum_to_get, price))
        result = self.api.trade(pair, "sell", price, sum_to_sell, shared_data.conn)
        print(result.received, result.remains, result.order_id)
        self.update_balance(prnt=True)
        self.next_action = "buy"


# Calculate start time for building average
start_time = now() - res_value * slow
#print("Lookback time:", dt.datetime.fromtimestamp(start_time))

# Fill in initial data from bitcoincharts.com
working_dataset = Data(res_value)
new_data, last_timestamp = dd.btccharts(start_time)
for value in new_data:
    time = value.split(',')[0]
    price = value.split(',')[1]
    working_dataset.append(time, price)

# Explicitly update dataset with last values
working_dataset.update(time, price)

# Record last price
shared_data.price = working_dataset.price[-1]

if shared_data.real_trading:
    # Activate trading object
    trade = Trading(keyfile, shared_data)
示例#4
0
        sys.exit(1)

    # Read from the end and split into lines
    f.seek(-1 * offset, os.SEEK_END)
    raw_data = f.read().decode()
    lines = raw_data.split('\n')
    # Get last line
    last_line = lines[-1]
    # If last line is empty
    if last_line == "":
        last_line = lines[-2]
        newline_before = False
    else:
        newline_before = True
    last_timestamp = int(last_line.split(',')[0])
    print("Last available point is at %s" %
          dt.datetime.fromtimestamp(last_timestamp))

new_data, newest_timestamp = datadownload.btccharts(last_timestamp)

# Append data to file
print("Appending %s lines to file. Last point is at %s" %
      (len(new_data), dt.datetime.fromtimestamp(newest_timestamp)))

with open(args.datafile_path, 'a') as f:
    for line in new_data:
        if newline_before:
            f.write("\n" + line)
        else:
            f.write(line + "\n")