MCPcopy Create free account

hub / github.com/ConteurShadow/Polymarket-Trading-Bot-Rust / functions

Functions284 in github.com/ConteurShadow/Polymarket-Trading-Bot-Rust

↓ 2 callersMethodhas_active_position
Returns true if we have an unsold position of the same type (BTC or ETH) in this period Note: - Trades with failed redemptions (redemption_abandoned =
src/trader.rs:203
↓ 2 callersMethodhas_position
Check if a position exists for a given token_id
src/simulation.rs:747
↓ 2 callersFunctioninit_history_file
(file: File)
src/bin/main_dual_limit_045_5m_btc.rs:61
↓ 2 callersFunctioninit_history_file
(file: File)
src/bin/main_dual_limit_045_same_size.rs:97
↓ 2 callersFunctionload_price_history
Load price history from a file
src/backtest.rs:232
↓ 2 callersMethodlog_market_end
Log market end event
src/simulation.rs:919
↓ 2 callersFunctionlog_to_history
(message: &str)
src/bin/main_dual_limit_045_same_size.rs:101
↓ 2 callersMethodmark_cycle_completed
Mark that a buy-sell cycle completed for a token type After this, the price must drop below trigger_price before allowing another buy
src/detector.rs:606
↓ 2 callersFunctionpost_limit_order
Post limit order. Returns order_id on success.
src/clob_sdk.rs:304
↓ 2 callersFunctionpost_market_order
Post market order. amount_is_usdc: true = amount in pUSD (collateral notional), false = amount in shares. order_type: "FOK" or "FAK".
src/clob_sdk.rs:359
↓ 2 callersFunctionprint_market_found
After resolving an active up/down market (both outcomes trade under this condition).
src/term_ui.rs:219
↓ 2 callersFunctionprint_rule_dim
()
src/term_ui.rs:145
↓ 2 callersMethodresolve_market_positions
Calculate final PnL when a market resolves Resolves all positions for a given condition_id based on market outcome Returns: (total_spent, total_earned
src/simulation.rs:788
↓ 2 callersFunctionsection_bar
Full-width bar with centered title (total width = [`FRAME_INNER`]).
src/term_ui.rs:57
↓ 2 callersMethodset_approval_for_all_clob
Approve the CLOB contract for ALL conditional tokens using CTF contract's setApprovalForAll() This is the recommended way to avoid allowance errors fo
src/api.rs:1201
↓ 2 callersMethodsigner
(&self)
src/api.rs:159
↓ 2 callersFunctionstrip_ansi_for_file
Strip ANSI escapes for history files and structured logs.
src/term_ui.rs:12
↓ 2 callersMethodsync_pending_trades_from_simulation
In simulation mode: sync pending_trades so that any limit order that the simulation tracker has marked filled (has a position) is reflected as buy_ord
src/trader.rs:1375
↓ 2 callersMethodsync_trades_with_portfolio
Sync pending trades with actual portfolio balance Checks if tokens are still in portfolio - if balance is 0, mark as sold (already redeemed) This prev
src/trader.rs:400
↓ 1 callersMethodadd_auth_header
Add JWT token to request if available
src/bin/test_predict_fun.rs:150
↓ 1 callersMethodadd_market_buy_position
Record a market buy as filled immediately in simulation (no limit order; position created at fill_price).
src/simulation.rs:215
↓ 1 callersMethodadd_price
Add a new price snapshot
src/simulation.rs:1049
↓ 1 callersFunctionbacktest_period
Run backtest for a single period
src/backtest.rs:338
↓ 1 callersMethodcalculate_unrealized_pnl
Calculate unrealized PnL for all open positions
src/simulation.rs:665
↓ 1 callersMethodcancel_limit_order
Cancel a simulated limit order (removes it from pending tracking)
src/simulation.rs:199
↓ 1 callersMethodcancel_order
Cancel a specific order by order id (CLOB). Uses REST DELETE with HMAC auth (clob_sdk has no cancel).
src/api.rs:763
↓ 1 callersMethodcheck_pending_trades
Check pending trades and sell when price reaches sell_price (0.99 or 1.0) Also handles limit order fills: detects when limit buy orders fill and place
src/trader.rs:1402
↓ 1 callersFunctionclient_create
Create authenticated CLOB client. Returns handle (non-zero) on success. funder: None for EOA; Some(proxy_wallet_address) for proxy/safe. signature_typ
src/clob_sdk.rs:224
↓ 1 callersFunctionclob_sdk_candidate_paths
()
src/clob_sdk.rs:54
↓ 1 callersMethodcreate_l1_headers
(&self)
src/api.rs:211
↓ 1 callersFunctiondecimal_to_f64
Helper function for Decimal to f64 conversion
src/detector.rs:615
↓ 1 callersFunctiondetermine_winner
Determine winner from final prices Winner is the token with ask price > 0.50 at the end Handles resolved state: $1.00/$0.00 means winner is $1.00 toke
src/backtest.rs:253
↓ 1 callersFunctiondiscover_current_btc_15m
Discover the current (or most recent) BTC 15-minute Up/Down market.
src/bin/test_merge.rs:79
↓ 1 callersFunctiondiscover_solana_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_trailing.rs:846
↓ 1 callersFunctiondiscover_xrp_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_trailing.rs:858
↓ 1 callersMethodexecute_limit_buy_batch
Place multiple limit buy orders in one batch request. Uses the same limit price and size for all. Returns one OrderResponse per opportunity in the sam
src/trader.rs:1259
↓ 1 callersMethodfetch_market_data
Fetch current market data for both ETH and BTC markets Uses get_price() endpoint continuously for real-time prices
src/monitor.rs:329
↓ 1 callersMethodfill_limit_order
Fill a limit order and create a position (for BUY) or close a position (for SELL)
src/simulation.rs:536
↓ 1 callersFunctionfmt_chainlink_beat
Chainlink spot vs price-to-beat (replaces plain `| BTC $…` tail).
src/term_ui.rs:490
↓ 1 callersFunctionfmt_countdown
(timer: &str)
src/term_ui.rs:478
↓ 1 callersFunctionfmt_eth_book
(up: &str, down: &str)
src/term_ui.rs:436
↓ 1 callersFunctionfmt_sol_book
(up: &str, down: &str)
src/term_ui.rs:450
↓ 1 callersFunctionfmt_trailing_status_line
Optional trailing status (e.g. hedge/trailing line) — high visibility.
src/term_ui.rs:527
↓ 1 callersFunctionfmt_xrp_book
(up: &str, down: &str)
src/term_ui.rs:464
↓ 1 callersFunctionformat_portfolio_sync_banner
()
src/term_ui.rs:205
↓ 1 callersFunctionformat_price_tick_line
Price tick for `log_to_history`: ANSI on stderr path, strip for files.
src/term_ui.rs:547
↓ 1 callersMethodgenerate_signature
Generate HMAC-SHA256 signature for authenticated requests
src/api.rs:420
↓ 1 callersMethodget_all_active_markets
Get all active markets (using events endpoint)
src/api.rs:511
↓ 1 callersMethodget_all_positions
Get all positions (for market closure checking)
src/simulation.rs:762
↓ 1 callersMethodget_auth_message
Get authentication message
src/bin/test_predict_fun.rs:88
↓ 1 callersMethodget_market_by_id
Get market by ID
src/bin/test_predict_fun.rs:199
↓ 1 callersMethodget_markets
Get all markets
src/bin/test_predict_fun.rs:159
↓ 1 callersFunctionget_or_discover_markets_5m_btc
( api: &PolymarketApi, )
src/bin/main_dual_limit_045_5m_btc.rs:981
↓ 1 callersMethodget_orderbook
Get orderbook for a market This returns bid/ask prices for Up/Down tokens
src/bin/test_predict_fun.rs:224
↓ 1 callersMethodget_pending_limit_trades_for_period
List all pending limit trades for a period (key starts with "{period}_" and ends with "_limit"). Used in simulation to augment current_prices so track
src/trader.rs:291
↓ 1 callersMethodget_pending_order_count
Get count of pending (unfilled) limit orders
src/simulation.rs:780
↓ 1 callersMethodget_portfolio_tokens
Automatically discovers current BTC and ETH markets if condition IDs are not provided
src/api.rs:946
↓ 1 callersMethodget_position_token_ids
Get all token IDs from open positions
src/simulation.rs:753
↓ 1 callersMethodget_redeemable_positions
Fetch redeemable position condition IDs from Data API (user=wallet, redeemable=true). Only includes positions where the wallet holds tokens (size > 0)
src/api.rs:1769
↓ 1 callersMethodget_server_time
(&self)
src/api.rs:195
↓ 1 callersMethodget_trend_analysis
Get trend analysis for a token
src/simulation.rs:279
↓ 1 callersMethodget_wallet_address
Return the wallet address to use for positions/redemption: proxy_wallet_address if set, else EOA from private_key.
src/api.rs:1756
↓ 1 callersMethodhas_api_credentials
True if API credentials (api_key, api_secret, api_passphrase) are set. Required for CLOB-authenticated calls (e.g. balance check, portfolio scan fallb
src/api.rs:1751
↓ 1 callersMethodis_backtest
Check if we're in backtest mode
src/config.rs:48
↓ 1 callersMethodis_history_replay
Check if we're in history-file replay mode
src/config.rs:53
↓ 1 callersMethodis_uptrending
Check if price is trending up strongly
src/simulation.rs:1143
↓ 1 callersMethodlog_pending_orders_summary
Log summary of pending orders
src/simulation.rs:931
↓ 1 callersMethodlog_position_summary
Write position summary to log file
src/simulation.rs:741
↓ 1 callersFunctionlog_to_history
(message: &str)
src/bin/main_dual_limit_045_5m_btc.rs:65
↓ 1 callersMethodmerge_complete_sets
Merge complete sets of Up and Down tokens for a condition into collateral (pUSD). Burns min(Up_balance, Down_balance) pairs and returns that much pUSD
src/api.rs:2095
↓ 1 callersFunctionparse_chainlink_btc_value
(text: &str)
src/rtds.rs:60
↓ 1 callersFunctionparse_os_release_ids
()
src/clob_sdk.rs:34
↓ 1 callersFunctionparse_price_line
Parse a price line from history file Format: [TIMESTAMP] 📊 BTC: U$bid/$ask D$bid/$ask | ETH: U$bid/$ask D$bid/$ask | SOL: U$bid/$ask D$bid/$ask | XRP:
src/backtest.rs:67
↓ 1 callersFunctionpipe_sep_colored
Separator between colored quote segments (visible but not loud).
src/term_ui.rs:416
↓ 1 callersMethodplace_limit_orders
Place multiple limit orders (one post_limit_order per order via clob_sdk).
src/api.rs:724
↓ 1 callersMethodplace_market_orders
Place multiple market orders (one post_market_order per order via clob_sdk).
src/api.rs:1657
↓ 1 callersFunctionpolygon
Ensure the SDK .so is loaded and return POLYGON chain id. Use this where the bot currently uses POLYGON.
src/clob_sdk.rs:209
↓ 1 callersFunctionpolygon_chain_id
Polygon mainnet chain ID (137). From the loaded .so.
src/clob_sdk.rs:125
↓ 1 callersFunctionprint_auth_start
()
src/term_ui.rs:329
↓ 1 callersFunctionprint_auth_success
( proxy_line: Option<&str>, api_key_preview: &str, signer_line: Option<&str>, signature_type:
src/term_ui.rs:333
↓ 1 callersFunctionprint_discover_alt_slug_prefix
(market_name: &str, prefix: &str)
src/term_ui.rs:253
↓ 1 callersFunctionprint_discover_try_previous_slug
(market_name: &str, try_slug: &str)
src/term_ui.rs:270
↓ 1 callersFunctionprint_monitoring_start
()
src/term_ui.rs:287
↓ 1 callersFunctionprint_section_bar_styled
(title: &str)
src/term_ui.rs:69
↓ 1 callersFunctionprint_simulation_hint
()
src/term_ui.rs:164
↓ 1 callersFunctionprint_startup_banner
Compact startup header (replaces large ASCII art).
src/term_ui.rs:125
↓ 1 callersFunctionprint_strategy_config
( limit_price: f64, early_min: u64, std_min: u64, hedge_px: f64, trailing: f64, shares
src/term_ui.rs:779
↓ 1 callersFunctionrecord_trailing_trade
Append one JSON line to history/trailing_trades.jsonl
src/bin/main_trailing.rs:164
↓ 1 callersMethodredeem_token_by_id_with_trade
Redeem tokens using trade data directly (avoids lookup issues)
src/trader.rs:3748
↓ 1 callersMethodrefresh_market_tokens
Refresh market data once per period (15 minutes) to get token IDs
src/monitor.rs:214
↓ 1 callersFunctionrun_backtest
Run backtest on all history files
src/backtest.rs:539
↓ 1 callersFunctionrun_chainlink_btc_loop
(out: Arc<Mutex<Option<f64>>>)
src/rtds.rs:30
↓ 1 callersFunctionrun_merge_check
Run merge check using API: fetch Up/Down balances for condition_id, compute merge, print result. Returns the MergeResult so the caller can decide to r
src/bin/test_merge.rs:106
↓ 1 callersFunctionrun_trailing_stop_replay
Replay historical prices and run trailing-stop hedge logic (no real orders). Assumes one side (e.g. Up) filled at 0.45; runs 2-min / 4-min / early hed
src/bin/main_dual_limit_045_same_size.rs:131
↓ 1 callersFunctionrun_unit_tests
()
src/bin/test_merge.rs:38
↓ 1 callersMethodsample_count
Get the number of price samples currently tracked
src/simulation.rs:1157
↓ 1 callersFunctionsecond_token_ceiling_desc
Human-readable description of the ceiling for the current time-since-first-buy (for skip logs).
src/bin/main_trailing.rs:72
↓ 1 callersFunctionsecond_token_meets_price_ceiling
Returns true if opposite_price is below the ceiling for the current time-since-first-buy. Stop loss is handled separately (always buys); this is only
src/bin/main_trailing.rs:53
↓ 1 callersMethodset_approval_for_all_via_relayer
Set approval for all tokens via Polymarket relayer (for proxy wallets) Based on: https://docs.polymarket.com/developers/builders/relayer-client NOTE:
src/api.rs:1276
↓ 1 callersFunctionspawn_chainlink_btc_task
Spawn a background task that keeps the latest Chainlink BTC/USD price in `out`. On each RTDS update, sets *out = Some(value). Reconnects on disconnect
src/rtds.rs:16
← previousnext →101–200 of 284, ranked by callers