Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/ConteurShadow/Polymarket-Trading-Bot-Rust
/ functions
Functions
284 in github.com/ConteurShadow/Polymarket-Trading-Bot-Rust
⨍
Functions
284
◇
Types & classes
59
↓ 2 callers
Method
has_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 callers
Method
has_position
Check if a position exists for a given token_id
src/simulation.rs:747
↓ 2 callers
Function
init_history_file
(file: File)
src/bin/main_dual_limit_045_5m_btc.rs:61
↓ 2 callers
Function
init_history_file
(file: File)
src/bin/main_dual_limit_045_same_size.rs:97
↓ 2 callers
Function
load_price_history
Load price history from a file
src/backtest.rs:232
↓ 2 callers
Method
log_market_end
Log market end event
src/simulation.rs:919
↓ 2 callers
Function
log_to_history
(message: &str)
src/bin/main_dual_limit_045_same_size.rs:101
↓ 2 callers
Method
mark_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 callers
Function
post_limit_order
Post limit order. Returns order_id on success.
src/clob_sdk.rs:304
↓ 2 callers
Function
post_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 callers
Function
print_market_found
After resolving an active up/down market (both outcomes trade under this condition).
src/term_ui.rs:219
↓ 2 callers
Function
print_rule_dim
()
src/term_ui.rs:145
↓ 2 callers
Method
resolve_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 callers
Function
section_bar
Full-width bar with centered title (total width = [`FRAME_INNER`]).
src/term_ui.rs:57
↓ 2 callers
Method
set_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 callers
Method
signer
(&self)
src/api.rs:159
↓ 2 callers
Function
strip_ansi_for_file
Strip ANSI escapes for history files and structured logs.
src/term_ui.rs:12
↓ 2 callers
Method
sync_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 callers
Method
sync_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 callers
Method
add_auth_header
Add JWT token to request if available
src/bin/test_predict_fun.rs:150
↓ 1 callers
Method
add_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 callers
Method
add_price
Add a new price snapshot
src/simulation.rs:1049
↓ 1 callers
Function
backtest_period
Run backtest for a single period
src/backtest.rs:338
↓ 1 callers
Method
calculate_unrealized_pnl
Calculate unrealized PnL for all open positions
src/simulation.rs:665
↓ 1 callers
Method
cancel_limit_order
Cancel a simulated limit order (removes it from pending tracking)
src/simulation.rs:199
↓ 1 callers
Method
cancel_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 callers
Method
check_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 callers
Function
client_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 callers
Function
clob_sdk_candidate_paths
()
src/clob_sdk.rs:54
↓ 1 callers
Method
create_l1_headers
(&self)
src/api.rs:211
↓ 1 callers
Function
decimal_to_f64
Helper function for Decimal to f64 conversion
src/detector.rs:615
↓ 1 callers
Function
determine_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 callers
Function
discover_current_btc_15m
Discover the current (or most recent) BTC 15-minute Up/Down market.
src/bin/test_merge.rs:79
↓ 1 callers
Function
discover_solana_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_trailing.rs:846
↓ 1 callers
Function
discover_xrp_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_trailing.rs:858
↓ 1 callers
Method
execute_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 callers
Method
fetch_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 callers
Method
fill_limit_order
Fill a limit order and create a position (for BUY) or close a position (for SELL)
src/simulation.rs:536
↓ 1 callers
Function
fmt_chainlink_beat
Chainlink spot vs price-to-beat (replaces plain `| BTC $…` tail).
src/term_ui.rs:490
↓ 1 callers
Function
fmt_countdown
(timer: &str)
src/term_ui.rs:478
↓ 1 callers
Function
fmt_eth_book
(up: &str, down: &str)
src/term_ui.rs:436
↓ 1 callers
Function
fmt_sol_book
(up: &str, down: &str)
src/term_ui.rs:450
↓ 1 callers
Function
fmt_trailing_status_line
Optional trailing status (e.g. hedge/trailing line) — high visibility.
src/term_ui.rs:527
↓ 1 callers
Function
fmt_xrp_book
(up: &str, down: &str)
src/term_ui.rs:464
↓ 1 callers
Function
format_portfolio_sync_banner
()
src/term_ui.rs:205
↓ 1 callers
Function
format_price_tick_line
Price tick for `log_to_history`: ANSI on stderr path, strip for files.
src/term_ui.rs:547
↓ 1 callers
Method
generate_signature
Generate HMAC-SHA256 signature for authenticated requests
src/api.rs:420
↓ 1 callers
Method
get_all_active_markets
Get all active markets (using events endpoint)
src/api.rs:511
↓ 1 callers
Method
get_all_positions
Get all positions (for market closure checking)
src/simulation.rs:762
↓ 1 callers
Method
get_auth_message
Get authentication message
src/bin/test_predict_fun.rs:88
↓ 1 callers
Method
get_market_by_id
Get market by ID
src/bin/test_predict_fun.rs:199
↓ 1 callers
Method
get_markets
Get all markets
src/bin/test_predict_fun.rs:159
↓ 1 callers
Function
get_or_discover_markets_5m_btc
( api: &PolymarketApi, )
src/bin/main_dual_limit_045_5m_btc.rs:981
↓ 1 callers
Method
get_orderbook
Get orderbook for a market This returns bid/ask prices for Up/Down tokens
src/bin/test_predict_fun.rs:224
↓ 1 callers
Method
get_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 callers
Method
get_pending_order_count
Get count of pending (unfilled) limit orders
src/simulation.rs:780
↓ 1 callers
Method
get_portfolio_tokens
Automatically discovers current BTC and ETH markets if condition IDs are not provided
src/api.rs:946
↓ 1 callers
Method
get_position_token_ids
Get all token IDs from open positions
src/simulation.rs:753
↓ 1 callers
Method
get_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 callers
Method
get_server_time
(&self)
src/api.rs:195
↓ 1 callers
Method
get_trend_analysis
Get trend analysis for a token
src/simulation.rs:279
↓ 1 callers
Method
get_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 callers
Method
has_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 callers
Method
is_backtest
Check if we're in backtest mode
src/config.rs:48
↓ 1 callers
Method
is_history_replay
Check if we're in history-file replay mode
src/config.rs:53
↓ 1 callers
Method
is_uptrending
Check if price is trending up strongly
src/simulation.rs:1143
↓ 1 callers
Method
log_pending_orders_summary
Log summary of pending orders
src/simulation.rs:931
↓ 1 callers
Method
log_position_summary
Write position summary to log file
src/simulation.rs:741
↓ 1 callers
Function
log_to_history
(message: &str)
src/bin/main_dual_limit_045_5m_btc.rs:65
↓ 1 callers
Method
merge_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 callers
Function
parse_chainlink_btc_value
(text: &str)
src/rtds.rs:60
↓ 1 callers
Function
parse_os_release_ids
()
src/clob_sdk.rs:34
↓ 1 callers
Function
parse_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 callers
Function
pipe_sep_colored
Separator between colored quote segments (visible but not loud).
src/term_ui.rs:416
↓ 1 callers
Method
place_limit_orders
Place multiple limit orders (one post_limit_order per order via clob_sdk).
src/api.rs:724
↓ 1 callers
Method
place_market_orders
Place multiple market orders (one post_market_order per order via clob_sdk).
src/api.rs:1657
↓ 1 callers
Function
polygon
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 callers
Function
polygon_chain_id
Polygon mainnet chain ID (137). From the loaded .so.
src/clob_sdk.rs:125
↓ 1 callers
Function
print_auth_start
()
src/term_ui.rs:329
↓ 1 callers
Function
print_auth_success
( proxy_line: Option<&str>, api_key_preview: &str, signer_line: Option<&str>, signature_type:
src/term_ui.rs:333
↓ 1 callers
Function
print_discover_alt_slug_prefix
(market_name: &str, prefix: &str)
src/term_ui.rs:253
↓ 1 callers
Function
print_discover_try_previous_slug
(market_name: &str, try_slug: &str)
src/term_ui.rs:270
↓ 1 callers
Function
print_monitoring_start
()
src/term_ui.rs:287
↓ 1 callers
Function
print_section_bar_styled
(title: &str)
src/term_ui.rs:69
↓ 1 callers
Function
print_simulation_hint
()
src/term_ui.rs:164
↓ 1 callers
Function
print_startup_banner
Compact startup header (replaces large ASCII art).
src/term_ui.rs:125
↓ 1 callers
Function
print_strategy_config
( limit_price: f64, early_min: u64, std_min: u64, hedge_px: f64, trailing: f64, shares
src/term_ui.rs:779
↓ 1 callers
Function
record_trailing_trade
Append one JSON line to history/trailing_trades.jsonl
src/bin/main_trailing.rs:164
↓ 1 callers
Method
redeem_token_by_id_with_trade
Redeem tokens using trade data directly (avoids lookup issues)
src/trader.rs:3748
↓ 1 callers
Method
refresh_market_tokens
Refresh market data once per period (15 minutes) to get token IDs
src/monitor.rs:214
↓ 1 callers
Function
run_backtest
Run backtest on all history files
src/backtest.rs:539
↓ 1 callers
Function
run_chainlink_btc_loop
(out: Arc<Mutex<Option<f64>>>)
src/rtds.rs:30
↓ 1 callers
Function
run_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 callers
Function
run_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 callers
Function
run_unit_tests
()
src/bin/test_merge.rs:38
↓ 1 callers
Method
sample_count
Get the number of price samples currently tracked
src/simulation.rs:1157
↓ 1 callers
Function
second_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 callers
Function
second_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 callers
Method
set_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 callers
Function
spawn_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
← previous
next →
101–200 of 284, ranked by callers