feat: переход на USDC + live mode

- spot.py: универсальная quote currency (USDT/USDC) вместо хардкода
- config.yaml: mode=live, testnet=false, BTC/USDC, 1 актив, $114 капитал

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
anor
2026-03-09 06:11:07 +10:00
co-authored by Claude Opus 4.6
parent ee46db896b
commit 7ad696673e
2 changed files with 24 additions and 47 deletions
+7 -31
View File
@@ -1,43 +1,19 @@
# RemizovTrader Configuration
mode: paper # paper | live
mode: live # paper | live
capital:
initial: 100.0
currency: USDT
initial: 114.0
currency: USDC
risk:
per_trade: 0.05 # 5% risk per trade ($100 capital)
per_trade: 0.05 # 5% risk per trade
max_position_pct: 0.50 # max 50% of equity in one position
max_open_positions: 3
max_open_positions: 1 # single asset, $114 capital
assets:
- ticker: BTC-USD
symbol: BTC/USDT
K: 2
corr_thresh: 0.5
trailing_stop: true
- ticker: ETH-USD
symbol: ETH/USDT
K: 2
corr_thresh: 0.5
trailing_stop: true
- ticker: AVAX-USD
symbol: AVAX/USDT
K: 2
corr_thresh: 0.5
trailing_stop: true
- ticker: LINK-USD
symbol: LINK/USDT
K: 2
corr_thresh: 0.5
trailing_stop: true
- ticker: SOL-USD
symbol: SOL/USDT
symbol: BTC/USDC
K: 2
corr_thresh: 0.5
trailing_stop: true
@@ -62,7 +38,7 @@ exchange:
data_source: exchange # "exchange" (ccxt/Bybit) or "yfinance"
api_key: "" # set via REMIZOV_API_KEY env var
api_secret: "" # set via REMIZOV_API_SECRET env var
testnet: true
testnet: false
web:
host: 0.0.0.0
+17 -16
View File
@@ -59,14 +59,15 @@ class SpotExecutor:
log.error(f"Price fetch {symbol} failed: {e}")
return None
def buy(self, symbol: str, usdt_amount: float) -> dict | None:
"""Market buy with specified USDT amount.
def buy(self, symbol: str, quote_amount: float) -> dict | None:
"""Market buy with specified quote currency amount.
Returns order dict or None on failure.
Does NOT retry on failure (prevents double orders).
"""
self._ensure_markets()
coin = symbol.split("/")[0]
quote = symbol.split("/")[1] # USDT, USDC, etc.
# 1. Get price
price = self.get_price(symbol)
@@ -75,7 +76,7 @@ class SpotExecutor:
# 2. Calculate amount
market = self.exchange.market(symbol)
amount = usdt_amount / price
amount = quote_amount / price
amount = float(self.exchange.amount_to_precision(symbol, amount))
# 3. Validate minimums
@@ -85,37 +86,37 @@ class SpotExecutor:
if amount < min_amount:
log.error(f"BUY {symbol}: amount {amount} < min {min_amount}")
return None
if usdt_amount < min_cost:
log.error(f"BUY {symbol}: cost ${usdt_amount:.2f} < min ${min_cost}")
if quote_amount < min_cost:
log.error(f"BUY {symbol}: cost ${quote_amount:.2f} < min ${min_cost}")
return None
# 4. Check balance (strict)
usdt_free = self.get_balance("USDT")
if usdt_free < usdt_amount:
quote_free = self.get_balance(quote)
if quote_free < quote_amount:
# Try to buy what we can afford
if usdt_free >= min_cost:
log.warning(f"BUY {symbol}: USDT {usdt_free:.2f} < requested {usdt_amount:.2f}, "
f"reducing to {usdt_free:.2f}")
usdt_amount = usdt_free
amount = usdt_amount / price
if quote_free >= min_cost:
log.warning(f"BUY {symbol}: {quote} {quote_free:.2f} < requested {quote_amount:.2f}, "
f"reducing to {quote_free:.2f}")
quote_amount = quote_free
amount = quote_amount / price
amount = float(self.exchange.amount_to_precision(symbol, amount))
else:
log.error(f"BUY {symbol}: USDT {usdt_free:.2f} < min ${min_cost}")
log.error(f"BUY {symbol}: {quote} {quote_free:.2f} < min ${min_cost}")
return None
# 5. Execute
ts = datetime.now(timezone.utc).isoformat()
if self.dry_run:
log.info(f"[DRY RUN] BUY {amount} {coin} @ ~${price:,.2f} "
f"(${usdt_amount:.2f}) at {ts}")
f"(${quote_amount:.2f}) at {ts}")
return {"dry_run": True, "side": "buy", "symbol": symbol,
"amount": amount, "price": price, "cost": usdt_amount}
"amount": amount, "price": price, "cost": quote_amount}
try:
order = self.exchange.create_market_buy_order(symbol, amount)
filled = float(order.get("filled", 0))
avg_price = float(order.get("average", price))
cost = float(order.get("cost", usdt_amount))
cost = float(order.get("cost", quote_amount))
log.info(f"BUY OK: {filled} {coin} @ ${avg_price:,.2f} "
f"(${cost:.2f}) order={order['id']}")
return order