├── .editorconfig ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Vagrantfile ├── config.rb ├── deploy.sh ├── font-selection.json ├── lib ├── multilang.rb ├── nesting_unique_head.rb ├── toc_data.rb └── unique_head.rb └── source ├── CNAME ├── en.html.md ├── fonts ├── slate.eot ├── slate.svg ├── slate.ttf ├── slate.woff └── slate.woff2 ├── images ├── favicon.ico ├── logo.png └── navbar.png ├── includes ├── en │ ├── _accounts.md │ ├── _authentication.md │ ├── _errors.md │ ├── _introduction.md │ ├── _leveraged.md │ ├── _markets.md │ ├── _order_errors.md │ ├── _orders.md │ ├── _otc.md │ ├── _publics.md │ └── _small_currency_exchange.md ├── jp │ ├── _accounts.md │ ├── _authentication.md │ ├── _errors.md │ ├── _introduction.md │ ├── _leveraged.md │ ├── _markets.md │ ├── _order_errors.md │ ├── _orders.md │ ├── _otc.md │ ├── _publics.md │ └── _small_currency_exchange.md ├── kr │ ├── _accounts.md │ ├── _authentication.md │ ├── _errors.md │ ├── _introduction.md │ ├── _markets.md │ ├── _order_errors.md │ ├── _orders.md │ └── _publics.md └── zh │ ├── _accounts.md │ ├── _authentication.md │ ├── _errors.md │ ├── _introduction.md │ ├── _leveraged.md │ ├── _markets.md │ ├── _order_errors.md │ ├── _orders.md │ ├── _otc.md │ └── _publics.md ├── index.html ├── javascripts ├── all.js ├── all_nosearch.js ├── app │ ├── _lang.js │ ├── _search.js │ └── _toc.js └── lib │ ├── _energize.js │ ├── _imagesloaded.min.js │ ├── _jquery.highlight.js │ ├── _jquery.js │ └── _lunr.js ├── jp.html.md ├── kr.html.md ├── layouts └── layout.erb ├── stylesheets ├── _icon-font.scss ├── _normalize.scss ├── _rtl.scss ├── _variables.scss ├── print.css.scss └── screen.css.scss └── zh.html.md /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # Top-most EditorConfig file 4 | root = true 5 | 6 | # Unix-style newlines with a newline ending every file 7 | [*] 8 | end_of_line = lf 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 2 12 | trim_trailing_whitespace = true 13 | 14 | [*.rb] 15 | charset = utf-8 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | Operating system: ✍️ TODO 12 | Last upstream commit (run `git log --author="Robert Lord" | head -n 1`): ✍️ TODO 13 | Browser version(s): ✍️ TODO 14 | Ruby version (run `ruby -v`): ✍️ TODO 15 | 16 | --- 17 | 18 | ✍️ TODO write your issue here 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | *.DS_STORE 15 | build/ 16 | .cache 17 | .vagrant 18 | .sass-cache 19 | 20 | # YARD artifacts 21 | .yardoc 22 | _yardoc 23 | doc/ 24 | .idea/ 25 | .env 26 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: ruby 4 | 5 | rvm: 6 | - 2.3.3 7 | - 2.4.0 8 | 9 | cache: bundler 10 | script: bundle exec middleman build 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## Version 0.1 4 | 5 | *2018.4.11* 6 | 7 | - 文档结构初始化 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@lord.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | ruby '>=2.3.1' 2 | source 'https://rubygems.org' 3 | 4 | # Middleman 5 | gem 'middleman', '~>4.2.1' 6 | gem 'middleman-syntax', '~> 3.0.0' 7 | gem 'middleman-autoprefixer', '~> 2.7.0' 8 | gem "middleman-sprockets", "~> 4.1.0" 9 | gem 'rouge', '~> 2.0.5' 10 | gem 'redcarpet', '~> 3.4.0' 11 | gem 'nokogiri', '~> 1.8.2' 12 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | activesupport (5.0.7) 5 | concurrent-ruby (~> 1.0, >= 1.0.2) 6 | i18n (>= 0.7, < 2) 7 | minitest (~> 5.1) 8 | tzinfo (~> 1.1) 9 | addressable (2.5.2) 10 | public_suffix (>= 2.0.2, < 4.0) 11 | autoprefixer-rails (6.7.7.2) 12 | execjs 13 | backports (3.11.3) 14 | coffee-script (2.4.1) 15 | coffee-script-source 16 | execjs 17 | coffee-script-source (1.12.2) 18 | compass-import-once (1.0.5) 19 | sass (>= 3.2, < 3.5) 20 | concurrent-ruby (1.0.5) 21 | contracts (0.13.0) 22 | dotenv (2.4.0) 23 | erubis (2.7.0) 24 | execjs (2.7.0) 25 | fast_blank (1.0.0) 26 | fastimage (2.1.3) 27 | ffi (1.9.23) 28 | haml (5.0.4) 29 | temple (>= 0.8.0) 30 | tilt 31 | hamster (3.0.0) 32 | concurrent-ruby (~> 1.0) 33 | hashie (3.5.7) 34 | i18n (0.7.0) 35 | kramdown (1.16.2) 36 | listen (3.0.8) 37 | rb-fsevent (~> 0.9, >= 0.9.4) 38 | rb-inotify (~> 0.9, >= 0.9.7) 39 | memoist (0.16.0) 40 | middleman (4.2.1) 41 | coffee-script (~> 2.2) 42 | compass-import-once (= 1.0.5) 43 | haml (>= 4.0.5) 44 | kramdown (~> 1.2) 45 | middleman-cli (= 4.2.1) 46 | middleman-core (= 4.2.1) 47 | sass (>= 3.4.0, < 4.0) 48 | middleman-autoprefixer (2.7.1) 49 | autoprefixer-rails (>= 6.5.2, < 7.0.0) 50 | middleman-core (>= 3.3.3) 51 | middleman-cli (4.2.1) 52 | thor (>= 0.17.0, < 2.0) 53 | middleman-core (4.2.1) 54 | activesupport (>= 4.2, < 5.1) 55 | addressable (~> 2.3) 56 | backports (~> 3.6) 57 | bundler (~> 1.1) 58 | contracts (~> 0.13.0) 59 | dotenv 60 | erubis 61 | execjs (~> 2.0) 62 | fast_blank 63 | fastimage (~> 2.0) 64 | hamster (~> 3.0) 65 | hashie (~> 3.4) 66 | i18n (~> 0.7.0) 67 | listen (~> 3.0.0) 68 | memoist (~> 0.14) 69 | padrino-helpers (~> 0.13.0) 70 | parallel 71 | rack (>= 1.4.5, < 3) 72 | sass (>= 3.4) 73 | servolux 74 | tilt (~> 2.0) 75 | uglifier (~> 3.0) 76 | middleman-sprockets (4.1.1) 77 | middleman-core (~> 4.0) 78 | sprockets (>= 3.0) 79 | middleman-syntax (3.0.0) 80 | middleman-core (>= 3.2) 81 | rouge (~> 2.0) 82 | mini_portile2 (2.3.0) 83 | minitest (5.11.3) 84 | nokogiri (1.8.2) 85 | mini_portile2 (~> 2.3.0) 86 | padrino-helpers (0.13.3.4) 87 | i18n (~> 0.6, >= 0.6.7) 88 | padrino-support (= 0.13.3.4) 89 | tilt (>= 1.4.1, < 3) 90 | padrino-support (0.13.3.4) 91 | activesupport (>= 3.1) 92 | parallel (1.12.1) 93 | public_suffix (3.0.2) 94 | rack (2.0.5) 95 | rb-fsevent (0.10.3) 96 | rb-inotify (0.9.10) 97 | ffi (>= 0.5.0, < 2) 98 | redcarpet (3.4.0) 99 | rouge (2.0.7) 100 | sass (3.4.25) 101 | servolux (0.13.0) 102 | sprockets (3.7.1) 103 | concurrent-ruby (~> 1.0) 104 | rack (> 1, < 3) 105 | temple (0.8.0) 106 | thor (0.20.0) 107 | thread_safe (0.3.6) 108 | tilt (2.0.8) 109 | tzinfo (1.2.5) 110 | thread_safe (~> 0.1) 111 | uglifier (3.2.0) 112 | execjs (>= 0.3.0, < 3) 113 | 114 | PLATFORMS 115 | ruby 116 | 117 | DEPENDENCIES 118 | middleman (~> 4.2.1) 119 | middleman-autoprefixer (~> 2.7.0) 120 | middleman-sprockets (~> 4.1.0) 121 | middleman-syntax (~> 3.0.0) 122 | nokogiri (~> 1.8.2) 123 | redcarpet (~> 3.4.0) 124 | rouge (~> 2.0.5) 125 | 126 | RUBY VERSION 127 | ruby 2.4.1p111 128 | 129 | BUNDLED WITH 130 | 1.16.1 131 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008-2013 Concur Technologies, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | not use this file except in compliance with the License. You may obtain 5 | a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | License for the specific language governing permissions and limitations 13 | under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 说明 2 | 3 | 文档使用 `slate` 搭建,详情请参考:https://github.com/lord/slate 4 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure(2) do |config| 2 | config.vm.box = "ubuntu/trusty64" 3 | config.vm.network :forwarded_port, guest: 4567, host: 4567 4 | 5 | config.vm.provision "bootstrap", 6 | type: "shell", 7 | inline: <<-SHELL 8 | sudo apt-add-repository ppa:brightbox/ruby-ng 9 | sudo apt-get update 10 | sudo apt-get install -yq ruby2.4 ruby2.4-dev 11 | sudo apt-get install -yq pkg-config build-essential nodejs git libxml2-dev libxslt-dev 12 | sudo apt-get autoremove -yq 13 | gem2.4 install --no-ri --no-rdoc bundler 14 | SHELL 15 | 16 | # add the local user git config to the vm 17 | config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig" 18 | 19 | config.vm.provision "install", 20 | type: "shell", 21 | privileged: false, 22 | inline: <<-SHELL 23 | echo "==============================================" 24 | echo "Installing app dependencies" 25 | cd /vagrant 26 | bundle config build.nokogiri --use-system-libraries 27 | bundle install 28 | SHELL 29 | 30 | config.vm.provision "run", 31 | type: "shell", 32 | privileged: false, 33 | run: "always", 34 | inline: <<-SHELL 35 | echo "==============================================" 36 | echo "Starting up middleman at http://localhost:4567" 37 | echo "If it does not come up, check the ~/middleman.log file for any error messages" 38 | cd /vagrant 39 | bundle exec middleman server --watcher-force-polling --watcher-latency=1 &> ~/middleman.log & 40 | SHELL 41 | end -------------------------------------------------------------------------------- /config.rb: -------------------------------------------------------------------------------- 1 | # Unique header generation 2 | require './lib/unique_head.rb' 3 | 4 | # Markdown 5 | set :markdown_engine, :redcarpet 6 | set :markdown, 7 | fenced_code_blocks: true, 8 | smartypants: true, 9 | disable_indented_code_blocks: true, 10 | prettify: true, 11 | tables: true, 12 | with_toc_data: true, 13 | no_intra_emphasis: true, 14 | renderer: UniqueHeadCounter 15 | 16 | # Assets 17 | set :css_dir, 'stylesheets' 18 | set :js_dir, 'javascripts' 19 | set :images_dir, 'images' 20 | set :fonts_dir, 'fonts' 21 | 22 | # Activate the syntax highlighter 23 | activate :syntax 24 | ready do 25 | require './lib/multilang.rb' 26 | end 27 | 28 | activate :sprockets 29 | 30 | activate :autoprefixer do |config| 31 | config.browsers = ['last 2 version', 'Firefox ESR'] 32 | config.cascade = false 33 | config.inline = true 34 | end 35 | 36 | # Github pages require relative links 37 | activate :relative_assets 38 | set :relative_links, true 39 | 40 | # Build Configuration 41 | configure :build do 42 | # If you're having trouble with Middleman hanging, commenting 43 | # out the following two lines has been known to help 44 | activate :minify_css 45 | activate :minify_javascript 46 | # activate :relative_assets 47 | # activate :asset_hash 48 | # activate :gzip 49 | end 50 | 51 | # Deploy Configuration 52 | # If you want Middleman to listen on a different port, you can set that below 53 | set :port, 4567 54 | 55 | helpers do 56 | require './lib/toc_data.rb' 57 | end 58 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -o errexit #abort if any command fails 3 | me=$(basename "$0") 4 | 5 | help_message="\ 6 | Usage: $me [-c FILE] [] 7 | Deploy generated files to a git branch. 8 | 9 | Options: 10 | 11 | -h, --help Show this help information. 12 | -v, --verbose Increase verbosity. Useful for debugging. 13 | -e, --allow-empty Allow deployment of an empty directory. 14 | -m, --message MESSAGE Specify the message used when committing on the 15 | deploy branch. 16 | -n, --no-hash Don't append the source commit's hash to the deploy 17 | commit's message. 18 | --source-only Only build but not push 19 | --push-only Only push but not build 20 | " 21 | 22 | 23 | run_build() { 24 | bundle exec middleman build --clean 25 | } 26 | 27 | parse_args() { 28 | # Set args from a local environment file. 29 | if [ -e ".env" ]; then 30 | source .env 31 | fi 32 | 33 | # Parse arg flags 34 | # If something is exposed as an environment variable, set/overwrite it 35 | # here. Otherwise, set/overwrite the internal variable instead. 36 | while : ; do 37 | if [[ $1 = "-h" || $1 = "--help" ]]; then 38 | echo "$help_message" 39 | return 0 40 | elif [[ $1 = "-v" || $1 = "--verbose" ]]; then 41 | verbose=true 42 | shift 43 | elif [[ $1 = "-e" || $1 = "--allow-empty" ]]; then 44 | allow_empty=true 45 | shift 46 | elif [[ ( $1 = "-m" || $1 = "--message" ) && -n $2 ]]; then 47 | commit_message=$2 48 | shift 2 49 | elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then 50 | GIT_DEPLOY_APPEND_HASH=false 51 | shift 52 | else 53 | break 54 | fi 55 | done 56 | 57 | # Set internal option vars from the environment and arg flags. All internal 58 | # vars should be declared here, with sane defaults if applicable. 59 | 60 | # Source directory & target branch. 61 | deploy_directory=build 62 | deploy_branch=gh-pages 63 | 64 | #if no user identity is already set in the current git environment, use this: 65 | default_username=${GIT_DEPLOY_USERNAME:-deploy.sh} 66 | default_email=${GIT_DEPLOY_EMAIL:-} 67 | 68 | #repository to deploy to. must be readable and writable. 69 | repo=origin 70 | 71 | #append commit hash to the end of message by default 72 | append_hash=${GIT_DEPLOY_APPEND_HASH:-true} 73 | } 74 | 75 | main() { 76 | parse_args "$@" 77 | 78 | enable_expanded_output 79 | 80 | if ! git diff --exit-code --quiet --cached; then 81 | echo Aborting due to uncommitted changes in the index >&2 82 | return 1 83 | fi 84 | 85 | commit_title=`git log -n 1 --format="%s" HEAD` 86 | commit_hash=` git log -n 1 --format="%H" HEAD` 87 | 88 | #default commit message uses last title if a custom one is not supplied 89 | if [[ -z $commit_message ]]; then 90 | commit_message="publish: $commit_title" 91 | fi 92 | 93 | #append hash to commit message unless no hash flag was found 94 | if [ $append_hash = true ]; then 95 | commit_message="$commit_message"$'\n\n'"generated from commit $commit_hash" 96 | fi 97 | 98 | previous_branch=`git rev-parse --abbrev-ref HEAD` 99 | 100 | if [ ! -d "$deploy_directory" ]; then 101 | echo "Deploy directory '$deploy_directory' does not exist. Aborting." >&2 102 | return 1 103 | fi 104 | 105 | # must use short form of flag in ls for compatibility with OS X and BSD 106 | if [[ -z `ls -A "$deploy_directory" 2> /dev/null` && -z $allow_empty ]]; then 107 | echo "Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag." >&2 108 | return 1 109 | fi 110 | 111 | if git ls-remote --exit-code $repo "refs/heads/$deploy_branch" ; then 112 | # deploy_branch exists in $repo; make sure we have the latest version 113 | 114 | disable_expanded_output 115 | git fetch --force $repo $deploy_branch:$deploy_branch 116 | enable_expanded_output 117 | fi 118 | 119 | # check if deploy_branch exists locally 120 | if git show-ref --verify --quiet "refs/heads/$deploy_branch" 121 | then incremental_deploy 122 | else initial_deploy 123 | fi 124 | 125 | restore_head 126 | } 127 | 128 | initial_deploy() { 129 | git --work-tree "$deploy_directory" checkout --orphan $deploy_branch 130 | git --work-tree "$deploy_directory" add --all 131 | commit+push 132 | } 133 | 134 | incremental_deploy() { 135 | #make deploy_branch the current branch 136 | git symbolic-ref HEAD refs/heads/$deploy_branch 137 | #put the previously committed contents of deploy_branch into the index 138 | git --work-tree "$deploy_directory" reset --mixed --quiet 139 | git --work-tree "$deploy_directory" add --all 140 | 141 | set +o errexit 142 | diff=$(git --work-tree "$deploy_directory" diff --exit-code --quiet HEAD --)$? 143 | set -o errexit 144 | case $diff in 145 | 0) echo No changes to files in $deploy_directory. Skipping commit.;; 146 | 1) commit+push;; 147 | *) 148 | echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2 149 | return $diff 150 | ;; 151 | esac 152 | } 153 | 154 | commit+push() { 155 | set_user_id 156 | git --work-tree "$deploy_directory" commit -m "$commit_message" 157 | 158 | disable_expanded_output 159 | #--quiet is important here to avoid outputting the repo URL, which may contain a secret token 160 | git push --quiet $repo $deploy_branch 161 | enable_expanded_output 162 | } 163 | 164 | #echo expanded commands as they are executed (for debugging) 165 | enable_expanded_output() { 166 | if [ $verbose ]; then 167 | set -o xtrace 168 | set +o verbose 169 | fi 170 | } 171 | 172 | #this is used to avoid outputting the repo URL, which may contain a secret token 173 | disable_expanded_output() { 174 | if [ $verbose ]; then 175 | set +o xtrace 176 | set -o verbose 177 | fi 178 | } 179 | 180 | set_user_id() { 181 | if [[ -z `git config user.name` ]]; then 182 | git config user.name "$default_username" 183 | fi 184 | if [[ -z `git config user.email` ]]; then 185 | git config user.email "$default_email" 186 | fi 187 | } 188 | 189 | restore_head() { 190 | if [[ $previous_branch = "HEAD" ]]; then 191 | #we weren't on any branch before, so just set HEAD back to the commit it was on 192 | git update-ref --no-deref HEAD $commit_hash $deploy_branch 193 | else 194 | git symbolic-ref HEAD refs/heads/$previous_branch 195 | fi 196 | 197 | git reset --mixed 198 | } 199 | 200 | filter() { 201 | sed -e "s|$repo|\$repo|g" 202 | } 203 | 204 | sanitize() { 205 | "$@" 2> >(filter 1>&2) | filter 206 | } 207 | 208 | if [[ $1 = --source-only ]]; then 209 | run_build 210 | elif [[ $1 = --push-only ]]; then 211 | main "$@" 212 | else 213 | run_build 214 | main "$@" 215 | fi 216 | -------------------------------------------------------------------------------- /font-selection.json: -------------------------------------------------------------------------------- 1 | { 2 | "IcoMoonType": "selection", 3 | "icons": [ 4 | { 5 | "icon": { 6 | "paths": [ 7 | "M438.857 73.143q119.429 0 220.286 58.857t159.714 159.714 58.857 220.286-58.857 220.286-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857zM512 785.714v-108.571q0-8-5.143-13.429t-12.571-5.429h-109.714q-7.429 0-13.143 5.714t-5.714 13.143v108.571q0 7.429 5.714 13.143t13.143 5.714h109.714q7.429 0 12.571-5.429t5.143-13.429zM510.857 589.143l10.286-354.857q0-6.857-5.714-10.286-5.714-4.571-13.714-4.571h-125.714q-8 0-13.714 4.571-5.714 3.429-5.714 10.286l9.714 354.857q0 5.714 5.714 10t13.714 4.286h105.714q8 0 13.429-4.286t6-10z" 8 | ], 9 | "attrs": [], 10 | "isMulticolor": false, 11 | "tags": [ 12 | "exclamation-circle" 13 | ], 14 | "defaultCode": 61546, 15 | "grid": 14 16 | }, 17 | "attrs": [], 18 | "properties": { 19 | "id": 100, 20 | "order": 4, 21 | "prevSize": 28, 22 | "code": 58880, 23 | "name": "exclamation-sign", 24 | "ligatures": "" 25 | }, 26 | "setIdx": 0, 27 | "iconIdx": 0 28 | }, 29 | { 30 | "icon": { 31 | "paths": [ 32 | "M585.143 786.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-54.857v-292.571q0-8-5.143-13.143t-13.143-5.143h-182.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h54.857v182.857h-54.857q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h256q8 0 13.143-5.143t5.143-13.143zM512 274.286v-91.429q0-8-5.143-13.143t-13.143-5.143h-109.714q-8 0-13.143 5.143t-5.143 13.143v91.429q0 8 5.143 13.143t13.143 5.143h109.714q8 0 13.143-5.143t5.143-13.143zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" 33 | ], 34 | "attrs": [], 35 | "isMulticolor": false, 36 | "tags": [ 37 | "info-circle" 38 | ], 39 | "defaultCode": 61530, 40 | "grid": 14 41 | }, 42 | "attrs": [], 43 | "properties": { 44 | "id": 85, 45 | "order": 3, 46 | "name": "info-sign", 47 | "prevSize": 28, 48 | "code": 58882 49 | }, 50 | "setIdx": 0, 51 | "iconIdx": 2 52 | }, 53 | { 54 | "icon": { 55 | "paths": [ 56 | "M733.714 419.429q0-16-10.286-26.286l-52-51.429q-10.857-10.857-25.714-10.857t-25.714 10.857l-233.143 232.571-129.143-129.143q-10.857-10.857-25.714-10.857t-25.714 10.857l-52 51.429q-10.286 10.286-10.286 26.286 0 15.429 10.286 25.714l206.857 206.857q10.857 10.857 25.714 10.857 15.429 0 26.286-10.857l310.286-310.286q10.286-10.286 10.286-25.714zM877.714 512q0 119.429-58.857 220.286t-159.714 159.714-220.286 58.857-220.286-58.857-159.714-159.714-58.857-220.286 58.857-220.286 159.714-159.714 220.286-58.857 220.286 58.857 159.714 159.714 58.857 220.286z" 57 | ], 58 | "attrs": [], 59 | "isMulticolor": false, 60 | "tags": [ 61 | "check-circle" 62 | ], 63 | "defaultCode": 61528, 64 | "grid": 14 65 | }, 66 | "attrs": [], 67 | "properties": { 68 | "id": 83, 69 | "order": 9, 70 | "prevSize": 28, 71 | "code": 58886, 72 | "name": "ok-sign" 73 | }, 74 | "setIdx": 0, 75 | "iconIdx": 6 76 | }, 77 | { 78 | "icon": { 79 | "paths": [ 80 | "M658.286 475.429q0-105.714-75.143-180.857t-180.857-75.143-180.857 75.143-75.143 180.857 75.143 180.857 180.857 75.143 180.857-75.143 75.143-180.857zM950.857 950.857q0 29.714-21.714 51.429t-51.429 21.714q-30.857 0-51.429-21.714l-196-195.429q-102.286 70.857-228 70.857-81.714 0-156.286-31.714t-128.571-85.714-85.714-128.571-31.714-156.286 31.714-156.286 85.714-128.571 128.571-85.714 156.286-31.714 156.286 31.714 128.571 85.714 85.714 128.571 31.714 156.286q0 125.714-70.857 228l196 196q21.143 21.143 21.143 51.429z" 81 | ], 82 | "width": 951, 83 | "attrs": [], 84 | "isMulticolor": false, 85 | "tags": [ 86 | "search" 87 | ], 88 | "defaultCode": 61442, 89 | "grid": 14 90 | }, 91 | "attrs": [], 92 | "properties": { 93 | "id": 2, 94 | "order": 1, 95 | "prevSize": 28, 96 | "code": 58887, 97 | "name": "icon-search" 98 | }, 99 | "setIdx": 0, 100 | "iconIdx": 7 101 | } 102 | ], 103 | "height": 1024, 104 | "metadata": { 105 | "name": "slate", 106 | "license": "SIL OFL 1.1" 107 | }, 108 | "preferences": { 109 | "showGlyphs": true, 110 | "showQuickUse": true, 111 | "showQuickUse2": true, 112 | "showSVGs": true, 113 | "fontPref": { 114 | "prefix": "icon-", 115 | "metadata": { 116 | "fontFamily": "slate", 117 | "majorVersion": 1, 118 | "minorVersion": 0, 119 | "description": "Based on FontAwesome", 120 | "license": "SIL OFL 1.1" 121 | }, 122 | "metrics": { 123 | "emSize": 1024, 124 | "baseline": 6.25, 125 | "whitespace": 50 126 | }, 127 | "resetPoint": 58880, 128 | "showSelector": false, 129 | "selector": "class", 130 | "classSelector": ".icon", 131 | "showMetrics": false, 132 | "showMetadata": true, 133 | "showVersion": true, 134 | "ie7": false 135 | }, 136 | "imagePref": { 137 | "prefix": "icon-", 138 | "png": true, 139 | "useClassSelector": true, 140 | "color": 4473924, 141 | "bgColor": 16777215 142 | }, 143 | "historySize": 100, 144 | "showCodes": true, 145 | "gridSize": 16, 146 | "showLiga": false 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /lib/multilang.rb: -------------------------------------------------------------------------------- 1 | module Multilang 2 | def block_code(code, full_lang_name) 3 | if full_lang_name 4 | parts = full_lang_name.split('--') 5 | rouge_lang_name = (parts) ? parts[0] : "" # just parts[0] here causes null ref exception when no language specified 6 | super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match| 7 | match + " tab-" + full_lang_name 8 | end 9 | else 10 | super(code, full_lang_name) 11 | end 12 | end 13 | end 14 | 15 | require 'middleman-core/renderers/redcarpet' 16 | Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, Multilang 17 | -------------------------------------------------------------------------------- /lib/nesting_unique_head.rb: -------------------------------------------------------------------------------- 1 | # Nested unique header generation 2 | require 'middleman-core/renderers/redcarpet' 3 | 4 | class NestingUniqueHeadCounter < Middleman::Renderers::MiddlemanRedcarpetHTML 5 | def initialize 6 | super 7 | @@headers_history = {} if !defined?(@@headers_history) 8 | end 9 | 10 | def header(text, header_level) 11 | friendly_text = text.parameterize 12 | @@headers_history[header_level] = text.parameterize 13 | 14 | if header_level > 1 15 | for i in (header_level - 1).downto(1) 16 | friendly_text.prepend("#{@@headers_history[i]}-") if @@headers_history.key?(i) 17 | end 18 | end 19 | 20 | return "#{text}" 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /lib/toc_data.rb: -------------------------------------------------------------------------------- 1 | require 'nokogiri' 2 | 3 | def toc_data(page_content) 4 | html_doc = Nokogiri::HTML::DocumentFragment.parse(page_content) 5 | 6 | # get a flat list of headers 7 | headers = [] 8 | html_doc.css('h1, h2, h3').each do |header| 9 | headers.push({ 10 | id: header.attribute('id').to_s, 11 | content: header.children, 12 | level: header.name[1].to_i, 13 | children: [] 14 | }) 15 | end 16 | 17 | [3,2].each do |header_level| 18 | header_to_nest = nil 19 | headers = headers.reject do |header| 20 | if header[:level] == header_level 21 | header_to_nest[:children].push header if header_to_nest 22 | true 23 | else 24 | header_to_nest = header if header[:level] < header_level 25 | false 26 | end 27 | end 28 | end 29 | headers 30 | end -------------------------------------------------------------------------------- /lib/unique_head.rb: -------------------------------------------------------------------------------- 1 | # Unique header generation 2 | require 'middleman-core/renderers/redcarpet' 3 | require 'digest' 4 | class UniqueHeadCounter < Middleman::Renderers::MiddlemanRedcarpetHTML 5 | def initialize 6 | super 7 | @head_count = {} 8 | end 9 | def header(text, header_level) 10 | friendly_text = text.gsub(/<[^<]+>/,"").parameterize 11 | if friendly_text.strip.length == 0 12 | # Looks like parameterize removed the whole thing! It removes many unicode 13 | # characters like Chinese and Russian. To get a unique URL, let's just 14 | # URI escape the whole header 15 | friendly_text = Digest::SHA1.hexdigest(text)[0,10] 16 | end 17 | @head_count[friendly_text] ||= 0 18 | @head_count[friendly_text] += 1 19 | if @head_count[friendly_text] > 1 20 | friendly_text += "-#{@head_count[friendly_text]}" 21 | end 22 | return "#{text}" 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /source/CNAME: -------------------------------------------------------------------------------- 1 | developer.fcoin.com 2 | -------------------------------------------------------------------------------- /source/en.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: API Reference 3 | 4 | language_tabs: # must be one of https://git.io/vQNgJ 5 | - python 6 | - javascript 7 | 8 | toc_footers: 9 | - Apply API Key 10 | 11 | includes: 12 | - en/introduction 13 | - en/authentication 14 | - en/publics 15 | - en/markets 16 | - en/accounts 17 | - en/orders 18 | - en/order_errors 19 | - en/otc 20 | - en/leveraged 21 | - en/small_currency_exchange 22 | - en/errors 23 | 24 | search: true 25 | --- 26 | -------------------------------------------------------------------------------- /source/fonts/slate.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/fonts/slate.eot -------------------------------------------------------------------------------- /source/fonts/slate.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /source/fonts/slate.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/fonts/slate.ttf -------------------------------------------------------------------------------- /source/fonts/slate.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/fonts/slate.woff -------------------------------------------------------------------------------- /source/fonts/slate.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/fonts/slate.woff2 -------------------------------------------------------------------------------- /source/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/images/favicon.ico -------------------------------------------------------------------------------- /source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/images/logo.png -------------------------------------------------------------------------------- /source/images/navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FCoinCommunity/api-docs/2e2b47a0022582914512190a235e5151824949a6/source/images/navbar.png -------------------------------------------------------------------------------- /source/includes/en/_accounts.md: -------------------------------------------------------------------------------- 1 | # Accounts and assets 2 | 3 | ## Query account assets 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | api.accounts_balance 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let orders = api.accountsBalance; 17 | ``` 18 | 19 | > The response results are as follows: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": [ 25 | { 26 | "currency": "btc", 27 | "available": "50.0", 28 | "frozen": "50.0", 29 | "balance": "100.0" 30 | } 31 | ] 32 | } 33 | ``` 34 | 35 | This API is used to query a user's list of assets. 36 | 37 | ### HTTP Request 38 | 39 | `GET https://api.fcoin.com/v2/accounts/balance` 40 | -------------------------------------------------------------------------------- /source/includes/en/_authentication.md: -------------------------------------------------------------------------------- 1 | # Certification 2 | 3 | > Execute the following code for user identification: 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | ``` 10 | 11 | ```javascript 12 | const fcoin = require('fcoin'); 13 | 14 | let api = fcoin.authorize('key', 'secret', timestamp); 15 | ``` 16 | 17 | FCoin uses API key and API secret for identification,Please visit the settings center and register as a developer to obtain API key and API secret. 18 | 19 | In addition to the public API, API key and signature are also included in FCoin's API request 20 | 21 | 22 | 23 | 24 | ## Access restrictions 25 | 26 | The current access frequency is 100 times / 10 seconds per user, and the access frequency limit will be differentiated according to the service in the future. 27 | 28 | 29 | 30 | 31 | ## API signature 32 | 33 | The data prepared before signing is as follows: 34 | 35 | `HTTP_METHOD` + `HTTP_REQUEST_URI` + `TIMESTAMP` + `POST_BODY` 36 | 37 | After the connection is established, Base64 encoding is performed. The encoded data is HMAC-SHA1 signed, and the signature is subjected to secondary Base64 encoding. The various parts are explained as follows: 38 | 39 | 42 | 43 | ### HTTP_METHOD 44 | 45 | `GET`, `POST`, `DELETE`, `PUT` requires capitalization 46 | 47 | ### HTTP_REQUEST_URI 48 | 49 | `https://api.fcoin.com/v2/` is the prefix for v2 API request 50 | 51 | Add the resource path you really want to access, such as `orders?param1=value1`, and finally `https://api.fcoin.com/v2/orders?param1=value1` 52 | 53 | The parameters in the requested URI need to be sorted by alphabetically. 54 | 55 | That is, if the requested URI is `https://api.fcoin.com/v2/orders?c=value1&b=value2&a=value3`, then the request parameters should be sorted alphabetically before signing, and the final signed URI is `https://api.fcoin.com/v2/orders?a=value3&b=value2&c=value1`. Please note that the order of the three parameters in the original request URI is `c, b, a`, and then `a, b, c` after ordering. 56 | 57 | ### TIMESTAMP 58 | 59 | When accessing the API, the time difference between the UNIX EPOCH timestamp and the server should be no more than 30 seconds. 60 | 61 | ### POST_BODY 62 | 63 | If it is a POST request, the POST request data also needs to be signed: 64 | 65 | All the requested keys are sorted in alphabetical order, followed by url parameterization, and connected with `&`. 66 | 67 | 70 | 71 | > If the requested data is: 72 | 73 | ```json 74 | { 75 | "username": "username", 76 | "password": "passowrd" 77 | } 78 | ``` 79 | 80 | > then sort the key alphabetically and parameterize the url, ie: 81 | 82 | ``` 83 | password=password 84 | username=username 85 | ``` 86 | 87 | > Because `p` is sorted before `u` in the alphabet, `password` is placed before `username` and then connected with `&`, ie: 88 | 89 | ``` 90 | password=password&username=username 91 | ``` 92 | 93 | ## Full example 94 | 95 | > For the following requests: 96 | 97 | ``` 98 | POST https://api.fcoin.com/v2/orders 99 | 100 | { 101 | "type": "limit", 102 | "side": "buy", 103 | "amount": "100.0", 104 | "price": "100.0", 105 | "symbol": "btcusdt" 106 | } 107 | 108 | timestamp: 1523069544359 109 | ``` 110 | 111 | > The preparated data before signing is as follows: 112 | 113 | ``` 114 | POSThttps://api.fcoin.com/v2/orders1523069544359amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit 115 | ``` 116 | 117 | > Perform Base64 encoding to obtain: 118 | 119 | ``` 120 | UE9TVGh0dHBzOi8vYXBpLmZjb2luLmNvbS92Mi9vcmRlcnMxNTIzMDY5NTQ0MzU5YW1vdW50PTEwMC4wJnByaWNlPTEwMC4wJnNpZGU9YnV5JnN5bWJvbD1idGN1c2R0JnR5cGU9bGltaXQ= 121 | ``` 122 | 123 | > Copy the key obtained when applying for the API Key (API SECRET). The following signature result is taken `3600d0a74aa3410fb3b1996cca2419c8` as an example, 124 | 125 | > The obtained result is `HMAC-SHA1` signed with the secret key, and the binary result is `Base64` encoded, to obtain: 126 | 127 | ``` 128 | DeP6oftldIrys06uq3B7Lkh3a0U= 129 | ``` 130 | 131 | > That is, the final signature is generated for verification to the API server 132 | 133 | ## Parameter name 134 | 135 | * `FC-ACCESS-KEY` 136 | * `FC-ACCESS-SIGNATURE` 137 | * `FC-ACCESS-TIMESTAMP` 138 | 139 | ## Description 140 | 141 | You can use the developer tools (not yet open) for online joint debugging testing 142 | -------------------------------------------------------------------------------- /source/includes/en/_errors.md: -------------------------------------------------------------------------------- 1 | # Order error code 2 | 3 | Error Code | Interpretation 4 | ---------- | ------- 5 | 400 | Bad Request -- 错误的请求 6 | 401 | Unauthorized -- API key 或者签名,时间戳有误 7 | 403 | Forbidden -- 禁止访问 8 | 404 | Not Found -- 未找到请求的资源 9 | 405 | Method Not Allowed -- 使用的 HTTP 方法不适用于请求的资源 10 | 406 | Not Acceptable -- 请求的内容格式不是 JSON 11 | 429 | Too Many Requests -- 请求受限,请降低请求频率 12 | 500 | Internal Server Error -- 服务内部错误,请稍后再进行尝试 13 | 503 | Service Unavailable -- 服务不可用,请稍后再进行尝试 14 | -------------------------------------------------------------------------------- /source/includes/en/_introduction.md: -------------------------------------------------------------------------------- 1 | # Introduction 2 | 3 | By understanding the following information, you can easily use the API provided by FCoin to access the FCoin trading platform. 4 | -------------------------------------------------------------------------------- /source/includes/en/_leveraged.md: -------------------------------------------------------------------------------- 1 | # Margin 2 | ## Transfer to margin account 3 | This API is used to transfer the assets in trading account or financial account to margin account. 4 | 5 | ### HTTP Request 6 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/in` 7 | 8 | ### Required parameter 9 | |Parameter|Default|Description| 10 | |:------|:------:|:------| 11 | |amount|non|Transfer amount| 12 | |currency|Non|Currencies:usdt、btc、eth| 13 | |source_account_type|Non|Asset resource type:|exchange: trading account; assets: financial account 14 | |target_account_type|Non|Target account type:leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 15 | 16 | ``` 17 | { 18 | "amount": 1, 19 | "currency": "btc", 20 | "source_account_type": "exchange", 21 | "target_account_type": "leveraged_btcusdt" 22 | } 23 | ``` 24 | 25 | ### RSRES 26 | ``` 27 | { 28 | "data": null, 29 | "status": "ok" 30 | } 31 | ``` 32 | 33 | ## margin account asset transfer out 34 | This API is used to transfer the assets in margin account out to the trading account or financial account. 35 | 36 | ### HTTP Request 37 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/out` 38 | 39 | ### Required parameter 40 | |Parameter|Default|Description| 41 | |:------|:------:|:------| 42 | |amountNon|Transfer amount | 43 | |currency||Non|Currencies:usdt、btc、eth、eos、xrp| 44 | |source_account_type |Non|Asset resource type: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 45 | |target_account_type|Non|Target account type: exchange: trading account; assets:financial account| 46 | 47 | ``` 48 | { 49 | "amount": 1, 50 | "currency": "btc", 51 | "source_account_type": "leveraged_btcusdt", 52 | "target_account_type": "exchange" 53 | } 54 | ``` 55 | 56 | ### RSRES 57 | ``` 58 | { 59 | "data": null, 60 | "status": "ok" 61 | } 62 | ``` 63 | 64 | ## Obtain the balance of certain currencies in margin account 65 | 66 | ### request url 67 | 68 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts/account` 69 | 70 | ### Required parameter 71 | |Parameter|Default|Description| 72 | |:------|:------:|:------| 73 | |account_type|Non|margin account type:btcusdt/ethusdt 74 | 75 | ### RSRES type 76 | 77 | ``` 78 | { 79 | "status": "ok", 80 | "data": { 81 | "open": true, #has opened the margin account of this type yet? true;false: 82 | "leveraged_account_type": "btcusdt", #margin account type 83 | "base": "btc", #base currency 84 | "quote": "usdt", #dominated currency 85 | "available_base_currency_amount": "1001.00", #available asset of base currencies 86 | "frozen_base_currency_amount": "0", #frozen asset of base currencies 87 | "available_quote_currency_amount": "100100", #available asset of dominated currencies 88 | "frozen_quote_currency_amount": "0", #frozen asset of dominated currencies 89 | "available_base_currency_loan_amount": "2.000", #base currencies amount you can borrow 90 | "available_quote_currency_loan_amount": "300.000",#dominated currencies amount you can borrow 91 | "blow_up_price": null, #blow-up price 92 | "risk_rate": "0.90", #blow-up risk ratios 93 | "state": "open" #account state. close ;open-has borrow any loans yet ;normal has borrowed-normal risk ratio; blow_up ;overrun ", allowableValues = "close,open,normal,blow_up,overrun") 94 | 95 | } 96 | } 97 | ``` 98 | 99 | 100 | ## btain the balance of all currencies in margin account 101 | 102 | ### request url 103 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts` 104 | 105 | ### Required parameter 106 | Non 107 | ### RSRES 108 | ``` 109 | { 110 | "status": "ok", 111 | "data": [ 112 | { 113 | "open": true, #has opened the margin account of this type yet? true;false: 114 | "leveraged_account_type": "btcusdt", #margin account type 115 | "base": "btc", #base currency 116 | "quote": "usdt", #dominated currency 117 | "available_base_currency_amount": "1001.00", #available asset of base currencies 118 | 119 | "frozen_base_currency_amount": "0", #frozen asset of base currencies 120 | 121 | "available_quote_currency_amount": "100100", #available asset of dominated currencies 122 | 123 | "frozen_quote_currency_amount": "0", #frozen asset of dominated currencies 124 | 125 | "available_base_currency_loan_amount": "2.000", #base currencies amount you can borrow 126 | 127 | "available_quote_currency_loan_amount": "300.000",#dominated currencies amount you can borrow 128 | 129 | "blow_up_price": null, #blow-up price 130 | "risk_rate": "0.90", #blow-up risk 131 | "state": "open" #account state. close; open-has borrow any loans yet ;normal has borrowed-normal risk ratio; blow_up ;overrun ", 132 | } 133 | ] 134 | } 135 | ``` -------------------------------------------------------------------------------- /source/includes/en/_markets.md: -------------------------------------------------------------------------------- 1 | # Market 2 | 3 | ## Market overview 4 | 5 | The market is a fully public API, which currently provides both HTTP and WebSocket APIs. 6 | In order to ensure more timely access to the market, it is recommended to use WebSocket to access. 7 | For the real-time performance of the market as much as possible, the current public part can only obtain the most recent market information. If there is a need to obtain the full amount or historical market information, please consult `support@fcoin.com` 8 | 9 | The URL base for all HTTP requests is: `https://api.fcoin.com/v2/market` 10 | 11 | The requested URL for all WebSocket is: `wss://api.fcoin.com/v2/ws` 12 | 13 | Terminology will be consistent below: 14 | 15 | - `topic` indicates the topic that has been subscribed. 16 | - `symbol` indicates the corresponding trading currency. 17 | - `ticker` market and tick information include the latest transaction price, the latest transaction volume, buy 1 sell 1, and the transaction 18 | - `depth` indicates the depth of market, order, handicap. 19 | - `level` indicates the type of market depth. Such as `L20`, `L150`. 20 | - `trade` indicates the latest transactions and latest deals. 21 | - `candle` represents candlestick chart, candlestick, K-line. 22 | - `resolution` indicates the type of candlestick.. Such as `M1`, `M15`. 23 | - `base volume` indicates the base currency volume, such as the amount of btc in btcusdt. 24 | - `quote volume` represents the volume of the quote currency, such as the volume of the usdt in btcusdt. 25 | - `ts` indicates the time to push the server. It Is numeric field, and unix epoch in millisecond. 26 | 27 | ## WebSocket’s first connection is established. 28 | 29 | The server sends a welcome message 30 | 31 | > Server return 32 | 33 | ```json 34 | { 35 | "type":"hello", 36 | "ts":1523693784042 37 | } 38 | ``` 39 | 40 | - `ts`: push the current time of the server. 41 | 42 | ## WebSocket connection retention - heartbeat 43 | 44 | After the WebSocket client establishes a connection with the WebSocket server, it is recommended that the WebSocket Client initiate a ping request to the server every 30 seconds (this frequency may change). If the server does not receive the client's ping request for a long time, it will actively disconnect (300s). 45 | 46 | ### WebSocket requests 47 | 48 | ```python 49 | import time 50 | import fcoin 51 | 52 | api = fcoin.authorize('key', 'secret', timestamp) 53 | now_ms = int(time.time()) 54 | api.market.ping(now_ms) 55 | ``` 56 | 57 | 58 | > Server return 59 | 60 | ```json 61 | { 62 | "type":"ping", 63 | "ts":1523693784042, 64 | "gap":112 65 | } 66 | ``` 67 | 68 | - `gap`: the gap between the time that the push server processes this statement and the client's transmission. 69 | - `ts`: push the current time of the server. 70 | 71 | ## Get push server time 72 | 73 | The gap between the push server time and data transfer time can be obtained by the ts and gap values returned by the server at the time of the ping request 74 | 75 | - gap: the gap between the time that the push server processes this statement and the client's transmission. 76 | - ts: push the current time of the server. 77 | 78 | 79 | ## Get ticker data 80 | 81 | To make the ticker Information Group small and fast enough, we enforced the list format. 82 | 83 | > The description of the corresponding field of the ticker list: 84 | 85 | ```json 86 | [ 87 | "Latest transaction price", 88 | "the most recent trading volume", 89 | "The highest buy 1 price", 90 | "The biggest buy 1 volume", 91 | "The lowest sell 1 price", 92 | "The smallest sell 1 volume", 93 | "The transaction price before 24 hours", 94 | "The highest price in 24 hours", 95 | "The lowest price in 24 hours", 96 | "The base currency volume within 24 hours, such as the amount of btc in btcusdt", 97 | "Priced currency volume within 24 hours, such as the amount of usdt in btcusdt" 98 | ] 99 | ``` 100 | 101 | 102 | ### HTTP requests 103 | 104 | `GET https://api.fcoin.com/v2/market/ticker/$symbol` 105 | 106 | ```python 107 | import fcoin 108 | 109 | api = fcoin.authorize('key', 'secret', timestamp) 110 | api.market.get_ticker("ethbtc") 111 | 112 | ``` 113 | 114 | ```json 115 | { 116 | "status": 0, 117 | "data": { 118 | "type": "ticker.btcusdt", 119 | "seq": 680035, 120 | "ticker": [ 121 | 7140.890000000000000000, 122 | 1.000000000000000000, 123 | 7131.330000000, 124 | 233.524600000, 125 | 7140.890000000, 126 | 225.495049866, 127 | 7140.890000000, 128 | 7140.890000000, 129 | 7140.890000000, 130 | 1.000000000, 131 | 7140.890000000000000000 132 | ] 133 | } 134 | } 135 | ``` 136 | 137 | ### WebSocket subscription 138 | 139 | topic: `ticker.$symbol` 140 | 141 | ```python 142 | import fcoin 143 | 144 | fcoin_ws = fcoin.init_ws() 145 | topics = ["ticker.ethbtc", "ticker.btcusdt"] 146 | fcoin_ws.handle(print) 147 | fcoin_ws.sub(topics) 148 | ``` 149 | 150 | > The results of a successful response to the subscription are as follows: 151 | 152 | ```json 153 | { 154 | "type": "topics", 155 | "topics": ["ticker.ethbtc", "ticker.btcusdt"] 156 | } 157 | ``` 158 | 159 | > Regular push results: 160 | 161 | ```json 162 | { 163 | "type": "ticker.btcusdt", 164 | "seq": 680035, 165 | "ticker": [ 166 | 7140.890000000000000000, 167 | 1.000000000000000000, 168 | 7131.330000000, 169 | 233.524600000, 170 | 7140.890000000, 171 | 225.495049866, 172 | 7140.890000000, 173 | 7140.890000000, 174 | 7140.890000000, 175 | 1.000000000, 176 | 7140.890000000000000000 177 | ] 178 | } 179 | ``` 180 | 181 | 182 | 183 | ## Get the latest trading details 184 | 185 | ### HTTP Request 186 | 187 | `GET https://api.fcoin.com/v2/market/depth/$level/$symbol` 188 | 189 | types of `$level` included: 190 | 191 | Type | Description 192 | -------- | -------- 193 | `L20` | 20 -level market depth. 194 | `L150` | 150 -level market depth. 195 | 196 | The `L20` push time will be slightly earlier than `L100`, and the push frequency will be slightly more than `L100`, depending on the specified pressure and situation. 197 | 198 | ### WebSocket subscription 199 | 200 | subscription topic: `depth.$level.$symbol` 201 | 202 | ```python 203 | import fcoin 204 | 205 | fcoin_ws = fcoin.init_ws() 206 | topics = ["depth.L20.ethbtc", "depth.L100.btcusdt"] 207 | fcoin_ws.handle(print) 208 | fcoin_ws.sub(topics) 209 | ``` 210 | 211 | ```javascript 212 | const fcoin = require('fcoin'); 213 | 214 | let fcoin_ws = fcoin.init_ws() 215 | topics = ["depth.L20.ethbtc", "depth.L100.btcusdt"] 216 | fcoin_ws.handle(print) 217 | fcoin_ws.sub(topics) 218 | ``` 219 | 220 | 221 | > The results of a successful response to the subscription are as follows: 222 | 223 | ```json 224 | { 225 | "type": "topics", 226 | "topics": ["depth.L20.ethbtc", "depth.L100.btcusdt"] 227 | } 228 | ``` 229 | 230 | > Regular push results 231 | 232 | The array corresponding to bids and asks must be an even number, buy (sell) 1 price, buy (sell) 1 volume, and arrange them one after the other. 233 | 234 | ```json 235 | { 236 | "type": "depth.L20.ethbtc", 237 | "ts": 1523619211000, 238 | "seq": 120, 239 | "bids": [0.000100000, 1.000000000, 0.000010000, 1.000000000], 240 | "asks": [1.000000000, 1.000000000] 241 | } 242 | ``` 243 | 244 | ## Get the latest trading details 245 | 246 | By comparing the size of the transaction id to determine whether it is an updated transaction. {trade id} Note that the transaction id of the public market does not actually correspond to the transaction id in the clearing system due to the existence of the trade to transaction process. 247 | Even if the transaction is a record, there is no guarantee that the id will always be consistent when the latest transaction is re-acquired 248 | 249 | PS: in the historical market, the trading id remains constant. {transaction id} is only used as a market update notification and should not be used depending on the archive. 250 | 251 | 252 | ### HTTP Request 253 | 254 | `GET https://api.fcoin.com/v2/market/trades/$symbol` 255 | 256 | ### Query parameters(HTTP Query) 257 | 258 | Parameter | Default | Description 259 | --------- | ------- | ----------- 260 | before | | Query a trade before a specified id 261 | limit | | the default is 20 262 | 263 | ### WebSocket gets the most recent deal 264 | 265 | topic: `trade.$symbol` 266 | limit: the number of most recent transactions 267 | args: [topic, limit] 268 | 269 | ```python 270 | import fcoin 271 | 272 | fcoin_ws = fcoin.init_ws() 273 | topic = "trade.ethbtc" 274 | limit = 3 275 | args = [topic, limit] 276 | fcoin_ws.req(args, rep_handler) 277 | ``` 278 | 279 | > The result of a successful response to the request is as follows: 280 | 281 | ```json 282 | {"id":null, 283 | "ts":1523693400329, 284 | "data":[ 285 | { 286 | "amount":1.000000000, 287 | "ts":1523419946174, 288 | "id":76000, 289 | "side":"sell", 290 | "price":4.000000000 291 | }, 292 | { 293 | "amount":1.000000000, 294 | "ts":1523419114272, 295 | "id":74000, 296 | "side":"sell", 297 | "price":4.000000000 298 | }, 299 | { 300 | "amount":1.000000000, 301 | "ts":1523415182356, 302 | "id":71000, 303 | "side":"sell", 304 | "price":3.000000000 305 | } 306 | ] 307 | } 308 | ``` 309 | 310 | ### WebSocket subscription 311 | 312 | ```python 313 | import fcoin 314 | 315 | fcoin_ws = fcoin.init_ws() 316 | topics = ["trade.ethbtc", "trade.btcusdt"] 317 | fcoin_ws.handle(print) 318 | fcoin_ws.sub(topics) 319 | ``` 320 | 321 | > The results of a successful response to the subscription are as follows: 322 | 323 | ```json 324 | { 325 | "type": "topics", 326 | "topics": ["trade.ethbtc"] 327 | } 328 | ``` 329 | 330 | 331 | > Regular push results 332 | 333 | ```json 334 | { 335 | "type":"trade.ethbtc", 336 | "id":76000, 337 | "amount":1.000000000, 338 | "ts":1523419946174, 339 | "side":"sell", 340 | "price":4.000000000 341 | } 342 | ``` 343 | 344 | ## Get Candle information 345 | 346 | ### HTTP Request 347 | 348 | `GET https://api.fcoin.com/v2/market/candles/$resolution/$symbol` 349 | 350 | ### Query parameters(HTTP Query) 351 | 352 | Parameter | default | description 353 | --------- | ------- | ----------- 354 | before | | Query a candle before a specified id 355 | limit | | the default is 20 356 | 357 | Types contained in $resolution 358 | 359 | Type | Description 360 | -------- | -------- 361 | `M1` | 1 minute 362 | `M3` | 3 minutes 363 | `M5` | 5 minutes 364 | `M15` | 15 minutes 365 | `M30` | 30 minutes 366 | `H1` | 1 hour 367 | `H4` | 4 hours 368 | `H6` | 6 hours 369 | `D1` | 1 day 370 | `W1` | 1 Week 371 | `MN` | 1 month 372 | 373 | ### Candle data subscribed in Weboskcet 374 | 375 | topic: `candle.$resolution.$symbol` 376 | 377 | ```python 378 | import fcoin 379 | 380 | fcoin_ws = fcoin.init_ws() 381 | topics = ["candle.M1.ethbtc", "depth.L20.ethbtc", "trade.ethbtc"] 382 | fcoin_ws.handle(print) 383 | fcoin_ws.sub(topics) 384 | ``` 385 | 386 | > The results of a successful response to the subscription are as follows: 387 | 388 | 389 | ```json 390 | { 391 | "type": "topics", 392 | "topics": ["candle.M1.ethbtc"] 393 | } 394 | ``` 395 | 396 | > The notification message format for a regular subscription is as follows: 397 | 398 | ```json 399 | { 400 | "type":"candle.M1.ethbtc", 401 | "id":1523691480, 402 | "seq":11400000, 403 | "open":2.000000000, 404 | "close":2.000000000, 405 | "high":2.000000000, 406 | "low":2.000000000, 407 | "count":0, 408 | "base_vol":0, 409 | "quote_vol":0 410 | } 411 | ``` 412 | -------------------------------------------------------------------------------- /source/includes/en/_order_errors.md: -------------------------------------------------------------------------------- 1 | ## Order error code 2 | 3 | Error code | Explanation 4 | ---------- | ------- 5 | 2000 | Account error 6 | -------------------------------------------------------------------------------- /source/includes/en/_orders.md: -------------------------------------------------------------------------------- 1 | # Orders 2 | 3 | ## Description of the order model 4 | 5 | The order model consists of the following properties: 6 | 7 | Property | type | interpretation 8 | ---------- | ------- | ------- 9 | `id` | `String` | Order ID 10 | `symbol` | `String` | Trading pairs 11 | `side` | `String` | Trading direction(`buy`, `sell`) 12 | `type` | `String` | Order type(`limit`,`market`,`ioc`,`fok`) 13 | `price` | `String` | Order Price 14 | `amount` | `String` | Order quantity 15 | `state` | `String` | State of order 16 | `executed_value` | `String` | Traded 17 | `filled_amount` | `String` | Trading volume 18 | `fill_fees` | `String` | service fee 19 | `created_at` | `Long` | Creation time 20 | `source` | `String` | Source 21 | 22 | Description of state of order: 23 | 24 | Property | Description 25 | ----------- | ------- 26 | `submitted` | Submission completed 27 | `partial_filled` | Partially traded 28 | `partial_canceled` | Partial_filled canceled 29 | `filled` | wholly traded 30 | `canceled` | cancellation completed 31 | `pending_cancel` | the canceling is submitted 32 | 33 | ## Create a new order 34 | 35 | ```python 36 | import fcoin 37 | 38 | api = fcoin.authorize('key', 'secret', timestamp) 39 | order_create_param = fcoin.order_create_param('btcusdt', 'buy', 'limit', '8000.0', '1.0') 40 | api.orders.create(order_create_param) 41 | ``` 42 | 43 | ```javascript 44 | const fcoin = require('fcoin'); 45 | 46 | let api = fcoin.authorize('key', 'secret', timestamp); 47 | let orderCreateParam = fcoin.orderCreateParam('btcusdt', 'buy', 'limit', '8000.0', '1.0'); 48 | let orders = api.orders.create(orderCreateParam); 49 | ``` 50 | 51 | > The response results are as follows: 52 | 53 | ```json 54 | { 55 | "status": 0, 56 | "data": "9d17a03b852e48c0b3920c7412867623" 57 | } 58 | ``` 59 | 60 | This API is used to create new orders。 61 | 62 | ### HTTP Request 63 | 64 | `POST https://api.fcoin.com/v2/orders` 65 | 66 | ### Request parameters 67 | 68 | Parameter | Default | Description 69 | --------- | ------- | ----------- 70 | symbol | Null | trading pairs 71 | side | Null | trading direction 72 | type | Null | order type 73 | price | Null | price 74 | amount | Null | order volume 75 | exchange | Null | exchange 76 | account_type | Null | Order type(margin:margin) 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## Query order list 84 | 85 | ```python 86 | import fcoin 87 | 88 | api = fcoin.authorize('key', 'secret', timestamp) 89 | api.orders.get() 90 | ``` 91 | 92 | ```javascript 93 | const fcoin = require('fcoin'); 94 | 95 | let api = fcoin.authorize('key', 'secret', timestamp); 96 | let orders = api.orders.get(); 97 | ``` 98 | 99 | > The response results are as follows: 100 | 101 | ```json 102 | { 103 | "status": 0, 104 | "data": [ 105 | { 106 | "id": "string", 107 | "symbol": "string", 108 | "type": "limit", 109 | "side": "buy", 110 | "price": "string", 111 | "amount": "string", 112 | "state": "submitted", 113 | "executed_value": "string", 114 | "fill_fees": "string", 115 | "filled_amount": "string", 116 | "created_at": 0, 117 | "source": "web" 118 | } 119 | ] 120 | } 121 | ``` 122 | 123 | This API is used to query the order list. 124 | 125 | ### HTTP Request 126 | 127 | `GET https://api.fcoin.com/v2/orders` 128 | 129 | ### Query parameters 130 | 131 | Parameter | Default | Description 132 | --------- | ------- | ----------- 133 | symbol | | Trading pairs 134 | states | | State of Orders 135 | before | | query orders before a specified page 136 | after | | query orders after a specified page 137 | limit | | the number of orders in each page, the default is 20 138 | account_type | Null | Order type(margin:margin) 139 | 140 | 141 | 142 | 143 | 144 | ## Get the specified order 145 | 146 | ```python 147 | import fcoin 148 | 149 | api = fcoin.authorize('key', 'secret', timestamp) 150 | api.orders.get('9d17a03b852e48c0b3920c7412867623') 151 | ``` 152 | 153 | ```javascript 154 | const fcoin = require('fcoin'); 155 | 156 | let api = fcoin.authorize('key', 'secret', timestamp); 157 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623'); 158 | ``` 159 | 160 | > The response results are as follows: 161 | 162 | ```json 163 | { 164 | "status": 0, 165 | "data": { 166 | "id": "9d17a03b852e48c0b3920c7412867623", 167 | "symbol": "string", 168 | "type": "limit", 169 | "side": "buy", 170 | "price": "string", 171 | "amount": "string", 172 | "state": "submitted", 173 | "executed_value": "string", 174 | "fill_fees": "string", 175 | "filled_amount": "string", 176 | "created_at": 0, 177 | "source": "web" 178 | } 179 | } 180 | ``` 181 | 182 | This API is used to return the specified order details。 183 | 184 | ### HTTP Request 185 | 186 | `GET https://api.fcoin.com/v2/orders/{order_id}` 187 | 188 | ### URL Parameters 189 | 190 | Parameter | Description 191 | --------- | ----------- 192 | order_id | order ID 193 | 194 | 195 | 196 | 197 | 198 | 199 | ## Application for cancellation of order 200 | 201 | ```python 202 | import fcoin 203 | 204 | api = fcoin.authorize('key', 'secret', timestamp) 205 | api.orders.submit_cancel(2) 206 | ``` 207 | 208 | ```javascript 209 | const fcoin = require('fcoin'); 210 | 211 | let api = fcoin.authorize('key', 'secret', timestamp); 212 | let max = api.orders.submitCancel(2); 213 | ``` 214 | 215 | > The response results are as follows: 216 | 217 | ```json 218 | { 219 | "status": 0, 220 | "msg": "string", 221 | "data": true 222 | } 223 | ``` 224 | 225 | This API is used to cancel the specified order. The order canceling process is asynchronous. That is, the successful call of this API represents that the order has entered the revocation request. Further processing of matching is required before the confirmation of order canceling. 226 | 227 | ### HTTP Request 228 | 229 | `POST https://api.fcoin.com/v2/orders/{order_id}/submit-cancel` 230 | 231 | ### URL Parameters 232 | 233 | Parameters | Description 234 | --------- | ----------- 235 | order_id | order ID 236 | 237 | 238 | 239 | 240 | 241 | 242 | ## Query trading records of a specified order 243 | 244 | ```python 245 | import fcoin 246 | 247 | api = fcoin.authorize('key', 'secret', timestamp) 248 | api.orders.get('9d17a03b852e48c0b3920c7412867623').match_results() 249 | ``` 250 | 251 | ```javascript 252 | const fcoin = require('fcoin'); 253 | 254 | let api = fcoin.authorize('key', 'secret', timestamp); 255 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623').matchResults(); 256 | ``` 257 | 258 | > The response results are as follows: 259 | 260 | ```json 261 | { 262 | "status": 0, 263 | "data": [ 264 | { 265 | "price": "string", 266 | "fill_fees": "string", 267 | "filled_amount": "string", 268 | "side": "buy", 269 | "type": "limit", 270 | "created_at": 0 271 | } 272 | ] 273 | } 274 | ``` 275 | 276 | This API is used to get the trading record of the specified order 277 | 278 | ### HTTP Request 279 | 280 | `GET https://api.fcoin.com/v2/orders/{order_id}/match-results` 281 | 282 | ### URL Parameters 283 | 284 | Parameters | Description 285 | --------- | ----------- 286 | order_id | order ID 287 | -------------------------------------------------------------------------------- /source/includes/en/_publics.md: -------------------------------------------------------------------------------- 1 | # Public interface 2 | 3 | ## Query server time 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | server_time = api.server_time() 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let serverTime = api.serverTime(); 17 | ``` 18 | 19 | > The response results are as follows: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": 1523430502977 25 | } 26 | ``` 27 | 28 | The API is used to obtain the server time。 29 | 30 | ### HTTP Request 31 | 32 | `GET https://api.fcoin.com/v2/public/server-time` 33 | 34 | 35 | 36 | 37 | 38 | ## Query available currencies 39 | 40 | ```python 41 | import fcoin 42 | 43 | api = fcoin.authorize('key', 'secret', timestamp) 44 | currencies = api.currencies() 45 | ``` 46 | 47 | ```javascript 48 | const fcoin = require('fcoin'); 49 | 50 | let api = fcoin.authorize('key', 'secret', timestamp); 51 | let currencies = api.currencies(); 52 | ``` 53 | 54 | > The response results are as follows: 55 | 56 | ```json 57 | { 58 | "status": 0, 59 | "data": [ 60 | "btc", 61 | "eth" 62 | ] 63 | } 64 | ``` 65 | 66 | This API is used to obtain the available currencies。 67 | 68 | ### HTTP Request 69 | 70 | `GET https://api.fcoin.com/v2/public/currencies` 71 | 72 | 73 | 74 | 75 | 76 | ## Query available trading pairs 77 | 78 | ```python 79 | import fcoin 80 | 81 | api = fcoin.authorize('key', 'secret', timestamp) 82 | symbols = api.symbols() 83 | ``` 84 | 85 | ```javascript 86 | const fcoin = require('fcoin'); 87 | 88 | let api = fcoin.authorize('key', 'secret', timestamp); 89 | let symbols = api.symbols(); 90 | ``` 91 | 92 | > The response results are as follows: 93 | 94 | ```json 95 | { 96 | "status": 0, 97 | "data": [ 98 | { 99 | "name": "btcusdt", 100 | "base_currency": "btc", 101 | "quote_currency": "usdt", 102 | "price_decimal": 2, 103 | "amount_decimal": 4 104 | }, 105 | { 106 | "name": "ethusdt", 107 | "base_currency": "eth", 108 | "quote_currency": "usdt", 109 | "price_decimal": 2, 110 | "amount_decimal": 4 111 | } 112 | ] 113 | } 114 | ``` 115 | 116 | This API is used to get available trading pairs。 117 | 118 | ### HTTP Request 119 | 120 | `GET https://api.fcoin.com/v2/public/symbols` 121 | -------------------------------------------------------------------------------- /source/includes/en/_small_currency_exchange.md: -------------------------------------------------------------------------------- 1 | # small assets conversion 2 | 3 | - Conversion record state description 4 | 5 | 6 | | Property | Meaning | 7 | |:------|:------:| 8 | |WAITING_TRANSFER_TO_SYSTEM|Waiting to be transferred into system account 9 | |WAITING_REFUND|Refund to users 10 | |FAIL|Conversion failed 11 | |WAITING_TRANSFER_TO_USER|Waiting to transfer to the user 12 | |SUCCESS|Conversion succeed 13 | 14 | ## User convert the small assets 15 | 16 | `POST https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 17 | 18 | ### Required Parameter 19 | | Property | Meaning | 20 | |:------|:------| 21 | |exchange_currency | Convert into,ft 22 | |small_currency_amounts | json format: [{"currency":"usdt","amount":"0.4"},{"currency":"btc","amount":"0.0002"}],among currency: currency to be converted,amount: convention amount (must be more than 0,18 digital precision are supported max. ) 23 | 24 | ### Responding result 25 | ``` 26 | { 27 | "status": "ok", 28 | "data": null 29 | } 30 | ``` 31 | 32 | ## Check convertible currency 33 | 34 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange/exchangeable_small_currencies/{exchange_currency}` 35 | 36 | ### Required Parameter 37 | 38 | exchange_currency: Converted into currency 39 | 40 | ### Responding result 41 | 42 | ``` 43 |  { 44 |  "exchange_currency": "ft", Converted into currency   45 | "total_exchange_amount": "0", total amount have been coverted 46 | "exchangeable_small_currencies": [ 47 | { 48 | "currency": "dash", currency to be converted 49 | "available_amount": "0.00063517", currency balance 50 | "valuation": "0.06805309", available balance estimated (usdt) 51 | "exchange_amount": "1.71670037", converted amount(commission has not been deducted) 52 | "exchangeable": true Can be converted or no(false means can be neglected during conversion) 53 | }, 54 | { 55 | "currency": "usdt", 56 | "available_amount": "0.3", 57 | "valuation": "0.3", 58 | "exchange_amount": "15", 59 | "exchangeable": true 60 | } 61 | ] 62 | } 63 | 64 | ``` 65 | 66 | ## Check conversion record 67 | 68 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 69 | 70 | ### Required Parameter 71 | 72 | | Property| Type | Meaning | 73 | |:------|:------:|:------| 74 | |has_prev |Boolean| the Parameter is controlled by the front end weather to include the former page or not, return as it 75 | |id |String|The last paging ID not mandatory 76 | |page_size |Integer| Request amount(1-40),40 by default 77 | 78 | 79 | #### Responding result 80 | 81 | ``` 82 | 83 | { 84 | "content": [ 85 | { 86 | "id": "jS6XfuzBhXXhDBtt_dNDqw", record id 87 | "exchange_currency": "ft", convert into currency 88 | "fees": "0.056006006006006007", fee 89 | "exchange_amount": "28.003003003003003003", converted amount 90 | "actual_exchange_amount": "27.946996996996996996", actual arrival amount = converted amount - fee 91 | "state": "waiting_transfer_to_user", conversion state 92 | "created_at": 1577949932988 conversion time 93 | } 94 | ], 95 | "current_elements": 1, 96 | "has_prev": false, 97 | "has_next": false, 98 | "next_page_id": "jS6XfuzBhXXhDBtt_dNDqw" 99 | } 100 | 101 | ``` 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /source/includes/jp/_accounts.md: -------------------------------------------------------------------------------- 1 | # アカウントと資金 2 | 3 | ## アカウント資金照会 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | api.accounts_balance 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let orders = api.accountsBalance; 17 | ``` 18 | 19 | > 响应结果如下: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": [ 25 | { 26 | "currency": "btc", 27 | "available": "50.0", 28 | "frozen": "50.0", 29 | "balance": "100.0" 30 | } 31 | ] 32 | } 33 | ``` 34 | 35 | このAPIは、ユーザーの資産リストを照会するために使用されます。 36 | 37 | ### HTTP Request 38 | 39 | `GET https://api.fcoin.com/v2/accounts/balance` 40 | -------------------------------------------------------------------------------- /source/includes/jp/_authentication.md: -------------------------------------------------------------------------------- 1 | # 認証 2 | 3 | > 下記コードを使用して、ユーザー認証を行います: 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | ``` 10 | 11 | ```javascript 12 | const fcoin = require('fcoin'); 13 | 14 | let api = fcoin.authorize('key', 'secret', timestamp); 15 | ``` 16 | 17 | FCoinはAPI キーとAPIシークレットを使用して、認証を行います。 設定センターにて,開発者にご登録してください。ご登録いただいた後、API キーとAPI シークレット情報をご利用いただけます。 18 | 19 | FCoinのAPI利用について,公開API以外に、API キー及び署名が必要となります。 20 | 21 | 22 | 23 | 24 | ## アクセス制限 25 | 26 | 現在、アクセスの頻度はユーザーごとに100回 / 10秒,将来はサービスごと、アクセスの頻度を制限する予定です。 27 | 28 | 29 | 30 | 31 | ## API 署名 32 | 33 | 署名を行うため、あらかじめ下記データをご用意してください: 34 | 35 | `HTTP_METHOD` + `HTTP_REQUEST_URI` + `TIMESTAMP` + `POST_BODY` 36 | 37 | 接続が確立後, Base64エンコーディングが必要です。エンコーディング後のデータに対して、 HMAC-SHA1 署名を行います。また、デジタル署名に対して、Base64エンコーディングを2回実施します。各ステップの詳細内容について、ご説明します: 38 | 39 | 42 | 43 | ### HTTP_METHOD 44 | 45 | `GET`, `POST`, `DELETE`, `PUT` は必ず大文字にしてください 46 | 47 | ### HTTP_REQUEST_URI 48 | 49 | `https://api.fcoin.com/v2/` v2 APIのリクエストの接頭辞 50 | 51 | その後に、アクセスしたいリソースパスを記入してください。例: `orders?param1=value1`の場合は,最終形は `https://api.fcoin.com/v2/orders?param1=value1`となります 52 | 53 | リクエストされたURIのパラメータについては、アルファベット順に並べ替える必要があります! 54 | 55 | すなわち、リクエストされたURIは`https://api.fcoin.com/v2/orders?c=value1&b=value2&a=value3`の場合,デジタル署名する際に、リクエスト・パラメータをアルファベット順にソートさせ、デジタル署名の最終URIは `https://api.fcoin.com/v2/orders?a=value3&b=value2&c=value1`となります。 元のリクエスト中には、URI中の三つのパラメータの順番は `c`, `b`, `a`だが,ソート後、順番は `a`, `b`, `c`になっております。ご注意ください。 56 | 57 | ### TIMESTAMP 58 | 59 | APIを利用してアクセスする時のUNIX EPOCHタイムスタンプは、サーバーとの時間差は30秒以内でなければなりません。 60 | 61 | ### POST_BODY 62 | 63 | POST リクエストの場合は,POST リクエストデータへのデジタル署名も必要です。デジタル署名のルールはご説明します: 64 | 65 | リクエストされたすべてのキーはアルファベット順に並べ替えられた後、urlパラメータ化されます。 &を使用して、繋ぎます。 66 | 67 | 70 | 71 | > 下記リクエストデータの場合は: 72 | 73 | ```json 74 | { 75 | "username": "username", 76 | "password": "passowrd" 77 | } 78 | ``` 79 | 80 | > 先に、キーをアルファベット順にソートし、urlパラメータ化します。すなわち: 81 | 82 | ``` 83 | password=password 84 | username=username 85 | ``` 86 | 87 | > アルファベットの順番には、`p`はuの前にあるため、`password`は`username`の前に置かれるべき、その次、&を使用して接続します。すなわち: 88 | 89 | ``` 90 | password=password&username=username 91 | ``` 92 | 93 | ## デモンストレーション 94 | 95 | > 下記のリクエストの場合は: 96 | 97 | ``` 98 | POST https://api.fcoin.com/v2/orders 99 | 100 | { 101 | "type": "limit", 102 | "side": "buy", 103 | "amount": "100.0", 104 | "price": "100.0", 105 | "symbol": "btcusdt" 106 | } 107 | 108 | timestamp: 1523069544359 109 | ``` 110 | 111 | > デジタル署名を行うため、あらかじめ下記データをご用意してください: 112 | 113 | ``` 114 | POSThttps://api.fcoin.com/v2/orders1523069544359amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit 115 | ``` 116 | 117 | > Base64エンコーディングし、下記データになります: 118 | 119 | ``` 120 | UE9TVGh0dHBzOi8vYXBpLmZjb2luLmNvbS92Mi9vcmRlcnMxNTIzMDY5NTQ0MzU5YW1vdW50PTEwMC4wJnByaWNlPTEwMC4wJnNpZGU9YnV5JnN5bWJvbD1idGN1c2R0JnR5cGU9bGltaXQ= 121 | ``` 122 | 123 | > API キーを申請した際に取得したキー(API シークレット)をコピーし,以下のデジタル署名結果は、例として `3600d0a74aa3410fb3b1996cca2419c8` を使用しています, 124 | 125 | > 結果に対して、秘密鍵を使用して、 `HMAC-SHA1` デジタル署名し、バイナリ結果に対して`Base64` エンコーディング後、下記になります: 126 | 127 | ``` 128 | DeP6oftldIrys06uq3B7Lkh3a0U= 129 | ``` 130 | 131 | > すなわち、APIサーバーへ検証するための最終的なデジタル署名が生成されます 132 | 133 | ## パラメータ名 134 | 135 | * `FC-ACCESS-KEY` 136 | * `FC-ACCESS-SIGNATURE` 137 | * `FC-ACCESS-TIMESTAMP` 138 | 139 | ## 説明 140 | 141 | デベロッパーツール(準備中)を使用して、オンライン検証を行えます。 142 | -------------------------------------------------------------------------------- /source/includes/jp/_errors.md: -------------------------------------------------------------------------------- 1 | # エラーコード 2 | 3 | エラーコード | 内容解釈 4 | ---------- | ------- 5 | 400 | Bad Request -- 誤リクエスト 6 | 401 | Unauthorized -- API key 或いは署名、タイムスタンプに誤りがあります 7 | 403 | Forbidden -- アクセス不可 8 | 404 | Not Found -- リクエストされたリソースが見つかりませんでした 9 | 405 | Method Not Allowed -- 使用されるHTTPメソッドは、要求されたリソースには適用されません 10 | 406 | Not Acceptable -- リクエストされたコンテンツのフォーマットはJSONではありません 11 | 429 | Too Many Requests -- 負荷がオーバーロード、リクエスト頻度を下げてください 12 | 500 | Internal Server Error -- サービスの内部エラーが発生、後でもう一度お試しください 13 | 503 | Service Unavailable -- サービスが利用できません、後でやり直してください 14 | -------------------------------------------------------------------------------- /source/includes/jp/_introduction.md: -------------------------------------------------------------------------------- 1 | # 紹介 2 | 3 | FCoin取引プラットフォームの利用方法をご紹介します。FCoinが提供するAPIを使用して、FCoin取引プラットフォームに簡単にアクセスできます。 4 | -------------------------------------------------------------------------------- /source/includes/jp/_leveraged.md: -------------------------------------------------------------------------------- 1 | # レバレッジ 2 | ## レバレッジ口座へ資産の振込入金 3 | このAPIは、取引口座或いはマイウォレットの資産をレバレッジ口座に振込入金するために使用されます。 4 | 5 | ### HTTP Request 6 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/in` 7 | 8 | ### リクエスト・パラメータ 9 | |ペラメータ|デフォルト値|説明| 10 | |:------|:------:|:------| 11 | |amount|無|振込入金の数量| 12 | |currency|無|通貨:usdt、btc、eth| 13 | |source_account_type|無|送金口座のタイプ: exchange: 取引口座; assets: マイウォレット | 14 | |target_account_type|無|入金先の口座のタイプ: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 15 | 16 | ``` 17 | { 18 | "amount": 1, 19 | "currency": "btc", 20 | "source_account_type": "exchange", 21 | "target_account_type": "leveraged_btcusdt" 22 | } 23 | ``` 24 | 25 | ### 応答結果 26 | ``` 27 | { 28 | "data": null, 29 | "status": "ok" 30 | } 31 | ``` 32 | 33 | ## レバレッジ口座から資産の振込出金 34 | このAPIは、レバレッジ口座から取引口座或いはマイウォレットに資産を振込出金するために使用されます。 35 | 36 | ### HTTP Request 37 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/out` 38 | 39 | ### リクエスト・パラメータ 40 | |ペラメータ|デフォルト値|説明| 41 | |:------|:------:|:------| 42 | |amount|無|振込出金の数量| 43 | |currency|無|通貨:usdt、btc、eth、eos、xrp| 44 | |source_account_type|無|資産の元口座のタイプ: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 45 | |target_account_type|無|出金先の口座のタイプ:: exchange: 取引口座; assets: マイウォレット| 46 | 47 | ``` 48 | { 49 | "amount": 1, 50 | "currency": "btc", 51 | "source_account_type": "leveraged_btcusdt", 52 | "target_account_type": "exchange" 53 | } 54 | ``` 55 | 56 | ### 応答結果 57 | ``` 58 | { 59 | "data": null, 60 | "status": "ok" 61 | } 62 | ``` 63 | 64 | ## 指定されたレバレッジ口座の情報を照会する 65 | 66 | ### リクエスト・URL 67 | 68 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts/account` 69 | 70 | ### リクエスト・パラメータ 71 | |ペラメータ|デフォルト値|説明| 72 | |:------|:------:|:------| 73 | |account_type|無|レバレッジ口座のタイプ:btcusdt/ethusdt 74 | 75 | ### 応答結果 76 | 77 | ``` 78 | { 79 | "status": "ok", 80 | "data": { 81 | "open": true, #本タイプのレバレッジ口座を開設しましたか? true:はい;false:いいえ 82 | "leveraged_account_type": "btcusdt", #レバレッジ口座のタイプ 83 | "base": "btc", #基軸通貨 84 | "quote": "usdt", #評価通貨 85 | "available_base_currency_amount": "1001.00", #利用可能の基軸通貨資産 86 | "frozen_base_currency_amount": "0", #凍結中の基軸通貨資産 87 | "available_quote_currency_amount": "100100", #利用可能の評価通貨資産 88 | "frozen_quote_currency_amount": "0", #凍結中の評価通貨資産 89 | "available_base_currency_loan_amount": "2.000", #貸借可能の基軸通貨資産 90 |      "available_quote_currency_loan_amount": "300.000",#貸借可能の評価通貨数量 91 | "blow_up_price": null, #清算価格 92 | "risk_rate": "0.90", #ロスカットリスク率 93 | "state": "open" #口座状態. close クローズ;open オープン-貸借無し;normal 貸借あり-ノーマルなリスク率;blow_up ロスカット;overrun 追証", allowableValues = "close,open,normal,blow_up,overrun") 94 | 95 | } 96 | } 97 | ``` 98 | 99 | 100 | ## 全てのレバレッジ口座の情報を照会する 101 | 102 | ### リクエスト・URL 103 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts` 104 | 105 | ### リクエスト・パラメータ 106 | 无 107 | ### 応答結果 108 | ``` 109 | { 110 | "status": "ok", 111 | "data": [ 112 | { 113 | "open": true, #本タイプのレバレッジ口座を開設しましたか? true:はい;false:いいえ 114 | "leveraged_account_type": "btcusdt", #レバレッジ口座のタイプ 115 | "base": "btc", #基軸通貨 116 | "quote": "usdt", #評価通貨 117 | "available_base_currency_amount": "1001.00", #利用可能の基軸通貨資産 118 | "frozen_base_currency_amount": "0", #凍結中の基軸通貨資産 119 | "available_quote_currency_amount": "100100", #利用可能の評価通貨資産 120 | "frozen_quote_currency_amount": "0", #凍結中の評価通貨資産 121 | "available_base_currency_loan_amount": "2.000", #貸借可能の基軸通貨資産 122 |      "available_quote_currency_loan_amount": "300.000",#貸借可能の評価通貨数量 123 | "blow_up_price": null, #清算価格 124 | "risk_rate": "0.90", #ロスカットリスク率 125 | "state": "open" #口座状態. close クローズ;open オープン-貸借無し;normal 貸借あり-ノーマルなリスク率;blow_up ロスカット;overrun 追証" 126 | } 127 | ] 128 | } 129 | ``` -------------------------------------------------------------------------------- /source/includes/jp/_order_errors.md: -------------------------------------------------------------------------------- 1 | ## 注文エラーコード 2 | 3 | エラーコード | 内容解釈 4 | ---------- | ------- 5 | 2000 | アカウントエラー 6 | -------------------------------------------------------------------------------- /source/includes/jp/_orders.md: -------------------------------------------------------------------------------- 1 | # 注文 2 | 3 | ## 注文モデル説明 4 | 5 | 注文モデルは、以下の属性によって構成されます: 6 | 7 | 属性 | タイプ | 内容説明 8 | ---------- | ------- | ------- 9 | `id` | `String` | 注文 ID 10 | `symbol` | `String` | 通貨ペア 11 | `side` | `String` | 取引方向(`buy`, `sell`) 12 | `type` | `String` | 注文タイプ(`limit`,`market`) 13 | `price` | `String` | 注文価格 14 | `amount` | `String` | 注文ボリューム 15 | `state` | `String` | 注文ステータス 16 | `executed_value` | `String` | 約定 17 | `filled_amount` | `String` | 出来高 18 | `fill_fees` | `String` | 手数料 19 | `created_at` | `Long` | 注文日時 20 | `source` | `String` | ソース 21 | 22 | 注文ステータス説明: 23 | 24 | 属性 | 内容説明 25 | ----------- | ------- 26 | `submitted` | 注文中 27 | `partial_filled` | 一部約定 28 | `partial_canceled` | 一部キャンセル 29 | `filled` | 約定 30 | `canceled` | キャンセル 31 | `pending_cancel` | キャンセルリクエスト中 32 | 33 | ## 新規注文 34 | 35 | ```python 36 | import fcoin 37 | 38 | api = fcoin.authorize('key', 'secret', timestamp) 39 | order_create_param = fcoin.order_create_param('btcusdt', 'buy', 'limit', '8000.0', '1.0') 40 | api.orders.create(order_create_param) 41 | ``` 42 | 43 | ```javascript 44 | const fcoin = require('fcoin'); 45 | 46 | let api = fcoin.authorize('key', 'secret', timestamp); 47 | let orderCreateParam = fcoin.orderCreateParam('btcusdt', 'buy', 'limit', '8000.0', '1.0'); 48 | let orders = api.orders.create(orderCreateParam); 49 | ``` 50 | 51 | > レスポンス結果は下記のとおりです: 52 | 53 | ```json 54 | { 55 | "status": 0, 56 | "data": "9d17a03b852e48c0b3920c7412867623" 57 | } 58 | ``` 59 | 60 | このAPIは新規注文を発注します。 61 | 62 | ### HTTP Request 63 | 64 | `POST https://api.fcoin.com/v2/orders` 65 | 66 | ### リクエスト・パラメータ 67 | 68 | パラメータ | デフォルト値 | 説明 69 | --------- | ------- | ----------- 70 | symbol | 無 | 通貨ペア 71 | side | 無 | 取引方向 72 | type | 無 | 注文タイプ 73 | price | 無 | 価格 74 | amount | 無 | 発注量 75 | exchage | 無 | 取引ゾーン 76 | account_type | 無 | 注文タイプ(レバレッジ:margin) 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## 注文リストの照会 84 | 85 | ```python 86 | import fcoin 87 | 88 | api = fcoin.authorize('key', 'secret', timestamp) 89 | api.orders.get() 90 | ``` 91 | 92 | ```javascript 93 | const fcoin = require('fcoin'); 94 | 95 | let api = fcoin.authorize('key', 'secret', timestamp); 96 | let orders = api.orders.get(); 97 | ``` 98 | 99 | > レスポンス結果は下記のとおりです: 100 | 101 | ```json 102 | { 103 | "status": 0, 104 | "data": [ 105 | { 106 | "id": "string", 107 | "symbol": "string", 108 | "type": "limit", 109 | "side": "buy", 110 | "price": "string", 111 | "amount": "string", 112 | "state": "submitted", 113 | "executed_value": "string", 114 | "fill_fees": "string", 115 | "filled_amount": "string", 116 | "created_at": 0, 117 | "source": "web" 118 | } 119 | ] 120 | } 121 | ``` 122 | 123 | このAPIは注文リストの照会に使用されます。 124 | 125 | ### HTTP Request 126 | 127 | `GET https://api.fcoin.com/v2/orders` 128 | 129 | ### 照会パラメータ 130 | 131 | パラメータ | デフォルト値 | 説明 132 | --------- | ------- | ----------- 133 | symbol | | 通貨ペア 134 | states | | 注文ステータス 135 | before | | あるページの前の 136 | after | | あるページの後の注文の照会 137 | limit | | ページごとの注文量、デフォルトは20条 138 | 139 | 140 | 141 | 142 | 143 | ## 特定注文の取得 144 | 145 | ```python 146 | import fcoin 147 | 148 | api = fcoin.authorize('key', 'secret', timestamp) 149 | api.orders.get('9d17a03b852e48c0b3920c7412867623') 150 | ``` 151 | 152 | ```javascript 153 | const fcoin = require('fcoin'); 154 | 155 | let api = fcoin.authorize('key', 'secret', timestamp); 156 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623'); 157 | ``` 158 | 159 | > レスポンス結果は下記のとおりです: 160 | 161 | ```json 162 | { 163 | "status": 0, 164 | "data": { 165 | "id": "9d17a03b852e48c0b3920c7412867623", 166 | "symbol": "string", 167 | "type": "limit", 168 | "side": "buy", 169 | "price": "string", 170 | "amount": "string", 171 | "state": "submitted", 172 | "executed_value": "string", 173 | "fill_fees": "string", 174 | "filled_amount": "string", 175 | "created_at": 0, 176 | "source": "web" 177 | } 178 | } 179 | ``` 180 | 181 | このAPIは指定された注文の詳細を取得します。 182 | 183 | ### HTTP Request 184 | 185 | `GET https://api.fcoin.com/v2/orders/{order_id}` 186 | 187 | ### URL パラメータ 188 | 189 | パラメータ | 説明 190 | --------- | ----------- 191 | order_id | 注文 ID 192 | 193 | 194 | 195 | 196 | 197 | 198 | ## 注文キャンセルのリクエスト 199 | 200 | ```python 201 | import fcoin 202 | 203 | api = fcoin.authorize('key', 'secret', timestamp) 204 | api.orders.submit_cancel(2) 205 | ``` 206 | 207 | ```javascript 208 | const fcoin = require('fcoin'); 209 | 210 | let api = fcoin.authorize('key', 'secret', timestamp); 211 | let max = api.orders.submitCancel(2); 212 | ``` 213 | 214 | > レスポンス結果は下記のとおりです: 215 | 216 | ```json 217 | { 218 | "status": 0, 219 | "msg": "string", 220 | "data": true 221 | } 222 | ``` 223 | 224 | このAPIは指定された注文をキャンセルするために、使用されます。注文のキャンセル・プロセスは非同期です。つまり、このAPIの呼び出しが成功した場合は、注文はキャンセルリクエストのプロセスに入っていますが、注文の取り消しを確認するためにマッチング処理を待つ必要があります。 225 | 226 | ### HTTP Request 227 | 228 | `POST https://api.fcoin.com/v2/orders/{order_id}/submit-cancel` 229 | 230 | ### URL パラメータ 231 | 232 | パラメータ | 解釈 233 | --------- | ----------- 234 | order_id | 注文 ID 235 | 236 | 237 | 238 | 239 | 240 | 241 | ## 指定されている注文の取引記録の照会 242 | 243 | ```python 244 | import fcoin 245 | 246 | api = fcoin.authorize('key', 'secret', timestamp) 247 | api.orders.get('9d17a03b852e48c0b3920c7412867623').match_results() 248 | ``` 249 | 250 | ```javascript 251 | const fcoin = require('fcoin'); 252 | 253 | let api = fcoin.authorize('key', 'secret', timestamp); 254 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623').matchResults(); 255 | ``` 256 | 257 | > レスポンス結果は下記のとおりです: 258 | 259 | ```json 260 | { 261 | "status": 0, 262 | "data": [ 263 | { 264 | "price": "string", 265 | "fill_fees": "string", 266 | "filled_amount": "string", 267 | "side": "buy", 268 | "type": "limit", 269 | "created_at": 0 270 | } 271 | ] 272 | } 273 | ``` 274 | 275 | このAPIは指定されている注文の取引記録の取得に使用されます 276 | 277 | ### HTTP Request 278 | 279 | `GET https://api.fcoin.com/v2/orders/{order_id}/match-results` 280 | 281 | ### URL パラメータ 282 | 283 | パラメータ | 解釈 284 | --------- | ----------- 285 | order_id | 注文 ID 286 | -------------------------------------------------------------------------------- /source/includes/jp/_otc.md: -------------------------------------------------------------------------------- 1 | # OTC 2 | ## OTC資産の振込入金 3 | このAPIは、取引口座やマイウォレットの資産をOTC口座に振込入金するために使用されます。 4 | 5 | ### HTTP Request 6 | `POST https://api.fcoin.com/v2/broker/otc/assets/transfer/in` 7 | 8 | ### リクエスト・パラメータ 9 | |ペラメータ|デフォルト値|説明| 10 | |:------|:------:|:------| 11 | |amount|無|振込入金の数量| 12 | |currency|無|通貨:usdt、btc、eth| 13 | |source_account_type|無|送金口座のタイプ: exchange: 取引口座; assets: マイウォレット| 14 | |target_account_type|無|入金先の口座のタイプ: otc:法定通貨口座| 15 | 16 | ``` 17 | { 18 | "amount": 1, 19 | "currency": "btc", 20 | "source_account_type": "exchange", 21 | "target_account_type": "otc" 22 | } 23 | ``` 24 | 25 | ### 応答結果 26 | ``` 27 | { 28 | "data": null, 29 | "status": "ok" 30 | } 31 | ``` 32 | 33 | 34 | ## OTC資産の振込出金 35 | このAPIは、OTC口座の資産を取引口座やマイウォレットに振込出金するために使用されます。 36 | 37 | ### HTTP Request 38 | `POST https://api.fcoin.com/v2/broker/otc/assets/transfer/out` 39 | 40 | ### リクエスト・パラメータ 41 | |ペラメータ|デフォルト値|説明| 42 | |:------|:------:|:------| 43 | |amount|無|振込出金の数量| 44 | |currency|無|通貨:usdt、btc、eth| 45 | |source_account_type|無|送金口座のタイプ:otc: 法币账户 | 46 | |target_account_type|無|入金先の口座のタイプ: exchange: 取引口座; assets: マイウォレット| 47 | 48 | ``` 49 | { 50 | "amount": 1, 51 | "currency": "btc", 52 | "source_account_type": "otc", 53 | "target_account_type": "exchange" 54 | } 55 | ``` 56 | 57 | ### 応答結果 58 | ``` 59 | { 60 | "data": null, 61 | "status": "ok" 62 | } 63 | ``` 64 | 65 | ## OTC注文 66 | ### 新しい注文を作る 67 | このAPIは、新しいOTC注文を作るために使用されます。 68 | 69 | ### HTTP Request 70 | `POST https://api.fcoin.com/v2/broker/otc/suborders` 71 | 72 | ### リクエスト・パラメータ 73 | |ペラメータ|デフォルト値|説明| 74 | |:------|:------:|:------| 75 | |amount|無|取引数量| 76 | |delegation_order_id|無|委託注文id| 77 | 78 | ``` 79 | { 80 | "amount": 1, 81 | "delegation_order_id": "St5_OiSE5YQiy4lxkQhq8w" 82 | } 83 | ``` 84 | 85 | ### 応答結果 86 | ``` 87 | { 88 | "err_code": "", 89 | "err_msg": "", 90 | "status": "ok", 91 | "data": 4064224473046529 92 | } 93 | ``` 94 | 95 | ## OTC注文リストを照会する 96 | このAPIは、OTC注文リストを照会するために使用されます。 97 | 98 | ### HTTP Request 99 | `GET https://api.fcoin.com/v2/broker/otc/suborders` 100 | 101 | ### リクエスト・パラメータ 102 | |ペラメータ|デフォルト値|説明| 103 | |:------|:------:|:------| 104 | |id|無|最後のページングのID| 105 | |page_size|無|各ページの記録回数| 106 | |delegation_order_id|無|委託注文id| 107 | |states|無|注文状態: 108 | 1 confirmed 確認済
2 buyer_appeal 買い手申し立て中
3 seller_appeal 売り手申し立て中
4 paid 買い手が支払い済み
5 released 通貨が転送済み 109 | 6 filled 約定済
7 cancelled キャンセル済
8 timeout キャンセル時間切れ
9 system_cancelled システムキャンセル(残高不足)| 110 | 111 | 112 | ### 応答結果 113 | ``` 114 | { 115 | "err_code": "", 116 | "err_msg": "", 117 | "status": "ok", 118 | "data": { 119 | "content": [ 120 | { 121 | "id": "4064224473046529", 122 | "currency": "usdt", 123 | "legal_currency": "cny", 124 | "direction": "buy", 125 | "type": "normal", 126 | "price": "7.00", 127 | "amount": "100.000000", 128 | "total_price": "700.00", 129 | "start_at": 1546614090132, 130 | "created_at": 1546614090135, 131 | "state": "confirmed" 132 | }, 133 | { 134 | "id": "3214937639915529", 135 | "currency": "usdt", 136 | "legal_currency": "cny", 137 | "direction": "buy", 138 | "type": "normal", 139 | "price": "7.70", 140 | "amount": "100.000000", 141 | "total_price": "770.00", 142 | "start_at": 1546421969839, 143 | "created_at": 1546421969842, 144 | "state": "filled" 145 | } 146 | ], 147 | "current_elements": 2, 148 | "has_prev": true, 149 | "has_next": false, 150 | "next_page_id": 3214937639915529 151 | } 152 | } 153 | ``` 154 | 155 | ## 注文詳細を照会する 156 | このAPIは、注文詳細を照会するために使用されます。 157 | 158 | ### HTTP Request 159 | `GET https://api.fcoin.com/v2/broker/otc/suborders/{id}` 160 | 161 | ### リクエスト・パラメータ 162 | |ペラメータ|デフォルト値|説明| 163 | |:------|:------:|:------| 164 | |id|無|注文id| 165 | 166 | ### 応答結果 167 | ``` 168 | { 169 | "status": "ok", 170 | "data": { 171 | "id": "4064224473046529", 172 | "currency": "usdt", 173 | "legal_currency": "cny", 174 | "direction": "buy", 175 | "type": "normal", 176 | "price": "7.00", 177 | "amount": "100.000000", 178 | "payment_method": "wechat_pay", 179 | "total_price": "700.00", 180 | "start_at": 1546614090132, 181 | "paid_at": 1546614126421, 182 | "finished_at": 1546614470679, 183 | "created_at": 1546614090135, 184 | "release_begin_at": 1546614294160, 185 | "buyer_user_id": "hXD7rALO-p899HLEG6OGCA", 186 | "seller_user_id": "U_g-dtTE_B8Q2eQYa4a8Bw", 187 | "state": "filled", 188 | "first_name": "Tim", 189 | "last_name": "im" 190 | } 191 | } 192 | ``` 193 | 194 | ## 注文支払いの確認 195 | このAPIは、注文の支払いを確認するために使用されます。 196 | 197 | ### HTTP Request 198 | `POST https://api.fcoin.com/v2/broker/otc/suborders/{id}/pay_confirm` 199 | 200 | ### リクエスト・パラメータ 201 | |ペラメータ|デフォルト値|説明| 202 | |:------|:------:|:------| 203 | |id|無|注文id| 204 | |payment_method|無|支払い方法: 205 | 1 alipay Alipay 206 | 2 wechat_pay Wechat Pay 207 | 3 bank_card_pay 銀行カード 208 | 209 | 210 | ### 応答結果 211 | ``` 212 | { 213 | "err_code": "", 214 | "err_msg": "", 215 | "status": "ok" 216 | } 217 | ``` 218 | 219 | ## 買い手の注文キャンセル 220 | このAPIは、買い手が注文をキャンセルするために使用されます。 221 | 222 | ### HTTP Request 223 | `POST https://api.fcoin.com/v2/broker/otc/suborders/{id}/cancel` 224 | 225 | ### リクエスト・パラメータ 226 | |ペラメータ|デフォルト値|説明| 227 | |:------|:------:|:------| 228 | |id|無|注文id| 229 | 230 | ### 応答結果 231 | ``` 232 | { 233 | "err_code": "", 234 | "err_msg": "", 235 | "status": "ok" 236 | } 237 | ``` 238 | 239 | ## 売り手の支払い方法の確認 240 | このAPIは、注文した後、売り手の支払い方法を確認するために使用されます。 241 | 242 | ### HTTP Request 243 | `GET https://api.fcoin.com/v2/broker/otc/suborders/{id}/payments` 244 | 245 | ### リクエスト・パラメータ 246 | |ペラメータ|デフォルト値|説明| 247 | |:------|:------:|:------| 248 | |id|無|注文id| 249 | 250 | ### 応答結果 251 | ``` 252 | { 253 | "status": "ok", 254 | "data": [ 255 | { 256 | "payment_method": "alipay", 257 | "first_name": "Tim", 258 | "last_name": "im", 259 | "bank_name": null, 260 | "bank_branch_name": null, 261 | "account": "zhifubao", 262 | "account_image_key": "551c9c2d6bad417fb4aa171bcc6b861d.jpg", 263 | "account_image_read_url": "https://s3.ap-northeast-1.amazonaws.com/local-s3.bitdict.com/kyc/551c9c2d6bad417fb4aa171bcc6b861d.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190115T113640Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIAIZ37IMEFO7JZRBOQ%2F20190115%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Signature=26788f3972b7a732b232cc08a54cd7afa038da0a219bf20076267ec70037bf3c" 264 | }, 265 | { 266 | "payment_method": "wechat_pay", 267 | "first_name": "Tim", 268 | "last_name": "im", 269 | "bank_name": null, 270 | "bank_branch_name": null, 271 | "account": "weixina", 272 | "account_image_key": "e5b20c5af24232f11ec4ce187f7c6998.jpg", 273 | "account_image_read_url": "https://s3.ap-northeast-1.amazonaws.com/local-s3.bitdict.com/kyc/e5b20c5af24232f11ec4ce187f7c6998.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20190115T113640Z&X-Amz-SignedHeaders=host&X-Amz-Expires=7200&X-Amz-Credential=AKIAIZ37IMEFO7JZRBOQ%2F20190115%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Signature=8d9e599cf672d3cc495407d2c9538e3b4fb7275aee7201b48b8ba48c65f6fa68" 274 | } 275 | ] 276 | } 277 | ``` 278 | 279 | ## OTC口座情報の獲得 280 | 281 | ### HTTP请求 282 | 283 | `GET https://api.fcoin.com/v2/broker/otc/users` 284 | 285 | ### リクエスト・パラメータ 286 | 无 287 | 288 | ### 応答結果 289 | 290 | ``` 291 | { 292 | "status": "ok", 293 | "data": { 294 | "user_id": "Hff9R282Ty8wDa5Xb8AaLg", #ユーザーID 295 | "nickname": "isfulei", #ニックネーム 296 | "merchant": true, #OTCメーカーですか? 297 | "margin_amount": "1.00000000", #証拠金の数量 298 | "total_transaction": 0, #約定済の注文総数 299 | "recent_transaction": 0, #最近約定済の注文数 300 | "total_release_time": "0", #合計転送時間(分) 301 | "average_release_time": "0", #平均転送時間(分) 302 | "recent_success_transaction_ratio": "0", #最近の成約率 303 | "register_at": 1, #登録時間 304 | "remark": "备注", #メモ 305 | "bind_email": true, #メールアドレスの紐付けを設定しますか? 306 | "bind_phone": true, #携帯の紐付けを設定しますか? 307 | "kyc": true, #KYC認証しますか? 308 | "enable_otc": true, #OTCユーザーでありますか? 309 | "set_payment_method": false, #支払い方法を設定しましたか? 310 | "set_assets_password": false, #資金パスワードを設定しましたか? 311 | "binding_google_auth": false, #2段階認証を設定しましたか? 312 | "phone": "86-13000000000", #電話番号 313 | "first_name": fu, #姓 314 | "last_name": lei, #名 315 | "email": "mock_user@fcoin.com" #メール 316 | } 317 | ``` 318 | 319 | ## OTC口座資金総額の照会 320 | 321 | ### リクエスト 322 | 323 | ```GET https://api.fcoin.com/v2/broker/otc/users/me/balances``` 324 | 325 | ### リクエスト・パラメータ 326 | 327 | 無 328 | 329 | ### 応答結果 330 | 331 | ``` 332 | { 333 | "status": "ok", 334 | "data": { 335 | "summary": "0.00000000", 336 | "balances": [ 337 | { 338 | "currency": "btc", # 通貨 339 | "available_amount": 20.3202023, # 利用可能額 340 | "frozen_amount": 32093.3223 # 凍結中の数量 341 | }, 342 | { 343 | "currency": "eth", 344 | "available_amount": 20.3202023, 345 | "frozen_amount": 32093.3223 346 | } 347 | ] 348 | } 349 | } 350 | ``` 351 | 352 | ## OTC口座の指定された通貨の資金照会 353 | 354 | ### リクエスト・URL 355 | 356 | `GET https://api.fcoin.com/v2/broker/otc/users/me/balance` 357 | 358 | ### リクエスト・パラメータ 359 | |ペラメータ|デフォルト値|説明| 360 | |:------|:------:|:------| 361 | |currency|無|通貨(例):btc/eth/usdt 362 | 363 | ### 応答結果 364 | 365 | ``` 366 | { 367 | "status": "ok", 368 | "data": { 369 | "summary": "0.00000000", # btcに換算すると 370 | "balances": [ 371 | { 372 | "currency": "btc", # 通貨 373 | "available_amount": 20.3202023, # 利用可能額 374 | "frozen_amount": 32093.3223 # 凍結中の数量 375 | } 376 | ] 377 | } 378 | } 379 | ``` -------------------------------------------------------------------------------- /source/includes/jp/_publics.md: -------------------------------------------------------------------------------- 1 | # 公開API 2 | 3 | ## サーバー時刻の照会 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | server_time = api.server_time() 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let serverTime = api.serverTime(); 17 | ``` 18 | 19 | > 応答結果は下記のとおりです: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": 1523430502977 25 | } 26 | ``` 27 | 28 | このAPIを使用して、サーバー時刻を取得できます。 29 | 30 | ### HTTP Request 31 | 32 | `GET https://api.fcoin.com/v2/public/server-time` 33 | 34 | 35 | 36 | 37 | 38 | ## 取扱い仮想通貨の照会 39 | 40 | ```python 41 | import fcoin 42 | 43 | api = fcoin.authorize('key', 'secret', timestamp) 44 | currencies = api.currencies() 45 | ``` 46 | 47 | ```javascript 48 | const fcoin = require('fcoin'); 49 | 50 | let api = fcoin.authorize('key', 'secret', timestamp); 51 | let currencies = api.currencies(); 52 | ``` 53 | 54 | > 応答結果は下記のとおりです: 55 | 56 | ```json 57 | { 58 | "status": 0, 59 | "data": [ 60 | "btc", 61 | "eth" 62 | ] 63 | } 64 | ``` 65 | 66 | このAPIを使用して、取扱い仮想通貨を取得できます。 67 | 68 | ### HTTP Request 69 | 70 | `GET https://api.fcoin.com/v2/public/currencies` 71 | 72 | 73 | 74 | 75 | 76 | ## 取引通貨ペアの照会 77 | 78 | ```python 79 | import fcoin 80 | 81 | api = fcoin.authorize('key', 'secret', timestamp) 82 | symbols = api.symbols() 83 | ``` 84 | 85 | ```javascript 86 | const fcoin = require('fcoin'); 87 | 88 | let api = fcoin.authorize('key', 'secret', timestamp); 89 | let symbols = api.symbols(); 90 | ``` 91 | 92 | > 応答結果は下記のとおりです: 93 | 94 | ```json 95 | { 96 | "status": 0, 97 | "data": [ 98 | { 99 | "name": "btcusdt", 100 | "base_currency": "btc", 101 | "quote_currency": "usdt", 102 | "price_decimal": 2, 103 | "amount_decimal": 4 104 | }, 105 | { 106 | "name": "ethusdt", 107 | "base_currency": "eth", 108 | "quote_currency": "usdt", 109 | "price_decimal": 2, 110 | "amount_decimal": 4 111 | } 112 | ] 113 | } 114 | ``` 115 | 116 | このAPIを使用して、取引通貨ペアを取得できます。 117 | 118 | ### HTTP Request 119 | 120 | `GET https://api.fcoin.com/v2/public/symbols` 121 | -------------------------------------------------------------------------------- /source/includes/jp/_small_currency_exchange.md: -------------------------------------------------------------------------------- 1 | # 小額通貨の両替 2 | 3 | - 両替履歴の状態に関する説明 4 | 5 | 6 | | 属性 | 説明 | 7 | |:------|:------:| 8 | |WAITING_TRANSFER_TO_SYSTEM|システムアカウントへ振り替え待ち 9 | |WAITING_REFUND|ユーザーに返却待ち 10 | |FAIL|両替失敗 11 | |WAITING_TRANSFER_TO_USER|ユーザーに振り替え待ち 12 | |SUCCESS|両替完了 13 | 14 | ## ユーザーは小額通貨を両替する 15 | 16 | `POST https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 17 | 18 | ### パラメータ・リクエスト 19 | | 属性 | 説明 | 20 | |:------|:------| 21 | |exchange_currency | もらう通貨:FT 22 | |small_currency_amounts | jsonフォーマット:[{"currency":"usdt","amount":"0.4"},{"currency":"btc","amount":"0.0002"}]。その中で、currencyは送る通貨です。amountは両替の数量です(0より大きくなる必要があります。最大18位の精度をサポートします)。 23 | 24 | ### レスポンス 25 | ``` 26 | { 27 | "status": "ok", 28 | "data": null 29 | } 30 | ``` 31 | 32 | ## 両替可能な通貨の照会 33 | 34 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange/exchangeable_small_currencies/{exchange_currency}` 35 | 36 | ### パラメータ・リクエスト 37 | 38 | exchange_currency: もらう通貨 39 | 40 | ### レスポンス 41 | 42 | ``` 43 | { 44 | "exchange_currency": "ft", もらう通貨 45 | "total_exchange_amount": "0", もらった通貨の総額 46 | "exchangeable_small_currencies": [ 47 | { 48 | "currency": "dash", 両替待ちの通貨 49 | "available_amount": "0.00063517", 利用可能な残高 50 | "valuation": "0.06805309", 利用可能な残高の価値(usdt) 51 | "exchange_amount": "1.71670037", もらえる数量(手数料未支払い)  52 | "exchangeable": true 両替可能ですか(Falseの場合、両替する時計算に入れず) 53 | }, 54 | { 55 | "currency": "usdt", 56 | "available_amount": "0.3", 57 | "valuation": "0.3", 58 | "exchange_amount": "15", 59 | "exchangeable": true 60 | } 61 | ] 62 | } 63 | 64 | ``` 65 | 66 | ## 両替履歴の照会 67 | 68 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 69 | 70 | ### パラメータ・リクエスト 71 | 72 | | 属性 | タイプ  | 説明 | 73 | |:------|:------:|:------| 74 | |has_prev |Boolean| 前のページが含まれますか?このパラメータはフロントエンドにより制御され、そのままで返します。 75 | |id |String|最後のページングのID 76 | |page_size |Integer| リクエスト可能な数量(1〜40)、デフォルトは40です。 77 | 78 | 79 | #### レスポンス 80 | 81 | ``` 82 | 83 | { 84 | "content": [ 85 | { 86 | "id": "jS6XfuzBhXXhDBtt_dNDqw", 記録ID 87 | "exchange_currency": "ft", もらう通貨 88 | "fees": "0.056006006006006007", 手数料 89 | "exchange_amount": "28.003003003003003003", もらえる数量 90 | "actual_exchange_amount": "27.946996996996996996", 両替でもらった数量 = もらえる数量 - 手数料  91 | "state": "waiting_transfer_to_user", 両替状態 92 | "created_at": 1577949932988 両替時間 93 | } 94 | ], 95 | "current_elements": 1, 96 | "has_prev": false, 97 | "has_next": false, 98 | "next_page_id": "jS6XfuzBhXXhDBtt_dNDqw" 99 | } 100 | 101 | ``` 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /source/includes/kr/_accounts.md: -------------------------------------------------------------------------------- 1 | # 账户与资产 2 | 3 | ## 查询账户资产 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | api.accounts_balance 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let orders = api.accountsBalance; 17 | ``` 18 | 19 | > 响应结果如下: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": [ 25 | { 26 | "currency": "btc", 27 | "available": "50.0", 28 | "frozen": "50.0", 29 | "balance": "100.0" 30 | } 31 | ] 32 | } 33 | ``` 34 | 35 | 此 API 用于查询用户的资产列表。 36 | 37 | ### HTTP Request 38 | 39 | `GET https://api.fcoin.com/v2/accounts/balance` 40 | -------------------------------------------------------------------------------- /source/includes/kr/_authentication.md: -------------------------------------------------------------------------------- 1 | # 认证 2 | 3 | > 执行下面的代码进行用户验证: 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | ``` 10 | 11 | ```javascript 12 | const fcoin = require('fcoin'); 13 | 14 | let api = fcoin.authorize('key', 'secret', timestamp); 15 | ``` 16 | 17 | FCoin 使用 API key 和 API secret 进行验证,请访问 [设置中心](https://exchange.fcoin.com/setting),并注册成为开发者,获取 API key 和 API secret。 18 | 19 | FCoin 的 API 请求,除公开的 API 外都需要携带 API key 以及签名 20 | 21 | 22 | 23 | 24 | ## 访问限制 25 | 26 | 目前访问频率为每个用户 100次 / 10秒,未来会按照业务区分访问频率限制。 27 | 28 | 29 | 30 | 31 | ## API 签名 32 | 33 | 签名前准备的数据如下: 34 | 35 | `HTTP_METHOD` + `HTTP_REQUEST_URI` + `TIMESTAMP` + `POST_BODY` 36 | 37 | 连接完成后,进行 `Base64` 编码,对编码后的数据进行 `HMAC-SHA1` 签名,并对签名进行二次 `Base64` 编码,各部分解释如下: 38 | 39 | 42 | 43 | ### HTTP_METHOD 44 | 45 | `GET`, `POST`, `DELETE`, `PUT` 需要大写 46 | 47 | ### HTTP_REQUEST_URI 48 | 49 | `https://api.fcoin.com/v2/` 为 v2 API 的请求前缀 50 | 51 | 后面再加上真正要访问的资源路径,如 `orders?param1=value1`,最终即 `https://api.fcoin.com/v2/orders?param1=value1` 52 | 53 | 对于请求的 URI 中的参数,需要按照按照字母表排序! 54 | 55 | 即如果请求的 URI 为 `https://api.fcoin.com/v2/orders?c=value1&b=value2&a=value3`,则进行签名时,应先将请求参数按照字母表排序,最终进行签名的 URI 为 `https://api.fcoin.com/v2/orders?a=value3&b=value2&c=value1`, 56 | 请注意,原请求 URI 中的三个参数顺序为 `c, b, a`,排序后为 `a, b, c`。 57 | 58 | ### TIMESTAMP 59 | 60 | 访问 API 时的 UNIX EPOCH 时间戳,需要和服务器之间的时间差少于 30 秒 61 | 62 | ### POST_BODY 63 | 64 | 如果是 `POST` 请求,`POST` 请求数据也需要被签名,签名规则如下: 65 | 66 | 所有请求的 key 按照字母顺序排序,然后进行 url 参数化,并使用 `&` 连接。 67 | 68 | 71 | 72 | > 如果请求数据为: 73 | 74 | ```json 75 | { 76 | "username": "username", 77 | "password": "passowrd" 78 | } 79 | ``` 80 | 81 | > 则先将 key 按照字母排序,然后进行 url 参数化,即: 82 | 83 | ``` 84 | password=password 85 | username=username 86 | ``` 87 | 88 | > 因为 `p` 在字母表中的排序在 `u` 之前,所以 `password` 要放在 `username` 之前,然后使用 `&` 进行连接,即: 89 | 90 | ``` 91 | password=password&username=username 92 | ``` 93 | 94 | ## 完整示例 95 | 96 | > 对于如下的请求: 97 | 98 | ``` 99 | POST https://api.fcoin.com/v2/orders 100 | 101 | { 102 | "type": "limit", 103 | "side": "buy", 104 | "amount": "100.0", 105 | "price": "100.0", 106 | "symbol": "btcusdt" 107 | } 108 | 109 | timestamp: 1523069544359 110 | ``` 111 | 112 | > 签名前的准备数据如下: 113 | 114 | ``` 115 | POSThttps://api.fcoin.com/v2/orders1523069544359amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit 116 | ``` 117 | 118 | > 进行 Base64 编码,得到: 119 | 120 | ``` 121 | UE9TVGh0dHBzOi8vYXBpLmZjb2luLmNvbS92Mi9vcmRlcnMxNTIzMDY5NTQ0MzU5YW1vdW50PTEwMC4wJnByaWNlPTEwMC4wJnNpZGU9YnV5JnN5bWJvbD1idGN1c2R0JnR5cGU9bGltaXQ= 122 | ``` 123 | 124 | > 拷贝在申请 API Key 时获得的秘钥(API SECRET),下面的签名结果采用 `3600d0a74aa3410fb3b1996cca2419c8` 作为示例, 125 | 126 | > 对得到的结果使用秘钥进行 `HMAC-SHA1` 签名,并对二进制结果进行 `Base64` 编码,得到: 127 | 128 | ``` 129 | DeP6oftldIrys06uq3B7Lkh3a0U= 130 | ``` 131 | 132 | > 即生成了用于向 API 服务器进行验证的最终签名 133 | 134 | ## 参数名称 135 | 136 | * `FC-ACCESS-KEY` 137 | * `FC-ACCESS-SIGNATURE` 138 | * `FC-ACCESS-TIMESTAMP` 139 | 140 | ## 说明 141 | 142 | 可以使用[开发者工具]()(暂未开放)进行在线联调测试。 143 | -------------------------------------------------------------------------------- /source/includes/kr/_errors.md: -------------------------------------------------------------------------------- 1 | # 错误代码 2 | 3 | 错误代码 | 含义解释 4 | ---------- | ------- 5 | 400 | Bad Request -- 错误的请求 6 | 401 | Unauthorized -- API key 或者签名,时间戳有误 7 | 403 | Forbidden -- 禁止访问 8 | 404 | Not Found -- 未找到请求的资源 9 | 405 | Method Not Allowed -- 使用的 HTTP 方法不适用于请求的资源 10 | 406 | Not Acceptable -- 请求的内容格式不是 JSON 11 | 429 | Too Many Requests -- 请求受限,请降低请求频率 12 | 500 | Internal Server Error -- 服务内部错误,请稍后再进行尝试 13 | 503 | Service Unavailable -- 服务不可用,请稍后再进行尝试 14 | -------------------------------------------------------------------------------- /source/includes/kr/_introduction.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 通过了解以下信息,您可以方便的使用 FCoin 提供的 API 来接入 FCoin 交易平台。 4 | -------------------------------------------------------------------------------- /source/includes/kr/_markets.md: -------------------------------------------------------------------------------- 1 | # 行情 2 | 3 | ## 行情概述 4 | 5 | 行情是一个全公开的 API, 当前同时提供了 HTTP 和 WebSocket 的 API. 6 | 为确保可以更及时的获得行情, 推荐使用 WebSocket 进行接入. 7 | 为尽可能行情的实时性能, 当前公开部分只能获取最近一段时间的行情, 如果有需要获取全量或者历史行情, 请咨询 `support@fcoin.com` 8 | 9 | 所有 HTTP 请求的 URL base 为: `https://api.fcoin.com/v2/market` 10 | 11 | 所有 WebSocket 请求的 URL 为: `wss://api.fcoin.com/v2/ws` 12 | 13 | 下文会统一术语: 14 | 15 | - `topic` 表示订阅的主题 16 | - `symbol` 表示对应交易币种. 所有币种区分的 topic 都在 topic 末尾. 17 | - `ticker` 行情 tick 信息, 包含最新成交价, 最新成交量, 买一卖一, 近 24 小时成交量. 18 | - `depth` 表示行情深度, 买卖盘, 盘口. 19 | - `level` 表示行情深度类型. 如 `L20`, `L100`. 20 | - `trade` 表示最新成交, 最新交易. 21 | - `candle` 表示蜡烛图, 蜡烛棒, K 线. 22 | - `resolution` 表示蜡烛图的种类. 如 `M1`, `M15`. 23 | - `base volume` 表示基准货币成交量, 如 btcusdt 中 btc 的量. 24 | - `quote volume` 表示计价货币成交量, 如 btcusdt 中 usdt 的量 25 | - `ts` 表示推送服务器的时间. 是毫秒为单位的数字型字段, unix epoch in millisecond. 26 | 27 | ## WebSocket 首次建立连接 28 | 29 | 服务器会发送一个欢迎信息 30 | 31 | > 服务器返回 32 | 33 | ```json 34 | { 35 | "type":"hello", 36 | "ts":1523693784042 37 | } 38 | ``` 39 | 40 | - `ts`: 推送服务器当前的时间. 41 | 42 | ## WebSocket 连接保持 - heartbeat 43 | 44 | WebSocket 客户端和 WebSocket 服务器建立连接之后,推荐 WebSocket Client 每隔 *30s*(这个频率可能会变化) 向服务器发起一次 ping 请求,如果服务器长时间没有接收到客户端的 ping 请求将会主动断开连接(300s)。 45 | 46 | ### WebSocket 请求 47 | 48 | ```python 49 | import time 50 | import fcoin 51 | 52 | api = fcoin.authorize('key', 'secret', timestamp) 53 | now_ms = int(time.time()) 54 | api.market.ping(now_ms) 55 | ``` 56 | 57 | 58 | > 服务器返回 59 | 60 | ```json 61 | { 62 | "type":"ping", 63 | "ts":1523693784042, 64 | "gap":112 65 | } 66 | ``` 67 | 68 | - `gap`: 推送服务器处理此语句的时间和客户端传输的时间差. 69 | - `ts`: 推送服务器当前的时间. 70 | 71 | ## 获取推送服务器时间 72 | 73 | 可以通过 ping 请求时服务器返回的 ts 和 gap 值获取推送服务器时间和数据传输时间差 74 | 75 | - gap: 推送服务器处理此语句的时间和客户端传输的时间差. 76 | - ts: 推送服务器当前的时间. 77 | 78 | 79 | ## 获取 ticker 数据 80 | 81 | 为了使得 ticker 信息组足够小和快, 我们强制使用了列表格式. 82 | 83 | > ticker 列表对应字段含义说明: 84 | 85 | ```json 86 | [ 87 | "最新成交价", 88 | "最近一笔成交的成交量", 89 | "最大买一价", 90 | "最大买一量", 91 | "最小卖一价", 92 | "最小卖一量", 93 | "24小时前成交价", 94 | "24小时内最高价", 95 | "24小时内最低价", 96 | "24小时内基准货币成交量, 如 btcusdt 中 btc 的量", 97 | "24小时内计价货币成交量, 如 btcusdt 中 usdt 的量" 98 | ] 99 | ``` 100 | 101 | 102 | ### HTTP 请求 103 | 104 | `GET https://api.fcoin.com/v2/market/ticker/$symbol` 105 | 106 | ```python 107 | import fcoin 108 | 109 | api = fcoin.authorize('key', 'secret', timestamp) 110 | api.market.get_ticker("ethbtc") 111 | 112 | ``` 113 | 114 | ```json 115 | { 116 | "status": 0, 117 | "data": { 118 | "type": "ticker.btcusdt", 119 | "seq": 680035, 120 | "ticker": [ 121 | 7140.890000000000000000, 122 | 1.000000000000000000, 123 | 7131.330000000, 124 | 233.524600000, 125 | 7140.890000000, 126 | 225.495049866, 127 | 7140.890000000, 128 | 7140.890000000, 129 | 7140.890000000, 130 | 1.000000000, 131 | 7140.890000000000000000 132 | ] 133 | } 134 | } 135 | ``` 136 | 137 | ### WebSocket 订阅 138 | 139 | topic: `ticker.$symbol` 140 | 141 | ```python 142 | import fcoin 143 | 144 | fcoin_ws = fcoin.init_ws() 145 | topics = ["ticker.ethbtc", "ticker.btcusdt"] 146 | fcoin_ws.handle(print) 147 | fcoin_ws.sub(topics) 148 | ``` 149 | 150 | > 订阅成功的响应结果如下: 151 | 152 | ```json 153 | { 154 | "type": "topics", 155 | "topics": ["ticker.ethbtc", "ticker.btcusdt"] 156 | } 157 | ``` 158 | 159 | > 常规订阅的通知消息格式如下: 160 | 161 | ```json 162 | { 163 | "type": "ticker.btcusdt", 164 | "seq": 680035, 165 | "ticker": [ 166 | 7140.890000000000000000, 167 | 1.000000000000000000, 168 | 7131.330000000, 169 | 233.524600000, 170 | 7140.890000000, 171 | 225.495049866, 172 | 7140.890000000, 173 | 7140.890000000, 174 | 7140.890000000, 175 | 1.000000000, 176 | 7140.890000000000000000 177 | ] 178 | } 179 | ``` 180 | 181 | 182 | 183 | ## 获取最新的深度明细 184 | 185 | ### HTTP Request 186 | 187 | `GET https://api.fcoin.com/v2/market/depth/$level/$symbol` 188 | 189 | `$level` 包含的种类: 190 | 191 | 类型 | 说明 192 | -------- | -------- 193 | `L20` | 20 档行情深度. 194 | `L100` | 100 档行情深度. 195 | 196 | 其中 `L20` 的推送时间会略早于 `L100`, 推送频次会略多于 `L100`, 看具体的压力和情况. 此处请按需使用. 197 | 198 | ### WebSocket 订阅 199 | 200 | 订阅 topic: `depth.$level.$symbol` 201 | 202 | ```python 203 | import fcoin 204 | 205 | fcoin_ws = fcoin.init_ws() 206 | topics = ["depth.L20.ethbtc", "depth.L100.btcusdt"] 207 | fcoin_ws.handle(print) 208 | fcoin_ws.sub(topics) 209 | ``` 210 | 211 | ```javascript 212 | const fcoin = require('fcoin'); 213 | 214 | let fcoin_ws = fcoin.init_ws() 215 | topics = ["depth.L20.ethbtc", "depth.L100.btcusdt"] 216 | fcoin_ws.handle(print) 217 | fcoin_ws.sub(topics) 218 | ``` 219 | 220 | 221 | > 订阅成功的响应结果如下: 222 | 223 | ```json 224 | { 225 | "type": "topics", 226 | "topics": ["depth.L20.ethbtc", "depth.L100.btcusdt"] 227 | } 228 | ``` 229 | 230 | > 常规的推送结果 231 | 232 | bids 和 asks 对应的数组一定是偶数条目, 买(卖)1价, 买(卖)1量, 依次往后排列. 233 | 234 | ```json 235 | { 236 | "type": "depth.L20.ethbtc", 237 | "ts": 1523619211000, 238 | "seq": 120, 239 | "bids": [0.000100000, 1.000000000, 0.000010000, 1.000000000], 240 | "asks": [1.000000000, 1.000000000] 241 | } 242 | ``` 243 | 244 | ## 获取最新的成交明细 245 | 246 | 通过对比其中的成交 id 大小才能决定是否是更新的成交.{trade id} 247 | 需要注意, 常规由于 trade 到 transaction 过程的存在, 公开行情的成交 id 并不实际对应清算系统中的成交 id. 248 | 即使成交是一条记录, 也无法保证最新成交在重新获取时候 id 永远保持一致. 249 | 250 | PS: 历史行情中, 是可以保证成交 id 保持恒定. {transaction id} 此处只作为行情更新通知, 不应依赖归档使用. 251 | 252 | 253 | ### HTTP Request 254 | 255 | `GET https://api.fcoin.com/v2/market/trades/$symbol` 256 | 257 | ### 查询参数(HTTP Query) 258 | 259 | 参数 | 默认值 | 描述 260 | --------- | ------- | ----------- 261 | before | | 查询某个 id 之前的 Trade 262 | limit | | 默认为 20 条 263 | 264 | ### WebSocket 获取最近的成交 265 | 266 | topic: `trade.$symbol` 267 | limit: 最近的成交条数 268 | args: [topic, limit] 269 | 270 | ```python 271 | import fcoin 272 | 273 | fcoin_ws = fcoin.init_ws() 274 | topic = "trade.ethbtc" 275 | limit = 3 276 | args = [topic, limit] 277 | fcoin_ws.req(args, rep_handler) 278 | ``` 279 | 280 | > 请求成功的响应结果如下: 281 | 282 | ```json 283 | {"id":null, 284 | "ts":1523693400329, 285 | "data":[ 286 | { 287 | "amount":1.000000000, 288 | "ts":1523419946174, 289 | "id":76000, 290 | "side":"sell", 291 | "price":4.000000000 292 | }, 293 | { 294 | "amount":1.000000000, 295 | "ts":1523419114272, 296 | "id":74000, 297 | "side":"sell", 298 | "price":4.000000000 299 | }, 300 | { 301 | "amount":1.000000000, 302 | "ts":1523415182356, 303 | "id":71000, 304 | "side":"sell", 305 | "price":3.000000000 306 | } 307 | ] 308 | } 309 | ``` 310 | 311 | ### WebSocket 订阅 312 | 313 | ```python 314 | import fcoin 315 | 316 | fcoin_ws = fcoin.init_ws() 317 | topics = ["trade.ethbtc", "trade.btcusdt"] 318 | fcoin_ws.handle(print) 319 | fcoin_ws.sub(topics) 320 | ``` 321 | 322 | > 订阅成功的响应结果如下: 323 | 324 | ```json 325 | { 326 | "type": "topics", 327 | "topics": ["trade.ethbtc"] 328 | } 329 | ``` 330 | 331 | 332 | > 常规的推送结果 333 | 334 | ```json 335 | { 336 | "type":"trade.ethbtc", 337 | "id":76000, 338 | "amount":1.000000000, 339 | "ts":1523419946174, 340 | "side":"sell", 341 | "price":4.000000000 342 | } 343 | ``` 344 | 345 | ## 获取 Candle 信息 346 | 347 | ### HTTP Request 348 | 349 | `GET https://api.fcoin.com/v2/market/candles/$resolution/$symbol` 350 | 351 | ### 查询参数(HTTP Query) 352 | 353 | 参数 | 默认值 | 描述 354 | --------- | ------- | ----------- 355 | before | | 查询某个 id 之前的 Candle 356 | limit | | 默认为 20 条 357 | 358 | $resolution 包含的种类 359 | 360 | 类型 | 说明 361 | -------- | -------- 362 | `M1` | 1 分钟 363 | `M3` | 3 分钟 364 | `M5` | 5 分钟 365 | `M15` | 15 分钟 366 | `M30` | 30 分钟 367 | `H1` | 1 小时 368 | `H4` | 4 小时 369 | `H6` | 6 小时 370 | `D1` | 1 日 371 | `W1` | 1 周 372 | `MN` | 1 月 373 | 374 | ### Weboskcet 订阅 Candle 数据 375 | 376 | topic: `candle.$resolution.$symbol` 377 | 378 | ```python 379 | import fcoin 380 | 381 | fcoin_ws = fcoin.init_ws() 382 | topics = ["candle.M1.ethbtc", "depth.L20.ethbtc", "trade.ethbtc"] 383 | fcoin_ws.handle(print) 384 | fcoin_ws.sub(topics) 385 | ``` 386 | 387 | > 订阅成功的响应结果如下: 388 | 389 | 390 | ```json 391 | { 392 | "type": "topics", 393 | "topics": ["candle.M1.ethbtc"] 394 | } 395 | ``` 396 | 397 | > 常规订阅的通知消息格式如下: 398 | 399 | ```json 400 | { 401 | "type":"candle.M1.ethbtc", 402 | "id":1523691480, 403 | "seq":11400000, 404 | "open":2.000000000, 405 | "close":2.000000000, 406 | "high":2.000000000, 407 | "low":2.000000000, 408 | "count":0, 409 | "base_vol":0, 410 | "quote_vol":0 411 | } 412 | ``` 413 | -------------------------------------------------------------------------------- /source/includes/kr/_order_errors.md: -------------------------------------------------------------------------------- 1 | ## 订单错误代码 2 | 3 | 错误代码 | 含义解释 4 | ---------- | ------- 5 | 2000 | 账户错误 6 | -------------------------------------------------------------------------------- /source/includes/kr/_orders.md: -------------------------------------------------------------------------------- 1 | # 订单 2 | 3 | ## 订单模型说明 4 | 5 | 订单模型由以下属性构成: 6 | 7 | 属性 | 类型 | 含义解释 8 | ---------- | ------- | ------- 9 | `id` | `String` | 订单 ID 10 | `symbol` | `String` | 交易对 11 | `side` | `String` | 交易方向(`buy`, `sell`) 12 | `type` | `String` | 订单类型(`limit`,`market`,`ioc`,`fok`) 13 | `price` | `String` | 下单价格 14 | `amount` | `String` | 下单数量 15 | `state` | `String` | 订单状态 16 | `executed_value` | `String` | 已成交 17 | `filled_amount` | `String` | 成交量 18 | `fill_fees` | `String` | 手续费 19 | `created_at` | `Long` | 创建时间 20 | `source` | `String` | 来源 21 | 22 | 订单状态说明: 23 | 24 | 属性 | 含义解释 25 | ----------- | ------- 26 | `submitted` | 已提交 27 | `partial_filled` | 部分成交 28 | `partial_canceled` | 部分成交已撤销 29 | `filled` | 完全成交 30 | `canceled` | 已撤销 31 | `pending_cancel` | 撤销已提交 32 | 33 | ## 创建新的订单 34 | 35 | ```python 36 | import fcoin 37 | 38 | api = fcoin.authorize('key', 'secret', timestamp) 39 | order_create_param = fcoin.order_create_param('btcusdt', 'buy', 'limit', '8000.0', '1.0') 40 | api.orders.create(order_create_param) 41 | ``` 42 | 43 | ```javascript 44 | const fcoin = require('fcoin'); 45 | 46 | let api = fcoin.authorize('key', 'secret', timestamp); 47 | let orderCreateParam = fcoin.orderCreateParam('btcusdt', 'buy', 'limit', '8000.0', '1.0'); 48 | let orders = api.orders.create(orderCreateParam); 49 | ``` 50 | 51 | > 响应结果如下: 52 | 53 | ```json 54 | { 55 | "status": 0, 56 | "data": "9d17a03b852e48c0b3920c7412867623" 57 | } 58 | ``` 59 | 60 | 此 API 用于创建新的订单。 61 | 62 | ### HTTP Request 63 | 64 | `POST https://api.fcoin.com/v2/orders` 65 | 66 | ### 请求参数 67 | 68 | 参数 | 默认值 | 描述 69 | --------- | ------- | ----------- 70 | symbol | 无 | 交易对 71 | side | 无 | 交易方向 72 | type | 无 | 订单类型 73 | price | 无 | 价格 74 | amount | 无 | 下单量 75 | 76 | 77 | 78 | 79 | 80 | 81 | ## 查询订单列表 82 | 83 | ```python 84 | import fcoin 85 | 86 | api = fcoin.authorize('key', 'secret', timestamp) 87 | api.orders.get() 88 | ``` 89 | 90 | ```javascript 91 | const fcoin = require('fcoin'); 92 | 93 | let api = fcoin.authorize('key', 'secret', timestamp); 94 | let orders = api.orders.get(); 95 | ``` 96 | 97 | > 响应结果如下: 98 | 99 | ```json 100 | { 101 | "status": 0, 102 | "data": [ 103 | { 104 | "id": "string", 105 | "symbol": "string", 106 | "type": "limit", 107 | "side": "buy", 108 | "price": "string", 109 | "amount": "string", 110 | "state": "submitted", 111 | "executed_value": "string", 112 | "fill_fees": "string", 113 | "filled_amount": "string", 114 | "created_at": 0, 115 | "source": "web" 116 | } 117 | ] 118 | } 119 | ``` 120 | 121 | 此 API 用于查询订单列表。 122 | 123 | ### HTTP Request 124 | 125 | `GET https://api.fcoin.com/v2/orders` 126 | 127 | ### 查询参数 128 | 129 | 参数 | 默认值 | 描述 130 | --------- | ------- | ----------- 131 | symbol | | 交易对 132 | states | | 订单状态 133 | before | | 查询某个页码之前的订单 134 | after | | 查询某个页码之后的订单 135 | limit | | 每页的订单数量,默认为 20 条 136 | 137 | 138 | 139 | 140 | 141 | ## 获取指定订单 142 | 143 | ```python 144 | import fcoin 145 | 146 | api = fcoin.authorize('key', 'secret', timestamp) 147 | api.orders.get('9d17a03b852e48c0b3920c7412867623') 148 | ``` 149 | 150 | ```javascript 151 | const fcoin = require('fcoin'); 152 | 153 | let api = fcoin.authorize('key', 'secret', timestamp); 154 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623'); 155 | ``` 156 | 157 | > 响应结果如下: 158 | 159 | ```json 160 | { 161 | "status": 0, 162 | "data": { 163 | "id": "9d17a03b852e48c0b3920c7412867623", 164 | "symbol": "string", 165 | "type": "limit", 166 | "side": "buy", 167 | "price": "string", 168 | "amount": "string", 169 | "state": "submitted", 170 | "executed_value": "string", 171 | "fill_fees": "string", 172 | "filled_amount": "string", 173 | "created_at": 0, 174 | "source": "web" 175 | } 176 | } 177 | ``` 178 | 179 | 此 API 用于返回指定的订单详情。 180 | 181 | ### HTTP Request 182 | 183 | `GET https://api.fcoin.com/v2/orders/{order_id}` 184 | 185 | ### URL 参数 186 | 187 | 参数 | 描述 188 | --------- | ----------- 189 | order_id | 订单 ID 190 | 191 | 192 | 193 | 194 | 195 | 196 | ## 申请撤销订单 197 | 198 | ```python 199 | import fcoin 200 | 201 | api = fcoin.authorize('key', 'secret', timestamp) 202 | api.orders.submit_cancel(2) 203 | ``` 204 | 205 | ```javascript 206 | const fcoin = require('fcoin'); 207 | 208 | let api = fcoin.authorize('key', 'secret', timestamp); 209 | let max = api.orders.submitCancel(2); 210 | ``` 211 | 212 | > 响应结果如下: 213 | 214 | ```json 215 | { 216 | "status": 0, 217 | "msg": "string", 218 | "data": true 219 | } 220 | ``` 221 | 222 | 此 API 用于撤销指定订单,订单撤销过程是异步的,即此 API 的调用成功代表着订单已经进入撤销申请的过程,需要等待撮合的进一步处理,才能进行订单的撤销确认。 223 | 224 | ### HTTP Request 225 | 226 | `POST https://api.fcoin.com/v2/orders/{order_id}/submit-cancel` 227 | 228 | ### URL 参数 229 | 230 | 参数 | 解释 231 | --------- | ----------- 232 | order_id | 订单 ID 233 | 234 | 235 | 236 | 237 | 238 | 239 | ## 查询指定订单的成交记录 240 | 241 | ```python 242 | import fcoin 243 | 244 | api = fcoin.authorize('key', 'secret', timestamp) 245 | api.orders.get('9d17a03b852e48c0b3920c7412867623').match_results() 246 | ``` 247 | 248 | ```javascript 249 | const fcoin = require('fcoin'); 250 | 251 | let api = fcoin.authorize('key', 'secret', timestamp); 252 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623').matchResults(); 253 | ``` 254 | 255 | > 响应结果如下: 256 | 257 | ```json 258 | { 259 | "status": 0, 260 | "data": [ 261 | { 262 | "price": "string", 263 | "fill_fees": "string", 264 | "filled_amount": "string", 265 | "side": "buy", 266 | "type": "limit", 267 | "created_at": 0 268 | } 269 | ] 270 | } 271 | ``` 272 | 273 | 此 API 用于获取指定订单的成交记录 274 | 275 | ### HTTP Request 276 | 277 | `GET https://api.fcoin.com/v2/orders/{order_id}/match-results` 278 | 279 | ### URL 参数 280 | 281 | 参数 | 解释 282 | --------- | ----------- 283 | order_id | 订单 ID 284 | -------------------------------------------------------------------------------- /source/includes/kr/_publics.md: -------------------------------------------------------------------------------- 1 | # 公开接口 2 | 3 | ## 查询服务器时间 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | server_time = api.server_time() 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let serverTime = api.serverTime(); 17 | ``` 18 | 19 | > 响应结果如下: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": 1523430502977 25 | } 26 | ``` 27 | 28 | 此 API 用于获取服务器时间。 29 | 30 | ### HTTP Request 31 | 32 | `GET https://api.fcoin.com/v2/public/server-time` 33 | 34 | 35 | 36 | 37 | 38 | ## 查询可用币种 39 | 40 | ```python 41 | import fcoin 42 | 43 | api = fcoin.authorize('key', 'secret', timestamp) 44 | currencies = api.currencies() 45 | ``` 46 | 47 | ```javascript 48 | const fcoin = require('fcoin'); 49 | 50 | let api = fcoin.authorize('key', 'secret', timestamp); 51 | let currencies = api.currencies(); 52 | ``` 53 | 54 | > 响应结果如下: 55 | 56 | ```json 57 | { 58 | "status": 0, 59 | "data": [ 60 | "btc", 61 | "eth" 62 | ] 63 | } 64 | ``` 65 | 66 | 此 API 用于获取可用币种。 67 | 68 | ### HTTP Request 69 | 70 | `GET https://api.fcoin.com/v2/public/currencies` 71 | 72 | 73 | 74 | 75 | 76 | ## 查询可用交易对 77 | 78 | ```python 79 | import fcoin 80 | 81 | api = fcoin.authorize('key', 'secret', timestamp) 82 | symbols = api.symbols() 83 | ``` 84 | 85 | ```javascript 86 | const fcoin = require('fcoin'); 87 | 88 | let api = fcoin.authorize('key', 'secret', timestamp); 89 | let symbols = api.symbols(); 90 | ``` 91 | 92 | > 响应结果如下: 93 | 94 | ```json 95 | { 96 | "status": 0, 97 | "data": [ 98 | { 99 | "name": "btcusdt", 100 | "base_currency": "btc", 101 | "quote_currency": "usdt", 102 | "price_decimal": 2, 103 | "amount_decimal": 4 104 | }, 105 | { 106 | "name": "ethusdt", 107 | "base_currency": "eth", 108 | "quote_currency": "usdt", 109 | "price_decimal": 2, 110 | "amount_decimal": 4 111 | } 112 | ] 113 | } 114 | ``` 115 | 116 | 此 API 用于获取可用交易对。 117 | 118 | ### HTTP Request 119 | 120 | `GET https://api.fcoin.com/v2/public/symbols` 121 | -------------------------------------------------------------------------------- /source/includes/zh/_accounts.md: -------------------------------------------------------------------------------- 1 | # 币币账户接口 2 | 3 | 4 | ## 查询交易账户的资产列表。 5 | 6 | 此api用于查询交易账户的资产 7 | ### HTTP Request 8 | 9 | `GET https://api.fcoin.com/v2/accounts/balance` 10 | 11 | ``` 12 | ``` 13 | 14 | 15 | 16 | ## 查询我的钱包的资产列表。 17 | 此api用于查询我的钱包的资产 18 | 19 | ### HTTP Request 20 | 21 | `GET https://api.fcoin.com/v2/assets/accounts/balance` 22 | 23 | ### 响应结果 24 | ``` 25 | { 26 | 'status': 0, 27 | 'data': [ 28 | { 29 | 'currency': 'btc', 币种名称 30 | 'available': '0.000000000000000000', 可用 31 | 'frozen': '0.000000000000000000', 冻结 32 | 'demand_deposit': '0.000000000000000000', 理财资产 33 | 'lock_deposit': '0.000000000000000000', 锁仓资产 34 | 'balance': '0.000000000000000000' 总资产 35 | }, 36 | { 37 | 'currency': 'eth', 38 | 'available': '0.000000000000000000', 39 | 'frozen': '0.000000000000000000', 40 | 'demand_deposit': '0.000000000000000000', 41 | 'lock_deposit': '0.000000000000000000', 42 | 'balance': '0.000000000000000000' 43 | }, 44 | ... 45 | } 46 | ``` 47 | 48 | 49 | 50 | ## 从我的钱包划转到交易账户 51 | 此接口用于从我的钱包将资产划转到交易账户 52 | 53 | ### HTTP Request 54 | `POST https://api.fcoin.com/v2/assets/accounts/assets-to-spot` 55 | 56 | ### 请求参数 57 | |参数|默认值|描述| 58 | |:------|:------:|:------| 59 | currency| |币种名称 60 | amount| |数量 61 | ### 请求示例: 62 | ``` 63 | { 64 | "currency": "btc", 65 | "amount": 1 66 | } 67 | ``` 68 | ``` 69 | ``` 70 | ### 响应结果 71 | ``` 72 | { 73 | "data": null, 74 | "status": "ok" 75 | } 76 | ``` 77 | 78 | ## 从交易账户划转到我的钱包 79 | 此接口用于从交易账户将资产划转到我的钱包 80 | 81 | ### HTTP Request 82 | `POST https://api.fcoin.com/v2/accounts/spot-to-assets` 83 | 84 | ### 请求参数 85 | |参数|默认值|描述| 86 | |:------|:------:|:------| 87 | currency| |币种名称 88 | amount| |数量 89 | ### 请求示例: 90 | ``` 91 | { 92 | "currency": "btc", 93 | "amount": 1 94 | } 95 | ``` 96 | ### 响应结果 97 | ``` 98 | { 99 | "data": null, 100 | "status": "ok" 101 | } 102 | ``` 103 | 104 | 105 | ## 碎币兑换 106 | 107 | - 兑换记录状态说明: 108 | 109 | 110 | | 属性 | 含义| 111 | |:------|:------:| 112 | |WAITING_TRANSFER_TO_SYSTEM|待划转到系统账户 113 | |WAITING_REFUND|待退款给用户 114 | |FAIL|兑换失败 115 | |WAITING_TRANSFER_TO_USER|待打款给用户 116 | |SUCCESS|兑换成功 117 | 118 | ## 用户兑换碎币 119 | 120 | `POST https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 121 | 122 | ### 请求参数 123 | | 属性 | 含义 | 124 | |:------|:------| 125 | |exchange_currency | 要兑换成的币种,ft 126 | |small_currency_amounts | json格式: [{"currency":"usdt","amount":"0.4"},{"currency":"btc","amount":"0.0002"}],其中currency: 待兑换的币种,amount: 要兑换的数量(必须大于0,最大支持18位精度) 127 | 128 | ### 响应结果 129 | ``` 130 | { 131 | "status": "ok", 132 | "data": null 133 | } 134 | ``` 135 | 136 | ## 查询可兑换的币种 137 | 138 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange/exchangeable_small_currencies/{exchange_currency}` 139 | 140 | ### 请求参数 141 | 142 | exchange_currency: 要兑换成的币种 143 | 144 | ### 响应结果 145 | 146 | ``` 147 | { 148 | "exchange_currency": "ft", 要兑换成的币种 149 | "total_exchange_amount": "0", 已经兑换所得总量 150 | "exchangeable_small_currencies": [ 151 | { 152 | "currency": "dash", 待兑换的币种 153 | "available_amount": "0.00063517", 币种可用余额 154 | "valuation": "0.06805309", 可用余额估值(usdt) 155 | "exchange_amount": "1.71670037", 兑换可得数量(未扣除手续费) 156 | "exchangeable": true 是否可兑换(如果为false,兑换时将忽略不计) 157 | }, 158 | { 159 | "currency": "usdt", 160 | "available_amount": "0.3", 161 | "valuation": "0.3", 162 | "exchange_amount": "15", 163 | "exchangeable": true 164 | } 165 | ] 166 | } 167 | 168 | ``` 169 | 170 | ## 查询兑换记录 171 | 172 | `GET https://api.fcoin.com/v2/broker/auth/small_currency_exchange` 173 | 174 | ### 请求参数 175 | 176 | | 属性| 类型 | 含义 | 177 | |:------|:------:|:------| 178 | |has_prev |Boolean| 是否包含前一页,该参数由前端控制,原样返回 179 | |id |String|最后一次分页的ID,非必传 180 | |page_size |Integer| 请求数量(1-40),默认为40 181 | 182 | 183 | #### 响应结果 184 | 185 | ``` 186 | 187 | { 188 | "content": [ 189 | { 190 | "id": "jS6XfuzBhXXhDBtt_dNDqw", 记录id 191 | "exchange_currency": "ft", 兑换成的币种 192 | "fees": "0.056006006006006007", 手续费 193 | "exchange_amount": "28.003003003003003003", 兑换应得数量 194 | "actual_exchange_amount": "27.946996996996996996", 兑换实际所得数量=兑换应得数量-手续费 195 | "state": "waiting_transfer_to_user", 兑换状态 196 | "created_at": 1577949932988 兑换时间 197 | } 198 | ], 199 | "current_elements": 1, 200 | "has_prev": false, 201 | "has_next": false, 202 | "next_page_id": "jS6XfuzBhXXhDBtt_dNDqw" 203 | } 204 | 205 | ``` 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /source/includes/zh/_authentication.md: -------------------------------------------------------------------------------- 1 | # 认证 2 | > 请注意以下为伪代码, 3 | > 执行下面的代码进行用户验证: 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | ``` 10 | 11 | ```javascript 12 | const fcoin = require('fcoin'); 13 | 14 | let api = fcoin.authorize('key', 'secret', timestamp); 15 | ``` 16 | 17 | FCoin 使用 API key 和 API secret 进行验证,请访问 [设置中心](https://exchange.fcoin.com/settings/api),并注册成为开发者,获取 API key 和 API secret。 18 | 19 | FCoin 的 API 请求,除公开的 API 外都需要携带 API key 以及签名 20 | 21 | 22 | 23 | 24 | ## 访问限制 25 | 26 | 目前访问频率为每个用户 100次 / 10秒,未来会按照业务区分访问频率限制。 27 | 28 | 29 | 30 | 31 | ## API 签名 32 | 33 | 签名前准备的数据如下: 34 | 35 | `HTTP_METHOD` + `HTTP_REQUEST_URI` + `TIMESTAMP` + `POST_BODY` 36 | 37 | 连接完成后,进行 `Base64` 编码,对编码后的数据进行 `HMAC-SHA1` 签名,并对签名进行二次 `Base64` 编码,各部分解释如下: 38 | 39 | 42 | 43 | ### HTTP_METHOD 44 | 45 | `GET`, `POST`, `DELETE`, `PUT` 需要大写 46 | 47 | ### HTTP_REQUEST_URI 48 | 49 | `https://api.fcoin.com/v2/` 为 v2 API 的请求前缀 50 | 51 | 后面再加上真正要访问的资源路径,如 `orders?param1=value1`,最终即 `https://api.fcoin.com/v2/orders?param1=value1` 52 | 53 | 对于请求的 URI 中的参数,需要按照按照字母表排序! 54 | 55 | 即如果请求的 URI 为 `https://api.fcoin.com/v2/orders?c=value1&b=value2&a=value3`,则进行签名时,应先将请求参数按照字母表排序,最终进行签名的 URI 为 `https://api.fcoin.com/v2/orders?a=value3&b=value2&c=value1`, 56 | 请注意,原请求 URI 中的三个参数顺序为 `c, b, a`,排序后为 `a, b, c`。 57 | 58 | ### TIMESTAMP 59 | 60 | 访问 API 时的 UNIX EPOCH 时间戳,需要和服务器之间的时间差少于 30 秒 61 | 62 | ### POST_BODY 63 | 64 | 如果是 `POST` 请求,`POST` 请求数据也需要被签名,签名规则如下: 65 | 66 | 所有请求的 key 按照字母顺序排序,然后进行 url 参数化,并使用 `&` 连接。 67 | 68 | 71 | 72 | > 如果请求数据为: 73 | 74 | ```json 75 | { 76 | "username": "username", 77 | "password": "passowrd" 78 | } 79 | ``` 80 | 81 | > 则先将 key 按照字母排序,然后进行 url 参数化,即: 82 | 83 | ``` 84 | password=password 85 | username=username 86 | ``` 87 | 88 | > 因为 `p` 在字母表中的排序在 `u` 之前,所以 `password` 要放在 `username` 之前,然后使用 `&` 进行连接,即: 89 | 90 | ``` 91 | password=password&username=username 92 | ``` 93 | 94 | ## 完整示例 95 | 96 | > 对于如下的请求: 97 | 98 | ``` 99 | POST https://api.fcoin.com/v2/orders 100 | 101 | { 102 | "type": "limit", 103 | "side": "buy", 104 | "amount": "100.0", 105 | "price": "100.0", 106 | "symbol": "btcusdt" 107 | } 108 | 109 | timestamp: 1523069544359 110 | ``` 111 | 112 | > 签名前的准备数据如下: 113 | 114 | ``` 115 | POSThttps://api.fcoin.com/v2/orders1523069544359amount=100.0&price=100.0&side=buy&symbol=btcusdt&type=limit 116 | ``` 117 | 118 | > 进行 Base64 编码,得到: 119 | 120 | ``` 121 | UE9TVGh0dHBzOi8vYXBpLmZjb2luLmNvbS92Mi9vcmRlcnMxNTIzMDY5NTQ0MzU5YW1vdW50PTEwMC4wJnByaWNlPTEwMC4wJnNpZGU9YnV5JnN5bWJvbD1idGN1c2R0JnR5cGU9bGltaXQ= 122 | ``` 123 | 124 | > 拷贝在申请 API Key 时获得的秘钥(API SECRET),下面的签名结果采用 `3600d0a74aa3410fb3b1996cca2419c8` 作为示例, 125 | 126 | > 对得到的结果使用秘钥进行 `HMAC-SHA1` 签名,并对二进制结果进行 `Base64` 编码,得到: 127 | 128 | ``` 129 | DeP6oftldIrys06uq3B7Lkh3a0U= 130 | ``` 131 | 132 | > 即生成了用于向 API 服务器进行验证的最终签名 133 | 134 | ## header中的参数名称 135 | 136 | * `FC-ACCESS-KEY` 137 | * `FC-ACCESS-SIGNATURE` 138 | * `FC-ACCESS-TIMESTAMP` 139 | 140 | ## 说明 141 | 142 | 可以使用[开发者工具]()(暂未开放)进行在线联调测试。 143 | -------------------------------------------------------------------------------- /source/includes/zh/_errors.md: -------------------------------------------------------------------------------- 1 | # 错误代码 2 | 3 | 错误代码 | 含义解释 4 | ---------- | ------- 5 | 400 | Bad Request -- 错误的请求 6 | 401 | Unauthorized -- API key 或者签名,时间戳有误 7 | 403 | Forbidden -- 禁止访问 8 | 404 | Not Found -- 未找到请求的资源 9 | 405 | Method Not Allowed -- 使用的 HTTP 方法不适用于请求的资源 10 | 406 | Not Acceptable -- 请求的内容格式不是 JSON 11 | 429 | Too Many Requests -- 请求受限,请降低请求频率 12 | 500 | Internal Server Error -- 服务内部错误,请稍后再进行尝试 13 | 503 | Service Unavailable -- 服务不可用,请稍后再进行尝试 14 | -------------------------------------------------------------------------------- /source/includes/zh/_introduction.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 通过了解以下信息,您可以方便的使用 FCoin 提供的 API 来接入 FCoin 交易平台。 4 | -------------------------------------------------------------------------------- /source/includes/zh/_leveraged.md: -------------------------------------------------------------------------------- 1 | # 杠杆账户接口 2 | ## 杠杆账户资产转入 3 | 此API用于将交易账户或资产账户的资产转入到杠杆账户。 4 | 5 | ### HTTP Request 6 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/in` 7 | 8 | ### 请求参数 9 | |参数|默认值|描述| 10 | |:------|:------:|:------| 11 | |amount|无|划转数量| 12 | |currency|无|币种名称:usdt、btc、eth| 13 | |source_account_type|无|资产来源账户类型: exchange: 交易账户; assets: 资产账户| 14 | |target_account_type|无|目标账户类型: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 15 | ### 请求示例: 16 | ``` 17 | { 18 | "amount": 1, 19 | "currency": "btc", 20 | "source_account_type": "exchange", 21 | "target_account_type": "leveraged_btcusdt" 22 | } 23 | ``` 24 | 25 | ### 响应结果 26 | ``` 27 | { 28 | "data": null, 29 | "status": "ok" 30 | } 31 | ``` 32 | 33 | ## 杠杆账户资产转出 34 | 此API用于将杠杆账户资产转入到交易账户或资产账户。 35 | 36 | ### HTTP Request 37 | `POST https://api.fcoin.com/v2/broker/leveraged/assets/transfer/out` 38 | 39 | ### 请求参数 40 | |参数|默认值|描述| 41 | |:------|:------:|:------| 42 | |amount|无|划转数量| 43 | |currency|无|币种名称:usdt、btc、eth、eos、xrp| 44 | |source_account_type|无|资产来源账户类型: leveraged_btcusdt、leveraged_ethusdt、leveraged_eosusdt、leveraged_xrpusdt| 45 | |target_account_type|无|目标账户类型: exchange: 交易账户; assets: 资产账户| 46 | ### 请求示例: 47 | ``` 48 | { 49 | "amount": 1, 50 | "currency": "btc", 51 | "source_account_type": "leveraged_btcusdt", 52 | "target_account_type": "exchange" 53 | } 54 | ``` 55 | 56 | ### 响应结果 57 | ``` 58 | { 59 | "data": null, 60 | "status": "ok" 61 | } 62 | ``` 63 | 64 | ## 查询指定杠杆账户的信息 65 | 66 | ### 请求url 67 | 68 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts/account` 69 | 70 | ### 请求参数 71 | |参数|默认值|描述| 72 | |:------|:------:|:------| 73 | |account_type|无|杠杆账户类型:btcusdt/ethusdt 74 | 75 | ### 响应结果 76 | 77 | ``` 78 | { 79 | "status": "ok", 80 | "data": { 81 | "open": true, #是否已经开通该类型杠杆账户. true:已开通;false:未开通 82 | "leveraged_account_type": "btcusdt", #杠杆账户类型 83 | "base": "btc", #基准币种 84 | "quote": "usdt", #计价币种 85 | "available_base_currency_amount": "1001.00", #可用的基准币种资产 86 | "frozen_base_currency_amount": "0", #冻结的基准币种资产 87 | "available_quote_currency_amount": "100100", #可用的计价币种资产 88 | "frozen_quote_currency_amount": "0", #冻结的计价币种资产 89 | "available_base_currency_loan_amount": "2.000", #可借的基准币种数量 90 | "available_quote_currency_loan_amount": "300.000",#可借的计价币种数量 91 | "blow_up_price": null, #爆仓价 92 | "risk_rate": "0.90", #爆仓风险率 93 | "state": "open", #账户状态. close 已关闭;open 已开通-未发生借贷;normal 已借贷-风险率正常;blow_up 已爆仓;overrun 已穿仓", allowableValues = "close,open,normal,blow_up,overrun") 94 | "base_currency_unpaid_amount":"1", #基准币种累计待还款数量(包含利息) 95 | "quote_currency_unpaid_amount":"2" #计价币种累计待还款数量(包含利息) 96 | } 97 | } 98 | ``` 99 | 100 | 101 | ## 查询所有杠杆账户的信息 102 | 103 | ### 请求url 104 | `GET https://api.fcoin.com/v2/broker/leveraged_accounts` 105 | 106 | ### 请求参数 107 | 无 108 | ### 响应结果 109 | ``` 110 | { 111 | "status": "ok", 112 | "data": [ 113 | { 114 | "open": true, #是否已经开通该类型杠杆账户. true:已开通;false:未开通 115 | "leveraged_account_type": "btcusdt", #杠杆账户类型 116 | "base": "btc", #基准币种 117 | "quote": "usdt", #计价币种 118 | "available_base_currency_amount": "1001.00", #可用的基准币种资产 119 | "frozen_base_currency_amount": "0", #冻结的基准币种资产 120 | "available_quote_currency_amount": "100100", #可用的计价币种资产 121 | "frozen_quote_currency_amount": "0", #冻结的计价币种资产 122 | "available_base_currency_loan_amount": "2.000", #可借的基准币种数量 123 | "available_quote_currency_loan_amount": "300.000",#可借的计价币种数量 124 | "blow_up_price": null, #爆仓价 125 | "risk_rate": "0.90", #爆仓风险率 126 | "state": "open", #账户状态. close 已关闭;open 已开通-未发生借贷;normal 已借贷-风险率正常;blow_up 已爆仓;overrun 已穿仓" 127 | "base_currency_unpaid_amount":"1", #基准币种累计待还款数量(包含利息) 128 | "quote_currency_unpaid_amount":"2" #计价币种累计待还款数量(包含利息) 129 | } 130 | ] 131 | } 132 | ``` 133 | 134 | ## 杠杆借贷和还款 135 | 136 | ## 下借款单 137 | 138 | `POST https://api.fcoin.com/v2/broker/leveraged/loans` 139 | 140 | ### 请求参数 141 | |参数|默认值|描述| 142 | |:------|:------:|:------| 143 | |account_type|无|杠杆账户类型:btcusdt/ethusdt 144 | |amount|无|借款数量 145 | |currency|无|借款币种名称 146 | |loan_type|无|借款类型. normal 正常借款(指定借款数量); all 全部(把剩余资产全部用来借款) 147 | 148 | ### 响应结果 149 | ``` 150 | { 151 | "amount": 0, 借款数量 152 | "created_at": 0, 账单生成时间 153 | "currency": "string", 借款币种名称 154 | "finished_at": 0, 还款完成时间 155 | "interest": 0, 总利息 156 | "interest_rate": 0, 借款利率 157 | "interest_start_at": 0, 计息开始时间 158 | "last_repayment_at": 0, 最后一次还款时间 159 | "loan_bill_id": 0, 借贷账单ID 160 | "next_interest_at": 0, 下一次计息时间 161 | "state": "string", 账单状态. submitted 已提交; 2 confirmed 已确认; 5 finished 还款完成 162 | "unpaid_amount": 0, 未还款数量 163 | "unpaid_interest": 0, 未还利息 164 | "unpaid_total_amount": 0 待还款总数量 (未还款数量+未还利息) 165 | } 166 | 167 | ``` 168 | 169 | 170 | ## 自定义查询杠杆借贷记录 171 | 172 | `GET https://api.fcoin.com/v2/broker/leveraged/loans` 173 | 174 | ### 请求参数 175 | |参数|默认值|描述| 176 | |:------|:------:|:------| 177 | |has_prev|无|是否包含前一页,该参数由前端控制,原样返回 178 | |id|无| 最后一次分页的ID 179 | |page_size|无| 请求数量,1-40 180 | |account_type|无| 借款账户类型 BTCUSDT ETHUSDT 181 | |skip_finish|false| 是否忽略已完成状态的借款单,默认不忽略 182 | 183 | ### 响应结果 184 | 185 | ``` 186 | { 187 | "content": [ 188 | { 189 | "amount": 0, 借款数量 190 | "created_at": 0, 账单生成时间 191 | "currency": "string", 借款币种名称 192 | "finished_at": 0, 还款完成时间 193 | "interest": 0, 总利息 194 | "interest_rate": 0, 借款利率 195 | "interest_start_at": 0, 计息开始时间 196 | "last_repayment_at": 0, 最后一次还款时间 197 | "loan_bill_id": 0, 借贷账单ID 198 | "next_interest_at": 0, 下一次计息时间 199 | "state": "string", 账单状态. submitted 已提交; 2 confirmed 已确认; 5 finished 还款完成 200 | "unpaid_amount": 0, 未还款数量 201 | "unpaid_interest": 0, 未还利息 202 | "unpaid_total_amount": 0 待还款总数量 (未还款数量+未还利息) 203 | } 204 | ], 205 | "current_elements": 0, 查询结果集数量 206 | "has_next": true, 是否包含下一页 207 | "has_prev": true, 是否包含前一页,该参数由前端控制,原样返回 208 | "next_page_id": "string" 下一页查询条件ID 209 | } 210 | ``` 211 | 212 | ## 查询指定杠杆借贷详情 213 | 214 | `GET https://api.fcoin.com/v2/broker/leveraged/loans/{leveraged_loan_id}` 215 | 216 | ### 请求参数 217 | |参数|默认值|描述| 218 | |:------|:------:|:------| 219 | |leveraged_loan_id|无|借贷账单ID 220 | ### 响应结果 221 | ``` 222 | 223 | { 224 | "amount": 0, 借款数量 225 | "created_at": 0, 账单生成时间 226 | "currency": "string", 借款币种名称 227 | "finished_at": 0, 还款完成时间 228 | "interest": 0, 总利息 229 | "interest_rate": 0, 借款利率 230 | "interest_start_at": 0, 计息开始时间 231 | "last_repayment_at": 0, 最后一次还款时间 232 | "loan_bill_id": 0, 借贷账单ID 233 | "next_interest_at": 0, 下一次计息时间 234 | "state": "string", 账单状态. submitted 已提交; 2 confirmed 已确认; 5 finished 还款完成 235 | "unpaid_amount": 0, 未还款数量 236 | "unpaid_interest": 0, 未还利息 237 | "unpaid_total_amount": 0 待还款总数量 (未还款数量+未还利息) 238 | } 239 | ``` 240 | 241 | 242 | ## 杠杆借款单还款 243 | `POST https://api.fcoin.com/v2/broker/leveraged/repayments/{loan_bill_id}` 244 | ### 请求参数 245 | |参数|默认值|描述| 246 | |:------|:------:|:------| 247 | |loan_bill_id|无|借款单编号 248 | ``` 249 | body 250 | { 251 | "amount": 0 还款数量 252 | } 253 | ``` 254 | ### 响应结果 255 | 还款单ID -------------------------------------------------------------------------------- /source/includes/zh/_markets.md: -------------------------------------------------------------------------------- 1 | # 行情接口 2 | 3 | ## 行情概述 4 | 5 | 行情是一个全公开的 API, 当前同时提供了 HTTP 和 WebSocket 的 API. 6 | 为确保可以更及时的获得行情, 推荐使用 WebSocket 进行接入. 7 | 为尽可能行情的实时性能, 当前公开部分只能获取最近一段时间的行情 8 | 9 | 所有 HTTP 请求的 URL base 为: `https://api.fcoin.com/v2/market` 10 | 11 | 所有 WebSocket 请求的 URL 为: `wss://api.fcoin.com/v2/ws` 12 | 13 | 下文会统一术语: 14 | 15 | - `topic` 表示订阅的主题 16 | - `symbol` 表示对应交易币种. 所有币种区分的 topic 都在 topic 末尾. 17 | - `ticker` 行情 tick 信息, 包含最新成交价, 最新成交量, 买一卖一, 近 24 小时成交量. 18 | - `depth` 表示行情深度, 买卖盘, 盘口. 19 | - `level` 表示行情深度类型. 如 `L20`, `L100`. 20 | - `trade` 表示最新成交, 最新交易. 21 | - `candle` 表示蜡烛图, 蜡烛棒, K 线. 22 | - `resolution` 表示蜡烛图的种类. 如 `M1`, `M15`. 23 | - `base volume` 表示基准货币成交量, 如 btcusdt 中 btc 的量. 24 | - `quote volume` 表示计价货币成交量, 如 btcusdt 中 usdt 的量 25 | - `ts` 表示推送服务器的时间. 是毫秒为单位的数字型字段, unix epoch in millisecond. 26 | 27 | ## WebSocket 首次建立连接 28 | 29 | 连接成功服务器会发送一个欢迎信息 30 | 31 | > 连接成功后服务器返回信息: 32 | 33 | ```json 34 | { 35 | "type":"hello", 36 | "ts":1523693784042 37 | } 38 | ``` 39 | 40 | > * `ts`: 推送服务器当前的时间. 41 | 42 | ## WebSocket 连接保持 - heartbeat 43 | 44 | ```python 45 | # WebSocket 向服务端发送 ping 维持心跳 46 | import time 47 | import fcoin 48 | 49 | api = fcoin.authorize('key', 'secret', timestamp) 50 | now_ms = int(time.time()) 51 | api.market.ping(now_ms) 52 | ``` 53 | 54 | 55 | WebSocket 客户端和 WebSocket 服务器建立连接之后,推荐 WebSocket Client 每隔 *30s*(这个频率可能会变化) 向服务器发起一次 ping 请求,如果服务器长时间没有接收到客户端的 ping 请求将会主动断开连接(300s)。 56 | 57 | ### WebSocket 请求 58 | 59 | 发送 **ping 指令**: `{"cmd":"ping","args":[$client_ts],"id":"$client_id"}` 60 | 61 | * `client_id`: 客户端为当前请求指定的自定义 id,服务器端会原样返回 62 | * `client_ts`: 客户端当前的时间 63 | 64 | > ping 指令请求示例: 65 | 66 | ```json 67 | {"cmd":"ping","args":[1540557696867],"id":"sample.client.id"} 68 | ``` 69 | 70 | > ping 指令成功服务器返回: 71 | 72 | ```json 73 | { 74 | "id":"sample.client.id", 75 | "type":"ping", 76 | "ts":1523693784042, 77 | "gap":112 78 | } 79 | ``` 80 | 81 | > * `gap`: 推送服务器处理此语句的时间和客户端传输的时间差. 82 | > * `ts`: 推送服务器当前的时间. 83 | 84 | 87 | 88 | ## WebSocket 订阅 89 | 90 | 发送 **sub 指令**: `{"cmd":"sub","args":["$topic", ...],"id":"$client_id"}` 91 | 92 | * `client_id`: 客户端为当前请求指定的自定义 id,服务器端会原样返回 93 | * `topic`: 待订阅的 topic,多个请用英文逗号`,`分隔,最多可以订阅20个 94 | 95 | > sub 指令请求示例(单 topic): 96 | 97 | ```json 98 | {"cmd":"sub","args":["ticker.ethbtc"]} 99 | ``` 100 | 101 | > sub 指令请求示例(多 topic): 102 | 103 | ```json 104 | {"cmd":"sub","args":["ticker.ethbtc", "ticker.btcusdt"]} 105 | ``` 106 | 107 | > 订阅成功的响应结果如下: 108 | 109 | ```json 110 | { 111 | "type": "topics", 112 | "topics": ["ticker.ethbtc", "ticker.btcusdt"] 113 | } 114 | ``` 115 | 116 | > 订阅失败的响应结果如下: 117 | 118 | ```json 119 | { 120 | "id":"invalid_topics_sample", 121 | "status":41002, 122 | "msg":"invalid sub topic, xxx.M1.xxx" 123 | } 124 | ``` 125 | 126 | ## 获取 ticker 数据 127 | 128 | 为了使得 ticker 信息组足够小和快, 我们强制使用了列表格式. 129 | 130 | > ticker 列表对应字段含义说明: 131 | 132 | ```json 133 | [ 134 | "最新成交价", 135 | "最近一笔成交的成交量", 136 | "最大买一价", 137 | "最大买一量", 138 | "最小卖一价", 139 | "最小卖一量", 140 | "24小时前成交价", 141 | "24小时内最高价", 142 | "24小时内最低价", 143 | "24小时内基准货币成交量, 如 btcusdt 中 btc 的量", 144 | "24小时内计价货币成交量, 如 btcusdt 中 usdt 的量" 145 | ] 146 | ``` 147 | 148 | 149 | ### HTTP 请求 150 | 151 | `GET https://api.fcoin.com/v2/market/ticker/$symbol` 152 | 153 | ```python 154 | # 获取 ticker 数据 155 | import fcoin 156 | 157 | api = fcoin.authorize('key', 'secret', timestamp) 158 | api.market.get_ticker("ethbtc") 159 | ``` 160 | 161 | > HTTP 请求响应结果如下: 162 | 163 | ```json 164 | { 165 | "status": 0, 166 | "data": { 167 | "type": "ticker.btcusdt", 168 | "seq": 680035, 169 | "ticker": [ 170 | 7140.890000000000000000, 171 | 1.000000000000000000, 172 | 7131.330000000, 173 | 233.524600000, 174 | 7140.890000000, 175 | 225.495049866, 176 | 7140.890000000, 177 | 7140.890000000, 178 | 7140.890000000, 179 | 1.000000000, 180 | 7140.890000000000000000 181 | ] 182 | } 183 | } 184 | ``` 185 | 186 | ### WebSocket 订阅 187 | 188 | 发送 **sub 指令**,topic: `ticker.$symbol` (请参考 `WebSocket 订阅`) 189 | 190 | ```python 191 | # 订阅 ticker 数据 192 | import fcoin 193 | 194 | fcoin_ws = fcoin.init_ws() 195 | topics = ["ticker.ethbtc", "ticker.btcusdt"] 196 | fcoin_ws.handle(print) 197 | fcoin_ws.sub(topics) 198 | ``` 199 | 200 | > WebSocket 订阅的通知消息结果如下: 201 | 202 | ```json 203 | { 204 | "type": "ticker.btcusdt", 205 | "seq": 680035, 206 | "ticker": [ 207 | 7140.890000000000000000, 208 | 1.000000000000000000, 209 | 7131.330000000, 210 | 233.524600000, 211 | 7140.890000000, 212 | 225.495049866, 213 | 7140.890000000, 214 | 7140.890000000, 215 | 7140.890000000, 216 | 1.000000000, 217 | 7140.890000000000000000 218 | ] 219 | } 220 | ``` 221 | 222 | 223 | 224 | ## 获取最新的深度明细 225 | 226 | ### HTTP 请求 227 | 228 | `GET https://api.fcoin.com/v2/market/depth/$level/$symbol` 229 | 230 | `$level` 包含的种类(大小写敏感): 231 | 232 | 类型 | 说明 233 | -------- | -------- 234 | `L20` | 20 档行情深度. 235 | `L150` | 150 档行情深度. 236 | 237 | 其中 `L20` 的推送时间会略早于 `L150`, 推送频次会略多于 `L150`, 看具体的压力和情况. 此处请按需使用. 238 | 239 | > HTTP 请求响应结果如下: 240 | 241 | ```json 242 | { 243 | "status":0, 244 | "data":{ 245 | "type": "depth.L20.ethbtc", 246 | "ts": 1523619211000, 247 | "seq": 120, 248 | "bids": [0.000100000, 1.000000000, 0.000010000, 1.000000000], 249 | "asks": [1.000000000, 1.000000000] 250 | } 251 | } 252 | ``` 253 | 254 | ### WebSocket 订阅 255 | 256 | ```python 257 | # WebSocket 订阅深度明细 258 | import fcoin 259 | 260 | fcoin_ws = fcoin.init_ws() 261 | topics = ["depth.L20.ethbtc", "depth.L150.btcusdt"] 262 | fcoin_ws.handle(print) 263 | fcoin_ws.sub(topics) 264 | ``` 265 | 266 | ```javascript 267 | // WebSocket 订阅深度明细 268 | const fcoin = require('fcoin'); 269 | 270 | let fcoin_ws = fcoin.init_ws() 271 | topics = ["depth.L20.ethbtc", "depth.L150.btcusdt"] 272 | fcoin_ws.handle(print) 273 | fcoin_ws.sub(topics) 274 | ``` 275 | 276 | 发送 **sub 指令**,topic: `depth.$level.$symbol` (请参考 `WebSocket 订阅`) 277 | 278 | > WebSocket 订阅的通知消息结果如下: 279 | 280 | ```json 281 | { 282 | "type": "depth.L20.ethbtc", 283 | "ts": 1523619211000, 284 | "seq": 120, 285 | "bids": [0.000100000, 1.000000000, 0.000010000, 1.000000000], 286 | "asks": [1.000000000, 1.000000000] 287 | } 288 | ``` 289 | 290 | > bids 和 asks 对应的数组一定是偶数条目, 买(卖)1价, 买(卖)1量, 依次往后排列. 291 | 292 | 293 | 294 | ## 获取最新的成交明细 295 | 296 | 通过对比其中的成交 id 大小才能决定是否是更新的成交.{trade id} 297 | 需要注意, 常规由于 trade 到 transaction 过程的存在, 公开行情的成交 id 并不实际对应清算系统中的成交 id. 298 | 即使成交是一条记录, 也无法保证最新成交在重新获取时候 id 永远保持一致. 299 | 300 | PS: 历史行情中, 是可以保证成交 id 保持恒定. {transaction id} 此处只作为行情更新通知, 不应依赖归档使用. 301 | 302 | 303 | ```python 304 | # WebSocket 请求获取最近的成交明细 305 | import fcoin 306 | 307 | fcoin_ws = fcoin.init_ws() 308 | topic = "trade.ethbtc" 309 | limit = 3 310 | args = [topic, limit] 311 | fcoin_ws.req(args, rep_handler) 312 | ``` 313 | 314 | ```python 315 | # WebSocket 订阅最近的成交明细 316 | import fcoin 317 | 318 | fcoin_ws = fcoin.init_ws() 319 | topics = ["trade.ethbtc", "trade.btcusdt"] 320 | fcoin_ws.handle(print) 321 | fcoin_ws.sub(topics) 322 | ``` 323 | 324 | 325 | ### HTTP 请求 326 | 327 | `GET https://api.fcoin.com/v2/market/trades/$symbol` 328 | 329 | #### 查询参数(HTTP 请求) 330 | 331 | 参数 | 默认值 | 描述 332 | --------- | ------- | ----------- 333 | before | | 查询某个 id 之前的 Trade 334 | limit | | 默认为 20 条 335 | 336 | ### WebSocket 请求 337 | 338 | 发送 **req 指令**: `{"cmd":"req", "args":["$topic", limit],"id":"$client_id"}` 339 | 340 | * `client_id`: 客户端为当前请求指定的自定义 id,服务器端会原样返回 341 | * `topic`: `trade.$symbol` 342 | * `limit`: 需要获取的最近的成交条数 343 | 344 | > WebSocket 请求成功的响应结果如下: 345 | 346 | ```json 347 | { 348 | "id":null, 349 | "ts":1523693400329, 350 | "data":[ 351 | { 352 | "amount":1.000000000, 353 | "ts":1523419946174, 354 | "id":76000, 355 | "side":"sell", 356 | "price":4.000000000 357 | }, 358 | { 359 | "amount":1.000000000, 360 | "ts":1523419114272, 361 | "id":74000, 362 | "side":"sell", 363 | "price":4.000000000 364 | }, 365 | { 366 | "amount":1.000000000, 367 | "ts":1523415182356, 368 | "id":71000, 369 | "side":"sell", 370 | "price":3.000000000 371 | } 372 | ] 373 | } 374 | ``` 375 | 376 | ### WebSocket 订阅 377 | 378 | 发送 **sub 指令**,topic: `trade.$symbol` (请参考 `WebSocket 订阅`) 379 | 380 | * `symbol`: 对应的交易对 381 | 382 | > WebSocket 订阅的通知消息结果如下: 383 | 384 | ```json 385 | { 386 | "type":"trade.ethbtc", 387 | "id":76000, 388 | "amount":1.000000000, 389 | "ts":1523419946174, 390 | "side":"sell", 391 | "price":4.000000000 392 | } 393 | ``` 394 | 395 | ## 获取 Candle 信息 396 | 397 | ### HTTP 请求 398 | 399 | `GET https://api.fcoin.com/v2/market/candles/$resolution/$symbol` 400 | 401 | #### 查询参数(HTTP 请求) 402 | 403 | 参数 | 默认值 | 描述 404 | --------- | ------- | ----------- 405 | before | | 查询某个 id 之前的 Candle 406 | limit | | 默认为 20 条 407 | 408 | $resolution 包含的种类(大小写敏感): 409 | 410 | 类型 | 说明 411 | -------- | -------- 412 | `M1` | 1 分钟 413 | `M3` | 3 分钟 414 | `M5` | 5 分钟 415 | `M15` | 15 分钟 416 | `M30` | 30 分钟 417 | `H1` | 1 小时 418 | `H4` | 4 小时 419 | `H6` | 6 小时 420 | `D1` | 1 日 421 | `W1` | 1 周 422 | `MN` | 1 月 423 | 424 | ### WebSocket 请求 425 | 426 | 发送 **req 指令**: `{"cmd":"req","args":["$topic",limit,before],"id":"$client_id"}` 427 | 428 | - `client_id`: 客户端为当前请求指定的自定义 id,服务器端会原样返回 429 | - `topic`: `candle.$resolution.$symbol` 430 | - `limit`: 需要获取的 candle 条数 431 | - `before`: 查询某个 id 之前的 Candle 432 | 433 | > WebSocket 请求成功的响应结果如下: 434 | 435 | ```json 436 | { 437 | "id":"candle.M1.btcusdt", 438 | "data":[ 439 | { 440 | "id":1540809840, 441 | "seq":24793830600000, 442 | "high":6491.74, 443 | "low":6489.24, 444 | "open":6491.24, 445 | "close":6490.07, 446 | "count":26, 447 | "base_vol":8.2221, 448 | "quote_vol":53371.531286 449 | }, 450 | { 451 | "id":1540809900, 452 | "seq":24793879800000, 453 | "high":6490.47, 454 | "low":6487.62, 455 | "open":6490.09, 456 | "close":6487.62, 457 | "count":23, 458 | "base_vol":10.8527, 459 | "quote_vol":70430.840624 460 | } 461 | ] 462 | } 463 | ``` 464 | 465 | ### Weboskcet 订阅 466 | 467 | 发送 **sub 指令**,topic: `candle.$resolution.$symbol` (请参考 `WebSocket 订阅`) 468 | 469 | * `resolution`: 同 HTTP 请求 resolution 参数 470 | 471 | ```python 472 | # WebSocket 订阅 candle 数据 473 | import fcoin 474 | 475 | fcoin_ws = fcoin.init_ws() 476 | topics = ["candle.M1.ethbtc"] 477 | fcoin_ws.handle(print) 478 | fcoin_ws.sub(topics) 479 | ``` 480 | 481 | > WebSocket 订阅的通知消息结果如下: 482 | 483 | ```json 484 | { 485 | "type":"candle.M1.ethbtc", 486 | "id":1523691480, 487 | "seq":11400000, 488 | "open":2.000000000, 489 | "close":2.000000000, 490 | "high":2.000000000, 491 | "low":2.000000000, 492 | "count":0, 493 | "base_vol":0, 494 | "quote_vol":0 495 | } 496 | ``` 497 | 498 | 499 | 500 | ## 获取所有的ticker数据 501 | 502 | ### HTTP 请求 503 | 504 | `GET https://api.fcoin.com/v2/market/all-tickers` 505 | 506 | #### 查询参数(HTTP 请求) 507 | 508 | 无 -------------------------------------------------------------------------------- /source/includes/zh/_order_errors.md: -------------------------------------------------------------------------------- 1 | ## 订单错误代码 2 | 3 | 错误代码 | 含义解释 4 | ---------- | ------- 5 | 2000 | 账户错误 6 | -------------------------------------------------------------------------------- /source/includes/zh/_orders.md: -------------------------------------------------------------------------------- 1 | # 现货和杠杆交易接口 2 | 3 | ## 订单模型说明 4 | 5 | 订单模型由以下属性构成: 6 | 7 | 属性 | 类型 | 含义解释 8 | ---------- | ------- | ------- 9 | `id` | `String` | 订单 ID 10 | `symbol` | `String` | 交易对 11 | `side` | `String` | 交易方向(`buy`, `sell`) 12 | `type` | `String` | 订单类型(`limit`,`market`,`ioc`,`fok`) 13 | `price` | `String` | 下单价格 14 | `amount` | `String` | 下单数量 15 | `state` | `String` | 订单状态 16 | `executed_value` | `String` | 已成交 17 | `filled_amount` | `String` | 成交量 18 | `fill_fees` | `String` | 手续费 19 | `created_at` | `Long` | 创建时间 20 | `source` | `String` | 来源 21 | 22 | 订单状态说明: 23 | 24 | 属性 | 含义解释 25 | ----------- | ------- 26 | `submitted` | 已提交 27 | `partial_filled` | 部分成交 28 | `partial_canceled` | 部分成交已撤销 29 | `filled` | 完全成交 30 | `canceled` | 已撤销 31 | `pending_cancel` | 撤销已提交 32 | 33 | ## 创建新的订单 34 | 35 | ```python 36 | import fcoin 37 | 38 | api = fcoin.authorize('key', 'secret', timestamp) 39 | order_create_param = fcoin.order_create_param('btcusdt', 'buy', 'limit', '8000.0', '1.0', 'main') 40 | api.orders.create(order_create_param) 41 | ``` 42 | 43 | ```javascript 44 | const fcoin = require('fcoin'); 45 | 46 | let api = fcoin.authorize('key', 'secret', timestamp); 47 | let orderCreateParam = fcoin.orderCreateParam('btcusdt', 'buy', 'limit', '8000.0', '1.0', 'main'); 48 | let orders = api.orders.create(orderCreateParam); 49 | ``` 50 | 51 | > 响应结果如下: 52 | 53 | ```json 54 | { 55 | "status": 0, 56 | "data": "9d17a03b852e48c0b3920c7412867623" 57 | } 58 | ``` 59 | 60 | 此 API 用于创建新的订单。 61 | 62 | ### HTTP Request 63 | 64 | `POST https://api.fcoin.com/v2/orders` 65 | 66 | ### 请求参数 67 | 68 | 参数 | 默认值 | 描述 69 | --------- | ------- | ----------- 70 | symbol | 无 | 交易对 71 | side | 无 | 交易方向 72 | type | 无 | 订单类型 73 | price | 无 | 价格 74 | amount | 无 | 下单量 75 | exchange | 无 | 交易区 76 | account_type | 无 | 账户类型(币币交易不需要填写,杠杆交易:margin) 77 | 78 | 79 | 80 | 81 | 82 | 83 | ## 查询订单列表 84 | 85 | ```python 86 | import fcoin 87 | 88 | api = fcoin.authorize('key', 'secret', timestamp) 89 | api.orders.get() 90 | ``` 91 | 92 | ```javascript 93 | const fcoin = require('fcoin'); 94 | 95 | let api = fcoin.authorize('key', 'secret', timestamp); 96 | let orders = api.orders.get(); 97 | ``` 98 | 99 | > 响应结果如下: 100 | 101 | ```json 102 | { 103 | "status": 0, 104 | "data": [ 105 | { 106 | "id": "string", 107 | "symbol": "string", 108 | "type": "limit", 109 | "side": "buy", 110 | "price": "string", 111 | "amount": "string", 112 | "state": "submitted", 113 | "executed_value": "string", 114 | "fill_fees": "string", 115 | "filled_amount": "string", 116 | "created_at": 0, 117 | "source": "web" 118 | } 119 | ] 120 | } 121 | ``` 122 | 123 | 此 API 用于查询订单列表。 124 | 125 | ### HTTP Request 126 | 127 | `GET https://api.fcoin.com/v2/orders` 128 | 129 | ### 查询参数 130 | 131 | 参数 | 默认值 | 描述 132 | --------- | ------- | ----------- 133 | symbol | | 交易对,必填 134 | states | | 订单状态,只支持单状态查询:submitted,partial_filled,partial_canceled,filled,canceled,必填 135 | before | | 查询某个时间戳之前的订单 136 | after | | 查询某个时间戳之后的订单 137 | limit | | 每页的订单数量,默认为 20 条,最大100 138 | account_type | | 杠杆:margin 139 | 140 | 141 | 142 | 143 | 144 | ## 获取指定订单 145 | 146 | ```python 147 | import fcoin 148 | 149 | api = fcoin.authorize('key', 'secret', timestamp) 150 | api.orders.get('9d17a03b852e48c0b3920c7412867623') 151 | ``` 152 | 153 | ```javascript 154 | const fcoin = require('fcoin'); 155 | 156 | let api = fcoin.authorize('key', 'secret', timestamp); 157 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623'); 158 | ``` 159 | 160 | > 响应结果如下: 161 | 162 | ```json 163 | { 164 | "status": 0, 165 | "data": { 166 | "id": "9d17a03b852e48c0b3920c7412867623", 167 | "symbol": "string", 168 | "type": "limit", 169 | "side": "buy", 170 | "price": "string", 171 | "amount": "string", 172 | "state": "submitted", 173 | "executed_value": "string", 174 | "fill_fees": "string", 175 | "filled_amount": "string", 176 | "created_at": 0, 177 | "source": "web" 178 | } 179 | } 180 | ``` 181 | 182 | 此 API 用于返回指定的订单详情。 183 | 184 | ### HTTP Request 185 | 186 | `GET https://api.fcoin.com/v2/orders/{order_id}` 187 | 188 | ### URL 参数 189 | 190 | 参数 | 描述 191 | --------- | ----------- 192 | order_id | 订单 ID 193 | 194 | 195 | 196 | 197 | 198 | 199 | ## 申请撤销订单 200 | 201 | ```python 202 | import fcoin 203 | 204 | api = fcoin.authorize('key', 'secret', timestamp) 205 | api.orders.submit_cancel(2) 206 | ``` 207 | 208 | ```javascript 209 | const fcoin = require('fcoin'); 210 | 211 | let api = fcoin.authorize('key', 'secret', timestamp); 212 | let max = api.orders.submitCancel(2); 213 | ``` 214 | 215 | > 响应结果如下: 216 | 217 | ```json 218 | { 219 | "status": 0, 220 | "msg": "string", 221 | "data": true 222 | } 223 | ``` 224 | 225 | 此 API 用于撤销指定订单,订单撤销过程是异步的,即此 API 的调用成功代表着订单已经进入撤销申请的过程,需要等待撮合的进一步处理,才能进行订单的撤销确认。 226 | 227 | ### HTTP Request 228 | 229 | `POST https://api.fcoin.com/v2/orders/{order_id}/submit-cancel` 230 | 231 | ### URL 参数 232 | 233 | 参数 | 解释 234 | --------- | ----------- 235 | order_id | 订单 ID 236 | 237 | 238 | 239 | 240 | 241 | 242 | ## 查询指定订单的成交记录 243 | 244 | ```python 245 | import fcoin 246 | 247 | api = fcoin.authorize('key', 'secret', timestamp) 248 | api.orders.get('9d17a03b852e48c0b3920c7412867623').match_results() 249 | ``` 250 | 251 | ```javascript 252 | const fcoin = require('fcoin'); 253 | 254 | let api = fcoin.authorize('key', 'secret', timestamp); 255 | let max = api.orders.get('9d17a03b852e48c0b3920c7412867623').matchResults(); 256 | ``` 257 | 258 | > 响应结果如下: 259 | 260 | ```json 261 | { 262 | "status": 0, 263 | "data": [ 264 | { 265 | "price": "string", 266 | "fill_fees": "string", 267 | "filled_amount": "string", 268 | "side": "buy", 269 | "type": "limit", 270 | "created_at": 0 271 | } 272 | ] 273 | } 274 | ``` 275 | 276 | 此 API 用于获取指定订单的成交记录 277 | 278 | ### HTTP Request 279 | 280 | `GET https://api.fcoin.com/v2/orders/{order_id}/match-results` 281 | 282 | ### URL 参数 283 | 284 | 参数 | 解释 285 | --------- | ----------- 286 | order_id | 订单 ID 287 | 288 | 289 | 290 | ## 创建计划委托订单 291 | 292 | `POST https://api.fcoin.com/v2/broker/entrust_orders/place_order` 293 | 294 | ### 请求参数 295 | 296 | | 参数 | 默认值 | 描述 | 297 | | :--- | --- | :--- | 298 | |`symbol`|无|交易对| 299 | |`account_type`|无|账户类型:交易账户 spot;杠杆账户:margin| 300 | |`exchange`|无|交易区(可以不传)| 301 | |`trigger_type`|无|触发类型:greater_or_equal >= 向上击穿触发价格;less_or_equal <= 向下击穿触发价格| 302 | |`trigger_price`|无|触发价格| 303 | |`delegation_price`|无|委托价格| 304 | |`amount`|无|委托数量| 305 | |`type`|无|订单类型:限价卖出 buy_limit;限价买入 sell_limit| 306 | 307 | ### response 308 | 309 | ``` 310 | {"status":"ok","data":"委托id"} 311 | ``` 312 | 313 | ## 撤销计划委托订单 314 | 315 | `POST https://api.fcoin.com/v2/broker/entrust_orders/{委托id}/{cancel}` 316 | 317 | ## 自定义查询计划委托订单 318 | 319 | `GET https://api.fcoin.com/v2/broker/entrust_orders` 320 | 321 | ### 请求参数 322 | 323 | |参数|默认值|描述| 324 | | --- | --- | --- | 325 | |`exchange`|无|交易区| 326 | |`symbol`|无|交易对| 327 | |`state`|无|状态:submitted 已提交;finished 已完成;canceled 已撤销;user_insufficient_balance 用户余额不足| 328 | |`type`|无|订单类型:限价卖出 buy_limit;限价买入 sell_limit| 329 | |`account_type`|无|账户类型:交易账户 spot;杠杆账户:margin| 330 | |`skip_canceled`|false|是否隐藏已撤销委托单(包含用户余额不足的委托单)| 331 | 332 | 查询杠杆账户,交易对必须传 333 | 334 | ### response 335 | 336 | ``` 337 | { 338 | "status": "ok", 339 | "data": { 340 | "content": [ 341 | { 342 | "id": "K87IRl38OdztQPmLMKoj6A", 343 | "order_id": null, 344 | "account_type": "spot", 345 | "symbol": "btcusdt", 346 | "base_currency": "btc", 347 | "quote_currency": "usdt", 348 | "trigger_type": "less_or_equal", 349 | "trigger_price": "3720.000000000000000000", 350 | "delegation_price": "3710.000000000000000000", 351 | "amount": "1.000000000000000000", 352 | "type": "buy_limit", 353 | "source": "web", 354 | "state": "submitted", 355 | "state_i18n": "未触发", 356 | "exchange": "main", 357 | "finished_at": 0, 358 | "canceled_at": 0, 359 | "created_at": 1575947617345 360 | } 361 | ], 362 | "current_elements": 1, 363 | "has_prev": false, 364 | "has_next": false, 365 | "next_page_id": "xVPrrdjH6MAcGB_OuJhKAg" 366 | } 367 | } 368 | ``` -------------------------------------------------------------------------------- /source/includes/zh/_publics.md: -------------------------------------------------------------------------------- 1 | # 公开接口 2 | 3 | ## 查询服务器时间 4 | 5 | ```python 6 | import fcoin 7 | 8 | api = fcoin.authorize('key', 'secret', timestamp) 9 | server_time = api.server_time() 10 | ``` 11 | 12 | ```javascript 13 | const fcoin = require('fcoin'); 14 | 15 | let api = fcoin.authorize('key', 'secret', timestamp); 16 | let serverTime = api.serverTime(); 17 | ``` 18 | 19 | > 响应结果如下: 20 | 21 | ```json 22 | { 23 | "status": 0, 24 | "data": 1523430502977 25 | } 26 | ``` 27 | 28 | 此 API 用于获取服务器时间。 29 | 30 | ### HTTP Request 31 | 32 | `GET https://api.fcoin.com/v2/public/server-time` 33 | 34 | 35 | 36 | 37 | 38 | ## 查询可用币种 39 | 40 | ```python 41 | import fcoin 42 | 43 | api = fcoin.authorize('key', 'secret', timestamp) 44 | currencies = api.currencies() 45 | ``` 46 | 47 | ```javascript 48 | const fcoin = require('fcoin'); 49 | 50 | let api = fcoin.authorize('key', 'secret', timestamp); 51 | let currencies = api.currencies(); 52 | ``` 53 | 54 | > 响应结果如下: 55 | 56 | ```json 57 | { 58 | "status": 0, 59 | "data": [ 60 | "btc", 61 | "eth" 62 | ] 63 | } 64 | ``` 65 | 66 | 此 API 用于获取可用币种。 67 | 68 | ### HTTP Request 69 | 70 | `GET https://api.fcoin.com/v2/public/currencies` 71 | 72 | 73 | 74 | 75 | 76 | ## 查询可用交易对 77 | 78 | ```python 79 | import fcoin 80 | 81 | api = fcoin.authorize('key', 'secret', timestamp) 82 | symbols = api.symbols() 83 | ``` 84 | 85 | ```javascript 86 | const fcoin = require('fcoin'); 87 | 88 | let api = fcoin.authorize('key', 'secret', timestamp); 89 | let symbols = api.symbols(); 90 | ``` 91 | 92 | > 响应结果如下: 93 | 94 | ```json 95 | { 96 | "status": 0, 97 | "data": [ 98 | { 99 | "name": "btcusdt", 100 | "base_currency": "btc", 101 | "quote_currency": "usdt", 102 | "price_decimal": 2, 103 | "amount_decimal": 4 104 | }, 105 | { 106 | "name": "ethusdt", 107 | "base_currency": "eth", 108 | "quote_currency": "usdt", 109 | "price_decimal": 2, 110 | "amount_decimal": 4 111 | } 112 | ] 113 | } 114 | ``` 115 | 116 | 此 API 用于获取可用交易对。 117 | 118 | ### HTTP Request 119 | 120 | `GET https://api.fcoin.com/v2/public/symbols` 121 | 122 | 或者,推荐使用下面接口 123 | `GET https://www.fcoin.com/openapi/v2/symbols` -------------------------------------------------------------------------------- /source/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | FCoin API Documentation 4 | 40 | 41 | 42 | 45 |
46 | 51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /source/javascripts/all.js: -------------------------------------------------------------------------------- 1 | //= require ./all_nosearch 2 | //= require ./app/_search 3 | -------------------------------------------------------------------------------- /source/javascripts/all_nosearch.js: -------------------------------------------------------------------------------- 1 | //= require ./lib/_energize 2 | //= require ./app/_toc 3 | //= require ./app/_lang 4 | 5 | $(function() { 6 | loadToc($('#toc'), '.toc-link', '.toc-list-h2', 10); 7 | setupLanguages($('body').data('languages')); 8 | $('.content').imagesLoaded( function() { 9 | window.recacheHeights(); 10 | window.refreshToc(); 11 | }); 12 | }); 13 | 14 | window.onpopstate = function() { 15 | activateLanguage(getLanguageFromQueryString()); 16 | }; 17 | -------------------------------------------------------------------------------- /source/javascripts/app/_lang.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_jquery 2 | 3 | /* 4 | Copyright 2008-2013 Concur Technologies, Inc. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); you may 7 | not use this file except in compliance with the License. You may obtain 8 | a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 15 | License for the specific language governing permissions and limitations 16 | under the License. 17 | */ 18 | ;(function () { 19 | 'use strict'; 20 | 21 | var languages = []; 22 | 23 | window.setupLanguages = setupLanguages; 24 | window.activateLanguage = activateLanguage; 25 | window.getLanguageFromQueryString = getLanguageFromQueryString; 26 | 27 | function activateLanguage(language) { 28 | if (!language) return; 29 | if (language === "") return; 30 | 31 | $(".lang-selector a").removeClass('active'); 32 | $(".lang-selector a[data-language-name='" + language + "']").addClass('active'); 33 | for (var i=0; i < languages.length; i++) { 34 | $(".highlight.tab-" + languages[i]).hide(); 35 | $(".lang-specific." + languages[i]).hide(); 36 | } 37 | $(".highlight.tab-" + language).show(); 38 | $(".lang-specific." + language).show(); 39 | 40 | window.recacheHeights(); 41 | 42 | // scroll to the new location of the position 43 | if ($(window.location.hash).get(0)) { 44 | $(window.location.hash).get(0).scrollIntoView(true); 45 | } 46 | } 47 | 48 | // parseURL and stringifyURL are from https://github.com/sindresorhus/query-string 49 | // MIT licensed 50 | // https://github.com/sindresorhus/query-string/blob/7bee64c16f2da1a326579e96977b9227bf6da9e6/license 51 | function parseURL(str) { 52 | if (typeof str !== 'string') { 53 | return {}; 54 | } 55 | 56 | str = str.trim().replace(/^(\?|#|&)/, ''); 57 | 58 | if (!str) { 59 | return {}; 60 | } 61 | 62 | return str.split('&').reduce(function (ret, param) { 63 | var parts = param.replace(/\+/g, ' ').split('='); 64 | var key = parts[0]; 65 | var val = parts[1]; 66 | 67 | key = decodeURIComponent(key); 68 | // missing `=` should be `null`: 69 | // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters 70 | val = val === undefined ? null : decodeURIComponent(val); 71 | 72 | if (!ret.hasOwnProperty(key)) { 73 | ret[key] = val; 74 | } else if (Array.isArray(ret[key])) { 75 | ret[key].push(val); 76 | } else { 77 | ret[key] = [ret[key], val]; 78 | } 79 | 80 | return ret; 81 | }, {}); 82 | }; 83 | 84 | function stringifyURL(obj) { 85 | return obj ? Object.keys(obj).sort().map(function (key) { 86 | var val = obj[key]; 87 | 88 | if (Array.isArray(val)) { 89 | return val.sort().map(function (val2) { 90 | return encodeURIComponent(key) + '=' + encodeURIComponent(val2); 91 | }).join('&'); 92 | } 93 | 94 | return encodeURIComponent(key) + '=' + encodeURIComponent(val); 95 | }).join('&') : ''; 96 | }; 97 | 98 | // gets the language set in the query string 99 | function getLanguageFromQueryString() { 100 | if (location.search.length >= 1) { 101 | var language = parseURL(location.search).language; 102 | if (language) { 103 | return language; 104 | } else if (jQuery.inArray(location.search.substr(1), languages) != -1) { 105 | return location.search.substr(1); 106 | } 107 | } 108 | 109 | return false; 110 | } 111 | 112 | // returns a new query string with the new language in it 113 | function generateNewQueryString(language) { 114 | var url = parseURL(location.search); 115 | if (url.language) { 116 | url.language = language; 117 | return stringifyURL(url); 118 | } 119 | return language; 120 | } 121 | 122 | // if a button is clicked, add the state to the history 123 | function pushURL(language) { 124 | if (!history) { return; } 125 | var hash = window.location.hash; 126 | if (hash) { 127 | hash = hash.replace(/^#+/, ''); 128 | } 129 | history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash); 130 | 131 | // save language as next default 132 | localStorage.setItem("language", language); 133 | } 134 | 135 | function setupLanguages(l) { 136 | var defaultLanguage = localStorage.getItem("language"); 137 | 138 | languages = l; 139 | 140 | var presetLanguage = getLanguageFromQueryString(); 141 | if (presetLanguage) { 142 | // the language is in the URL, so use that language! 143 | activateLanguage(presetLanguage); 144 | 145 | localStorage.setItem("language", presetLanguage); 146 | } else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) { 147 | // the language was the last selected one saved in localstorage, so use that language! 148 | activateLanguage(defaultLanguage); 149 | } else { 150 | // no language selected, so use the default 151 | activateLanguage(languages[0]); 152 | } 153 | } 154 | 155 | // if we click on a language tab, activate that language 156 | $(function() { 157 | $(".lang-selector a").on("click", function() { 158 | var language = $(this).data("language-name"); 159 | pushURL(language); 160 | activateLanguage(language); 161 | return false; 162 | }); 163 | }); 164 | })(); 165 | -------------------------------------------------------------------------------- /source/javascripts/app/_search.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_lunr 2 | //= require ../lib/_jquery 3 | //= require ../lib/_jquery.highlight 4 | ;(function () { 5 | 'use strict'; 6 | 7 | var content, searchResults; 8 | var highlightOpts = { element: 'span', className: 'search-highlight' }; 9 | var searchDelay = 0; 10 | var timeoutHandle = 0; 11 | 12 | var index = new lunr.Index(); 13 | 14 | index.ref('id'); 15 | index.field('title', { boost: 10 }); 16 | index.field('body'); 17 | index.pipeline.add(lunr.trimmer, lunr.stopWordFilter); 18 | 19 | $(populate); 20 | $(bind); 21 | 22 | function populate() { 23 | $('h1, h2').each(function() { 24 | var title = $(this); 25 | var body = title.nextUntil('h1, h2'); 26 | index.add({ 27 | id: title.prop('id'), 28 | title: title.text(), 29 | body: body.text() 30 | }); 31 | }); 32 | 33 | determineSearchDelay(); 34 | } 35 | function determineSearchDelay() { 36 | if(index.tokenStore.length>5000) { 37 | searchDelay = 300; 38 | } 39 | } 40 | 41 | function bind() { 42 | content = $('.content'); 43 | searchResults = $('.search-results'); 44 | 45 | $('#input-search').on('keyup',function(e) { 46 | var wait = function() { 47 | return function(executingFunction, waitTime){ 48 | clearTimeout(timeoutHandle); 49 | timeoutHandle = setTimeout(executingFunction, waitTime); 50 | }; 51 | }(); 52 | wait(function(){ 53 | search(e); 54 | }, searchDelay ); 55 | }); 56 | } 57 | 58 | function search(event) { 59 | 60 | var searchInput = $('#input-search')[0]; 61 | 62 | unhighlight(); 63 | searchResults.addClass('visible'); 64 | 65 | // ESC clears the field 66 | if (event.keyCode === 27) searchInput.value = ''; 67 | 68 | if (searchInput.value) { 69 | var results = index.search(searchInput.value).filter(function(r) { 70 | return r.score > 0.0001; 71 | }); 72 | 73 | if (results.length) { 74 | searchResults.empty(); 75 | $.each(results, function (index, result) { 76 | var elem = document.getElementById(result.ref); 77 | searchResults.append("
  • " + $(elem).text() + "
  • "); 78 | }); 79 | highlight.call(searchInput); 80 | } else { 81 | searchResults.html('
  • '); 82 | $('.search-results li').text('No Results Found for "' + searchInput.value + '"'); 83 | } 84 | } else { 85 | unhighlight(); 86 | searchResults.removeClass('visible'); 87 | } 88 | } 89 | 90 | function highlight() { 91 | if (this.value) content.highlight(this.value, highlightOpts); 92 | } 93 | 94 | function unhighlight() { 95 | content.unhighlight(highlightOpts); 96 | } 97 | })(); 98 | 99 | -------------------------------------------------------------------------------- /source/javascripts/app/_toc.js: -------------------------------------------------------------------------------- 1 | //= require ../lib/_jquery 2 | //= require ../lib/_imagesloaded.min 3 | ;(function () { 4 | 'use strict'; 5 | 6 | var loaded = false; 7 | 8 | var debounce = function(func, waitTime) { 9 | var timeout = false; 10 | return function() { 11 | if (timeout === false) { 12 | setTimeout(function() { 13 | func(); 14 | timeout = false; 15 | }, waitTime); 16 | timeout = true; 17 | } 18 | }; 19 | }; 20 | 21 | var closeToc = function() { 22 | $(".toc-wrapper").removeClass('open'); 23 | $("#nav-button").removeClass('open'); 24 | }; 25 | 26 | function loadToc($toc, tocLinkSelector, tocListSelector, scrollOffset) { 27 | var headerHeights = {}; 28 | var pageHeight = 0; 29 | var windowHeight = 0; 30 | 31 | var recacheHeights = function() { 32 | headerHeights = {}; 33 | pageHeight = $(document).height(); 34 | windowHeight = $(window).height(); 35 | 36 | $toc.find(tocLinkSelector).each(function() { 37 | var targetId = $(this).attr('href'); 38 | if (targetId[0] === "#") { 39 | headerHeights[targetId] = $(targetId).offset().top; 40 | } 41 | }); 42 | }; 43 | 44 | var refreshToc = function() { 45 | var currentTop = $(document).scrollTop() + scrollOffset; 46 | 47 | if (currentTop + windowHeight >= pageHeight) { 48 | // at bottom of page, so just select last header by making currentTop very large 49 | // this fixes the problem where the last header won't ever show as active if its content 50 | // is shorter than the window height 51 | currentTop = pageHeight + 1000; 52 | } 53 | 54 | var best = null; 55 | for (var name in headerHeights) { 56 | if ((headerHeights[name] < currentTop && headerHeights[name] > headerHeights[best]) || best === null) { 57 | best = name; 58 | } 59 | } 60 | 61 | // Catch the initial load case 62 | if (currentTop == scrollOffset && !loaded) { 63 | best = window.location.hash; 64 | loaded = true; 65 | } 66 | 67 | var $best = $toc.find("[href='" + best + "']").first(); 68 | if (!$best.hasClass("active")) { 69 | // .active is applied to the ToC link we're currently on, and its parent