def main(argv): getEnv(argv) global cryptsyClient cryptsyClient = CryptsyPy(public, private) cryptsyClient.cancelAllOrders()
def main(argv): getEnv(argv) cryptsy_py = CryptsyPy(public=public, private=private) market_data = cryptsy_py.getMarkets() cryptsy_mongo = CryptsyMongo(host="192.168.1.33") last_trades = cryptsy_mongo.getLastTrades() if len(userMarketIds) > 0: market_ids = userMarketIds else: market_ids = set([int(last_trade['marketid']) for last_trade in last_trades]) for market_id in market_ids: market_name = next((market_name for market_name in market_data if int(market_data[market_name]) == market_id)) plot_diagram(market_name, market_id)
def main(argv): global public global private getEnv(argv) global cryptsy_client cryptsy_client = CryptsyPy(public, private) # cryptsy_mongo = CryptsyMongo(host="192.168.1.33") cryptsy_mongo = CryptsyMongo() recent_market_trends = cryptsy_mongo.getRecentMarketTrends() recent_trades = cryptsy_client.getRecentTrades() if recent_trades is not None: cryptsy_mongo.persistTrades(recent_trades) if hours is not None: start_time = toCryptsyServerTime(datetime.utcnow() - timedelta(hours=int(hours))) else: now = datetime.utcnow() start_time = toCryptsyServerTime(datetime(now.year, now.month, now.day)) total_buy_best = 0.0 total_sell_best = 0.0 total_fee_best = 0.0 print "Best markets:" mongotradeStats = cryptsy_mongo.getAllTradesFrom(start_time) filteredTradeStats = filter( lambda x: mongotradeStats[x]['Sell'] >= mongotradeStats[x]['Fee'] + mongotradeStats[x]['Buy'], mongotradeStats) sortedTradeStats = sorted(filteredTradeStats, key=lambda x: mongotradeStats[x]['Sell'] - mongotradeStats[x]['Buy'] - mongotradeStats[x][ 'Fee'], reverse=True) for tradeStat in sortedTradeStats: sell = float(mongotradeStats[tradeStat]['Sell']) buy = float(mongotradeStats[tradeStat]['Buy']) fee = float(mongotradeStats[tradeStat]['Fee']) total_buy_best += buy total_sell_best += sell total_fee_best += fee std = next((toEightDigit(market_trend.std) for market_trend in recent_market_trends if int(market_trend.marketId) == int(tradeStat)), None) print "MarketId: {}, Std:{}, Sell: {}, Buy: {}, Earn: {}".format(tradeStat, std, toEightDigit(sell), toEightDigit(buy), toEightDigit(sell - buy - fee)) print "Best markets total: buy: {}, sell: {}, fee:{} - earnings: {}".format(total_buy_best, total_sell_best, total_fee_best, total_sell_best - total_buy_best - total_fee_best) total_buy_worst = 0.0 total_sell_worst = 0.0 total_fee_worst = 0.0 print "Worst markets:" mongotradeStats = cryptsy_mongo.getAllTradesFrom(start_time) filteredTradeStats = filter( lambda x: 0 < mongotradeStats[x]['Sell'] < mongotradeStats[x]['Fee'] + mongotradeStats[x]['Buy'], mongotradeStats) sortedTradeStats = sorted(filteredTradeStats, key=lambda x: mongotradeStats[x]['Sell'] - mongotradeStats[x]['Buy'] - mongotradeStats[x][ 'Fee']) for tradeStat in sortedTradeStats: sell = float(mongotradeStats[tradeStat]['Sell']) buy = float(mongotradeStats[tradeStat]['Buy']) fee = float(mongotradeStats[tradeStat]['Fee']) total_buy_worst += buy total_sell_worst += sell total_fee_worst += fee std = next((toEightDigit(market_trend.std) for market_trend in recent_market_trends if int(market_trend.marketId) == int(tradeStat)), None) print "MarketId: {}, Std:{}, Sell: {}, Buy: {}, Earn: {}".format(tradeStat, std, toEightDigit(sell), toEightDigit(buy), toEightDigit(sell - buy - fee)) print "Worst markets total: buy: {}, sell: {}, fee:{} - earnings: {}".format(total_buy_worst, total_sell_worst, total_fee_worst, total_sell_worst - total_buy_worst - total_fee_worst) print "Total stats: total earning: {}".format( (total_sell_best + total_sell_worst) - (total_buy_best + total_buy_worst + total_fee_best + total_fee_worst))