Alphafamilia Algo Help

Keys on the exchange side

In short

  • You create the API key in your exchange account and enter it only in the app's form.
  • The key needs the right to trade; a key that may withdraw funds is not accepted.
  • Never send the key and the secret to anyone — not even to the system administrator.

A strategy trades on the exchange through an API key (on Binance, BingX and Bybit — an API Key and a Secret Key, at Coinbase — a key name and a private key, at T-Invest — a token). You create the key yourself, in your account on the exchange. Then you enter it in the app, and the service asks the exchange itself what the key can do. This page is about preparing the key on the exchange.

Important. Enter the key and the secret only in the app's form. Never write them in a chat, an email or notes, and never send them to anyone, including the system administrator.

Binance

What key you need

Key setting on Binance What is needed
Key type System-generated (HMAC): the exchange gives an API Key and a Secret Key
Reading (Enable Reading) On
Spot trading On — for spot strategies
Futures (Enable Futures) On — if you need futures strategies
Withdrawals Off
IP access restriction Only the address of the Alphafamilia Algo server

The app checks the key with the exchange itself (the "Check the key" button when you add a connection) and shows the answer point by point:

  • if withdrawals are allowed, the key is not accepted: "Withdrawals enabled — such a key is refused";
  • if trading is not allowed, the key is not accepted;
  • a "Binance USD-M futures" connection needs the futures permission ("Enable Futures"), a "Binance spot" one — spot ("Enable Spot & Margin Trading"); without it the key is not accepted;
  • if there is no IP restriction, the key is accepted with a warning, and the warning shows the server's address. But Binance lets only a key with an IP list trade: with no list and trading not allowed, the "Check result" says one line — "✗ Binance allows trading only to a key with an IP list. Add the server's address … to the key's IP list (“Restrict access to trusted IPs only”), switch on “Enable Spot & Margin Trading” (for futures — “Enable Futures”) and press “Check key” again."

One key can serve both spot and futures of one account, but in the app these are two connections — "Binance spot" and "Binance USD-M futures"; the key is entered for each. "Binance COIN-M futures" needs the same "Enable Futures" right — Binance has one right for USD-M and COIN-M, so the same key will do; it is typed in again too, and the check asks the COIN-M account (I want to trade COIN-M futures).

Create a key

  1. Find out the address (IP) of the server: the app shows it in step 2 of a new connection ("Profile" → "Settings" → "Exchange connections" → "+ New connection"), with a "Copy" button. There is also a reminder of what to switch on for the key and a link to this Binance guide.
  2. On Binance, open API key management: profile → "Account" → "API Management" → "Create API".
  3. Choose the key type "System-generated" and enter a name, for example dca2.
  4. Confirm the creation with your two-factor codes.
  5. Copy the API Key and the Secret Key. The exchange shows the Secret Key only once.
  6. Open the key's settings and choose IP access restriction: trusted addresses only. Enter the address of the server.
  7. Turn on spot trading and, if you need futures, "Enable Futures".
  8. Make sure withdrawals are off.
  9. Save the key's settings and confirm them with your security codes.

Official Binance instructions: How to Create API Keys on Binance.

Important. By Binance rules, a key without an IP restriction can only read by default. So the restriction to the server's address is needed not only for safety, but also for trading.

Important. The app does not accept keys with your own key pair (Ed25519, RSA): the form needs an API Key and a Secret Key of 64 latin letters and digits each. A key of another kind gets the answer "The key has a wrong form (extra spaces?).".

Tip. The futures permission cannot be turned on for a key created before the futures account was opened. If the option is missing, open a futures account and create a new key.

Binance test network

The test network is a practice exchange with play money. Its key is created separately, not in your usual Binance account.

  1. Open the Spot Test Network site: https://testnet.binance.vision.
  2. Log in with GitHub.
  3. Press "Generate HMAC_SHA256 Key" and save the API Key and the Secret Key. The Secret Key is shown only once. This key needs no IP restrictions.
  4. In the app, when you add the connection, choose the environment "test network".

The test money is on the test network account already — no top-up is needed. On the connection screen the hint for the test network is shorter than for the live one.

Official Binance instructions: How to Test My Functions on Binance Testnet?.

On the test network the exchange does not report the key's restrictions. So there are no checks of withdrawals and the IP address there.

For practice futures trading, Binance has demo trading with its own keys: sign in with your Binance account on https://demo.binance.com, open futures demo trading and its "API Management" (https://demo.binance.com/en/my/settings/api-management). Keys made earlier on the old practice site testnet.binancefuture.com work too. Such a key is also added as a Binance connection with the environment "test network": the app checks it on the practice futures. It trades futures only — spot strategies on such a connection will not work.

BingX

At BingX, as at Binance, the key has two parts — the API Key and the Secret Key. Its permissions: "Read" (always on), "Spot Trading" for spot, "Perpetual Futures Trading" for futures; "Withdrawal" and transfers — off; the server's address in the IP whitelist. A futures key can be tried on the VST demo account (virtual USDT); BingX has no demo spot.

How to create the key, what to switch on the futures account and how BingX differs from Binance — BingX: spot and USDT-M futures. BingX's key page: API Management.

Important. The server reaches BingX over its IPv4 address only — the one the app shows at step 2 of a new connection. A key whose IP list lacks the server's address is refused by the check, with a hint to add the address.

Bybit

At Bybit the key has two parts too — the API Key and the Secret Key. It must be a key of the global bybit.com on the Unified Trading Account; a classic account's key is refused.

Key setting on Bybit What is needed
Key type "System-generated", "Read-Write"
Spot "Unified Trading" → "Trade" — for a "Bybit spot" connection
Futures "Contracts" → "Orders" and "Positions" — for a "Bybit USDT futures" connection
Withdrawals ("Withdrawal" under "Assets") Off — a key that may withdraw is refused
IP The server's address. Bybit switches off a key without an IP list after 90 days

The app takes a key without an IP list, but shows its term on the connection's card and reminds you in Telegram 7 days before and on the day. Bybit's demo account has its own keys: on bybit.com switch to "Demo Trading" mode and create the key there; the demo funds are requested there too. How to create the key, the demo account and the futures account's settings — Bybit. Bybit's guide: How to create your API key.

Coinbase

Coinbase's key is of another kind: it is made not in the profile but on the CDP developer portal (portal.cdp.coinbase.com → API Keys → Secret API Keys), and consists of a key name (organizations/…/apiKeys/…) and a private key (a text with BEGIN and END).

Key setting at Coinbase What is needed
Signature algorithm ECDSA (Ed25519 is not accepted)
Permissions "View" and "Trade"
"Transfer" (moving and withdrawing) Off — a key with this permission is not accepted
Portfolio The key is restricted to the portfolio for the strategies
IP allowlist The server's address. The app does not see Coinbase's IP list and does not warn

The private key is pasted whole — with line breaks or without them, and the CDP key file may be pasted into either of the two fields. The key has no term. How to create the key, why there is no test environment and how Coinbase differs from Binance — Coinbase. Coinbase's guide: API Key Authentication.

The key's term and daily check

Some exchanges limit a key's term (Bybit — 90 days for a key without an IP list). If the exchange tells the term, it is kept with the connection and shown on its card: "The key works until 30.01.2027 (89 d)". 7 days before and on the day a reminder comes in Telegram — then create a new key on the exchange and replace it in the app ("Replace key", with the connection's strategies stopped).

Once a day the server checks the keys of all your exchanges itself — one by one, without extra load, and not while the exchange blocks the server's address. If the exchange's answer changed, a message comes: a new term, a term appeared or is gone, the key no longer works, withdrawals were switched on for the key, the key has no trading permission. All such messages — Telegram messages.

BNB for fees (Binance). The same daily check looks at whether paying fees in BNB is on at Binance. If it is on, and the BNB beyond what the strategies count as theirs is below 0.02 BNB or worth less than 12 USDT at BNB's price, the message "little BNB left for fees" comes — once a day while the reserve is not topped up. On spot the BNB is needed on the spot account, on futures — on the futures wallet (the BNB has to be transferred there). Nothing is stopped or sold; when the reserve runs out, the exchange takes the fee from the coin received (on futures — without the discount). Buy a little BNB or switch paying fees in BNB off in the account's settings on the exchange. If paying in BNB is off, a spot purchase's fee is taken from the coin bought, and the strategy buys one quantity step more — so that after the fee the planned quantity is left for the TP.

T-Invest

What token you need

T-Invest works not with a key and a secret but with a single token. The token starts with t..

  • For testing — a sandbox token: the money there is not real. For the "sandbox" environment the app has its own checklist: "Issue a sandbox token in T-Invest — not a live one.", "No sandbox account — after the token check, open one with the button: the app tops it up with 100,000 virtual ₽.", "The token has no IP restriction.".
  • For real work — a token with trading rights. Best of all — with access to only one account that you set aside for the strategies.

A token cannot withdraw money, and the broker has no IP restriction for tokens. So for a token the app checks only the accounts and the right to trade on them.

Create a token

  1. Open the T-Invest app or website.
  2. Go to: Settings → T-Invest API tokens → "Create token" (the broker's app may show these names in Russian).
  3. Choose the kind of token: for the sandbox or with trading rights.
  4. Limit access to the account for the strategies, if the broker lets you choose an account.
  5. Copy the token. The broker shows it only once.

Official description: Token — T-Invest API (in Russian), the sandbox — Sandbox — T-Invest API (in Russian).

The account for the strategies

In the app, after you enter the token, click "Check the token and show the accounts" and choose an account. Accounts where the token may only read are marked "read only" and cannot be chosen. More — Connections and the key vault.

Tip. A new sandbox token has no accounts. The check then says "The key will not be taken — The token has no sandbox account. Open one with the button below.", and under it is the button "Open a sandbox account (with a test balance of 100,000 ₽)": the app opens the account at the broker, tops it up with 100,000 virtual roubles and shows it to choose at once. If the account runs out of money — ask the system administrator to top it up.

Specifics of trading shares and funds — T-Invest shares and funds.

Next: Connections and the key vault