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
↓ 37 callers
Function
paint
(plain: &str, f: F)
src/term_ui.rs:77
↓ 36 callers
Method
log_to_file
Log to simulation file (and optionally to market-specific file)
src/simulation.rs:107
↓ 25 callers
Function
log_trading_event
(event: &str)
src/lib.rs:45
↓ 21 callers
Method
check_balance_only
Check token balance only (for redemption/portfolio scanning) via clob_sdk.
src/api.rs:1063
↓ 21 callers
Method
get_market
Get market details by condition ID
src/api.rs:618
↓ 20 callers
Function
copy_rust_to_c
(s: &str)
src/clob_sdk.rs:217
↓ 19 callers
Method
check_balance_allowance
Check token balance and allowance before selling (via clob_sdk).
src/api.rs:1070
↓ 18 callers
Method
place_order
Place an order using clob_sdk (post_limit_order). Equivalent to JavaScript: client.createAndPostOrder(userOrder)
src/api.rs:707
↓ 16 callers
Method
get_pending_limit_trade
Get a pending limit trade (keyed by `"{period}_{token_id}_limit"`)
src/trader.rs:261
↓ 15 callers
Method
display_name
(&self)
src/detector.rs:70
↓ 15 callers
Method
flush
(&mut self)
src/bin/main_dual_limit_045_5m_btc.rs:48
↓ 14 callers
Method
execute_buy
Execute buy when momentum opportunity is detected Buys any token (BTC Up/Down, ETH Up/Down) when price reaches trigger_price after 10 minutes
src/trader.rs:491
↓ 13 callers
Function
use_color
()
src/term_ui.rs:43
↓ 12 callers
Method
update_balance_allowance_for_sell
Refresh cached allowance for outcome token before selling (via clob_sdk).
src/api.rs:1091
↓ 10 callers
Method
cancel_pending_limit_buy
Cancel a pending LIMIT BUY order for the given token/period and remove it from tracking
src/trader.rs:322
↓ 10 callers
Method
get_market_by_slug
Get market by slug (e.g., "btc-updown-15m-1767726000") The API returns an event object with a markets array
src/api.rs:568
↓ 10 callers
Function
load_lib
()
src/clob_sdk.rs:106
↓ 10 callers
Function
polygon
Polygon chain ID from clob_sdk (137).
src/api.rs:62
↓ 9 callers
Method
ensure_clob_client
Ensure CLOB client is created and return handle. Call after authenticate() or when placing orders/checking balance.
src/api.rs:315
↓ 9 callers
Function
merge_up_down_amounts
Compute how many complete sets (Up + Down pairs) can be formed, and the remainders. - `complete_sets = min(up_amount, down_amount)` - `remaining_up =
src/merge.rs:28
↓ 8 callers
Method
check_token
Check a single token for opportunity
src/detector.rs:115
↓ 8 callers
Method
is_simulation
Get the effective simulation mode If --no-simulation is used, forces production If --backtest is used, it overrides everything
src/config.rs:37
↓ 8 callers
Method
log_trend_analysis
Log trend analysis for a token (useful for debugging)
src/simulation.rs:323
↓ 8 callers
Method
mark_limit_trade_filled_by_hedge
attribute the balance increase to a "limit fill" and log "LIMIT BUY ORDER FILLED" again. Uses max(current_balance, existing t.units) for units so a st
src/trader.rs:371
↓ 8 callers
Function
print_outcome_token_id
One outcome token (📈 UP / 📉 DOWN) for CLOB order books.
src/term_ui.rs:305
↓ 8 callers
Method
track_price
Track price for trend analysis Call this whenever you receive new price data
src/simulation.rs:263
↓ 6 callers
Method
authenticate
Authenticate with signature and get JWT token Note: You'll need to sign the message with your private key
src/bin/test_predict_fun.rs:120
↓ 6 callers
Method
discover_current_market
Discover current BTC or ETH 15-minute market Similar to main bot's discover_market function
src/api.rs:784
↓ 6 callers
Function
discover_market
( api: &PolymarketApi, market_name: &str, slug_prefixes: &[&str], current_time: u64, seen_
src/bin/main_dual_limit_045_same_size.rs:2979
↓ 6 callers
Method
place_market_order
Place a market order (FOK/FAK) for immediate execution This is used for emergency selling or when you want immediate execution at market price. Equiv
src/api.rs:1597
↓ 5 callers
Method
execute_sell
Execute sell order with configurable order type order_type: None or "FAK" for Fill-and-Kill (allows partial fills), "FOK" for Fill-or-Kill Default: FA
src/trader.rs:3039
↓ 5 callers
Method
get_best_price
Get best bid/ask prices for a token (from orderbook)
src/api.rs:688
↓ 5 callers
Method
get_market_file
Get or create a market-specific log file Skips dummy markets - they should only log to simulation.toml
src/simulation.rs:77
↓ 5 callers
Method
get_price
Get price for a token (for trading) side: "BUY" or "SELL"
src/api.rs:648
↓ 5 callers
Method
get_simulation_tracker
(&self)
src/trader.rs:29
↓ 5 callers
Method
get_token_balance_shares
After a market-order hedge for the unfilled side, mark the pending _limit trade for that token as filled (confirmed_balance + buy_order_confirmed) so
src/trader.rs:358
↓ 4 callers
Method
check_is_approved_for_all
Check if setApprovalForAll was already set for the Exchange contract
src/api.rs:1097
↓ 4 callers
Function
contract_config
Get contract config from the loaded SDK .so. Same as SDK's contract_config(chain_id, is_neg_risk).
src/clob_sdk.rs:155
↓ 4 callers
Function
discover_market
( api: &PolymarketApi, _market_name: &str, slug_prefixes: &[&str], current_time: u64, seen
src/bin/main_trailing.rs:814
↓ 4 callers
Method
flush
(&mut self)
src/bin/main_dual_limit_045_same_size.rs:84
↓ 4 callers
Method
get_current_condition_ids
Get current market condition IDs (for checking if markets are closed)
src/monitor.rs:191
↓ 4 callers
Method
get_or_create_api_credentials
(&self)
src/api.rs:282
↓ 4 callers
Method
get_pending_limit_trade_by_market
Get a pending limit trade by market (period, condition_id, token_type). Use this when the current snapshot's token_id might differ from the token_id u
src/trader.rs:269
↓ 4 callers
Method
get_pending_trade_for_period_token
Get a pending trade for (period, token_id) from any key: _limit, _individual_hedge, or _standard_hedge. Used by dual-limit same-size low-price exit to
src/trader.rs:310
↓ 4 callers
Method
get_portfolio_tokens_all
Get all tokens in portfolio with balance > 0 Get all tokens in portfolio with balance > 0, checking recent markets (not just current) Uses REDEEM_SCAN
src/api.rs:822
↓ 4 callers
Function
log_to_history
Logging functions - modules will use these
src/lib.rs:31
↓ 4 callers
Method
log_to_market
Log to both main file and market-specific file For dummy markets, only logs to simulation.toml (no separate market file)
src/simulation.rs:118
↓ 4 callers
Function
maybe_hedge_pair
( trader: &Trader, condition_id: &str, up: &Option
src/bin/main_dual_limit_045_same_size.rs:2120
↓ 4 callers
Function
print_discover_section_start
One line for `log_to_history` / stderr (ANSI stripped for files).
src/term_ui.rs:192
↓ 4 callers
Function
push_lib_pair
(out: &mut Vec<String>, name: &str)
src/clob_sdk.rs:49
↓ 4 callers
Function
read_string_from_ffi
( lib: &Library, fn_name: &[u8], chain_id: u64, neg_risk: bool, )
src/clob_sdk.rs:135
↓ 4 callers
Method
signer_address
(&self)
src/api.rs:168
↓ 4 callers
Function
token_type_for
(market_name: &str, is_up: bool)
src/bin/main_trailing.rs:149
↓ 4 callers
Function
trailing_window_label
Returns human-readable time-window label for trailing-stop logs.
src/bin/main_trailing.rs:90
↓ 4 callers
Method
update_markets
Update markets when a new period starts
src/monitor.rs:146
↓ 3 callers
Method
add_limit_order
Add a limit order to simulation tracking
src/simulation.rs:135
↓ 3 callers
Function
balance_allowance
Fetch balance and allowance for token. asset_type: "Collateral" (pUSD) or "Conditional".
src/clob_sdk.rs:417
↓ 3 callers
Method
calculate_trend
Calculate the current trend using linear regression and pattern analysis
src/simulation.rs:1058
↓ 3 callers
Method
check_all_approvals
Check all approvals for all contracts. Returns (contract_name, usdc_approved, ctf_approved).
src/api.rs:1133
↓ 3 callers
Function
disabled_eth_market
()
src/bin/main_dual_limit_045_same_size.rs:2902
↓ 3 callers
Function
disabled_solana_market
()
src/bin/main_dual_limit_045_same_size.rs:2919
↓ 3 callers
Function
disabled_xrp_market
()
src/bin/main_dual_limit_045_same_size.rs:2936
↓ 3 callers
Method
get_current_market_timestamp
Get the current market's timestamp from the BTC market slug
src/monitor.rs:198
↓ 3 callers
Method
get_orderbook
Get order book for a specific token
src/api.rs:597
↓ 3 callers
Method
get_total_spending_and_earnings
Get total spending and earnings across all positions
src/simulation.rs:863
↓ 3 callers
Method
log_market_start
Log market start event Logs once to simulation.toml and writes to market-specific files (without duplicating main log)
src/simulation.rs:872
↓ 3 callers
Method
mid_price
(&self)
src/models.rs:54
↓ 3 callers
Method
opposite
Get the opposite token type (Up <-> Down)
src/detector.rs:84
↓ 3 callers
Function
print_section_title
(title: &str)
src/term_ui.rs:153
↓ 3 callers
Function
redeem_token
Redeem a winning token
src/bin/test_redeem.rs:322
↓ 3 callers
Method
redeem_tokens
for pUSD collateral at 1:1 notional after market resolution. Parameters: - condition_id: The condition ID of the resolved market - token_id: The toke
src/api.rs:1816
↓ 3 callers
Method
request_api_credentials
(&self, method: reqwest::Method, path: &str)
src/api.rs:263
↓ 3 callers
Method
reset_period
Reset for new period (detector state is reset elsewhere). We do NOT remove pending trades here: unsold/unredeemed positions from the previous period m
src/trader.rs:3790
↓ 3 callers
Function
sell_token
( api: &PolymarketApi, token_id: &str, balance: f64, shares: Option<f64>, check_only: bool
src/bin/test_sell.rs:192
↓ 3 callers
Method
start_monitoring
Start monitoring markets continuously Returns a callback function that can be used to update markets when new period starts
src/monitor.rs:771
↓ 2 callers
Method
add_auth_headers
Add authentication headers to a request
src/api.rs:484
↓ 2 callers
Method
apply_env_overrides
(&mut self)
src/config.rs:249
↓ 2 callers
Function
ask_f64
Ask price for recording and calculation (we buy at ask). Falls back to bid if ask missing.
src/bin/main_trailing.rs:140
↓ 2 callers
Method
check_limit_orders
Check if any limit orders should be filled based on current prices
src/simulation.rs:404
↓ 2 callers
Method
check_market_result
(&self, condition_id: &str, token_id: &str)
src/trader.rs:3737
↓ 2 callers
Method
check_usdc_balance_allowance
Check pUSD (CLOB V2 collateral) balance and allowance for buying tokens (via clob_sdk). Returns (balance, allowance) as Decimal values (names `usdc_*`
src/api.rs:1054
↓ 2 callers
Method
clear
Clear all price history (useful when starting a new period)
src/simulation.rs:1162
↓ 2 callers
Function
derive_proxy_wallet_for_signer
Derive deterministic Polymarket proxy wallet for a signer EOA on Polygon.
src/api.rs:67
↓ 2 callers
Function
derive_safe_wallet_for_signer
Derive deterministic Polymarket Safe wallet for a signer EOA on Polygon.
src/api.rs:75
↓ 2 callers
Function
disabled_eth_market
()
src/bin/main_dual_limit_045_5m_btc.rs:1026
↓ 2 callers
Function
disabled_eth_market
()
src/bin/main_trailing.rs:930
↓ 2 callers
Function
disabled_solana_market
()
src/bin/main_dual_limit_045_5m_btc.rs:1043
↓ 2 callers
Function
disabled_solana_market
()
src/bin/main_trailing.rs:947
↓ 2 callers
Function
disabled_xrp_market
()
src/bin/main_dual_limit_045_5m_btc.rs:1060
↓ 2 callers
Function
disabled_xrp_market
()
src/bin/main_trailing.rs:964
↓ 2 callers
Function
discover_btc_5m_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_dual_limit_045_5m_btc.rs:996
↓ 2 callers
Function
discover_solana_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_dual_limit_045_same_size.rs:2953
↓ 2 callers
Function
discover_xrp_market
( api: &PolymarketApi, current_time: u64, seen_ids: &mut std::collections::HashSet<String>, )
src/bin/main_dual_limit_045_same_size.rs:2966
↓ 2 callers
Method
execute_limit_buy
Execute limit buy order - places limit buy for both Up and Down tokens When a buy order fills, immediately places ONE limit sell order at sell_price (
src/trader.rs:1075
↓ 2 callers
Function
first_buy_units_and_investment
Returns (units, investment) so that investment = units * price >= MIN_FIRST_BUY_COST and units >= base_shares. Rounds units up to 2 decimals for API.
src/bin/main_trailing.rs:32
↓ 2 callers
Method
get_opposite_token_id
Get the opposite token ID for a given token type and condition ID Returns the token ID of the opposite token (Up <-> Down)
src/trader.rs:175
↓ 2 callers
Function
get_or_discover_markets
( api: &PolymarketApi, enable_eth: bool, enable_solana: bool, enable_xrp: bool, )
src/bin/main_trailing.rs:870
↓ 2 callers
Function
get_or_discover_markets
Copy helper functions from main.rs
src/bin/main_dual_limit_045_same_size.rs:2801
↓ 2 callers
Method
get_pending_order_token_ids
Get all token IDs from pending limit orders
src/simulation.rs:771
↓ 2 callers
Method
get_position_summary
Get position summary
src/simulation.rs:688
next →
1–100 of 284, ranked by callers