If you just want to use CCXT — just install it as a regular package into your project. The CCXT library consists of a public part and a private part. Anyone can use the public part immediately after installation. Public APIs provide unrestricted access to public information for all exchange markets without the need to register a user account or have an API key.
Also, read the Manual for more details. We are investing a significant amount of time into the development of this library. If CCXT made your life easier and you want to help us improve it further, or if you want to speed up development of new features and exchanges, please support us with a tip.
We appreciate all contributions! Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Support this project by becoming a supporter. Your avatar will show up here with a link to your website. Thank you to all our backers! Skip to content. Star 24k. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branches Tags. Could not load branches. Could not load tags. Latest commit. Git stats 51, commits. Failed to load latest commit information. See the following excerpt from the file to see an example:. This tells docker-compose to pull the freqtrade Docker image that contains the correct plotting libraries. These must be defined inside the strategy specified with the -s option. By default, this creates a plotly html file available in the plot directory:. You can view a full version of this interactive plot here.
Hover over the plot to see how the bot actually does what we wanted it to do, as defined by our simple moving average strategy:. To see what else you can do with plot-dataframe , run docker-compose freqtrade plot-dataframe -h or visit the relevant docs. I want to acknowledge freqtrade's helpful, well-written documentation, from which this article has taken much inspiration. I'd like to thank the developers for their effort in creating such an fantastic tool for all of us to use.
Currently he is working as a Research Data Scientist on a Deep Learning based fire risk prediction system. The internet's best data science courses View Courses. Toggle navigation. You are reading tutorials. Author: Ioannis Prapas Data Scientist. How to backtest strategies and trade cryptocurrency with Python using freqtrade. In this first part, you'll see: Freqtrade's basic functionality and crypto-market terms — We'll learn how freqtrade works, how to navigate the command-line tool to download historical market data, create a new configuration file, and a new strategy.
Backtesting a strategy on historical data to determine our strategy's performance — We'll see how to generate full reports, as well as plots to visualize our bot's simulated trades. In the second part, we'll go into more advanced topics, such as: Trading with more coin pairs Understanding and defining Return On Investment ROI and Stoploss Optimizing our strategies Live deployment Suggestions for further improvement. Note Please be aware of freqtrade's disclaimer paraphrased : "This software is for educational purposes only.
Freqtrade is a cryptocurrency algorithmic trading software written in Python. It allows you to: Develop a strategy : easily using Python and pandas. We'll be creating a simple strategy in this article, and you can view freqtrade's example strategies repo. Download market data : quickly download historical price data of the cryptocurrency of your choice. Backtest : test your strategy on historical data.
Backtesting is a critical step to see if your strategy has any chance of making money in the real world. It is not a guarantee for actual performance since market conditions are more complex than the downloaded data. Optimize : find the best parameters for your strategy with hyperopt.
Select coin pairs to trade : your selection can be static or dynamic based on simple filters, such as if trading volume greater than a certain amount. Dry run : test a strategy on live data with a simulated wallet. Live run : deploy a strategy using real money via a crypto exchange's API. This is the last step after you know what you are doing and are willing to lose all your money. Use a Telegram Bot : control and monitor your strategies through Telegram.
Analyze and visualize trading history : utilize trading data from save files or via an SQL database. Ok, let's dive in by starting with the installation. Docker - easiest method for all platforms. You can now set up freqtrade by issuing the following commands in your desired directory:. You should now have the following directory structure:. How do I install freqtrade without Docker?
In my case, using Ubuntu To verify the installation was successful, run freqtrade --help Important Note : If you install freqtrade directly, you won't need to preface your commands with docker-compose run --rm like we have in the remainder of this article. To verify freqtrade is installed correctly and ready for use, issue the help command:.
You should see the following output. Backtesting: How freqtrade tests trading strategies. This initiates a new loop in live runs, while in backtesting, this is needed only once. Here, you can use any exchange that freqtrade supports.
This command generated the file:. Where the columns mean the following: time: Unix timestamp in milliseconds Open: Opening price at the beginning of the candlestick High: Highest price reached during the candlestick Low: Lowest price reached during the candlestick Close: Closing price at the end of the candlestick Volume: Quantity of asset bought or sold, displayed in base currency, in our case ETH.
BTC is the quote currency. This data can be representing neatly in the following candlestick chart:. Source: www. For a brief overview, you can also view Investopedia's article, Understanding Basic Candlestick Charts Now that we've seen an example of the data and understand each row's meaning, let's move on to configuring freqtrade to run our strategy. To create a new config, we run the following command:.
You will see a few initial questions, to which we answered with the following values:. Implementing a simple, custom strategy - Moving Average Crossover. Understanding the strategy. Trading is really very simple, and you only have to do two things right: Buy Low Sell High.
That easy? What's the catch? The tricky thing is to find the actual low and high points. This is called a Moving Average Crossover Strategy. Defining a custom strategy for freqtrade. Now, we can find the newly created file in the strategies folder:. Note The function definitions in this class use type hinting to define argument and return value types. In a similar fashion to the previous function, this function populates our sell signal.
Now that we have a strategy filled out, we can test how it would have performed on past data. The parameters in the above command are as follows:. Duration Winners 51 days, Avg. Duration Loser 17 days, Zero Duration Trades 0. We get a full report that contains the results of all our trades during the specified period. Freqtrade split's the report into four parts: 1.
The most important parts to point out are the following: Trades per day - the average number of closed trades per day. I'm usually looking for strategies that make about ten trades per day. When trading more than one coin-pair, this metric is the average of market changes that all pairs incur, from the beginning to the end of the specified period.
It's crucial to test a strategy in different market conditions, not just upward trending markets. However, this strategy is as simple as it gets and has vast room for improvement: Comparing to buy and hold Just holding ETH, i. In this article, we've seen just a glimpse of what we can do with freqtrade: Define custom strategies using pandas.
Backtest them using historical data and generate relevant reports. Plot results and visualize the simulated trades using plotly.
DataFrame ethusdt df1. Improve this question. Otto Otto 1 1 gold badge 1 1 silver badge 5 5 bronze badges. Add a comment. Sorted by: Reset to default. Highest score default Date modified newest first Date created oldest first. DataFrame self. DateTimeFormat self. Improve this answer. Onsightfree Onsightfree 3 3 silver badges 10 10 bronze badges. Hi SaeidMohammadiNejati, Constants is just a py file i have to store all of static strings etc.
Opentime df. Mike Malyi Mike Malyi 8 8 silver badges 16 16 bronze badges. ChauGiang check that both the timezones are of the same format — isnvi23h4. I even print klines line 6 and found the data is not correct — Chau Giang. Show 3 more comments. Chau Giang Chau Giang 1, 9 9 silver badges 19 19 bronze badges. Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct.
You can find more information on how to write good answers in the help center. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
Will chatbots ever live up to the hype? GitHub Repository dev branch. There's a lot of code here, so I'm just going to review bitex. You'll see that there's plenty here for one review. Maybe some of the other reviewers here at Code Review will review some of your other code.
The name does not make it clear. What does an instance of this class represent? Can you give some examples of how it might be used? There is text in your introduction to the post that could be used as a starting point for the docstring. This gives more flexibility to the logger, for example if logging is suppressed then the message may never need to be formatted.
It is risky to have default arguments for key and secret that are insecure. This would leave the API insecure. It is much better if code can be secure by default. So I would have prefer to have default arguments that are invalid. The repetition in the construction of self. It is the path to a text file whose first two lines are the key and the secret respectively.
The second argument to open defaults to 'r' , so this could be omitted. Basing a nonce only on the output of time. The sign method is insecure by default. It would be easy to forget to override it, and then nothing would appear to go wrong, but all the signatures would be bogus. It would be better to be secure by default. A good way to do that would be to use the facilities from the abc Abstract Base Classes module:.
The docstring for the query method does not explain what the arguments mean, or what is returned. What if someone needs to query an API that needs a longer timeout than this? The value should be a keyword argument to the query function or possibly an attribute of the class or object.
Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Start collaborating and sharing organizational knowledge. Create a free Team Why Teams? Learn more. Asked 5 years, 4 months ago. Modified 4 years, 2 months ago. Viewed 1k times. Why I am submitting this for review Ever since I started this project, I've rewritten the base code several times significantly. Round: flaws, improvements in code and logic, bugs, etc.
Review Round 2: Refactoring and Layout I have especially my worries about the bitex. Override this in child. URL is required to be returned, as some Signatures use the url for sig generation, and api calls made must match the address exactly. Defaults to unauthenticated query.
HTTPError as e: log. Improve this question. Add a comment. Sorted by: Reset to default. Highest score default Date modified newest first Date created oldest first. There is no module docstring. What is the purpose of this module? What does it contain? The method nonce has no docstring.
Python Cryptobot Binance source. Thanks for your great videos. I was inspired them and started my own crypto-bot project! So, I think may be it is better to use condition statement instead of infinite loop for example : while len self. If you check the CCXT library, it provides common interface to many different exchanges.
Keep up the great work! Could you please make a tutorial on how to write a bot for binance spot, so that through the webhook trading view it can alert when to buy and sell based on the indicator. In my case it would be the MarketLiberator indicator. And how to put it on the server? Hi, love your content and looking forward to the next one with the indicators calculated over a longer timeframe. Danke sir! Can you make a video how to make a logarithmic regression for btc and adding a heatmap on the chart.
Algovibes July 22, 13 1 minute read. Data from the API includes current prices for Bitcoin as well as over 6, altcoins with trading volume, historical records, and additional crypto exchange resources. Sign up for a free account at RapidAPI to access this service and generate a free API key that you can use when building custom software applications. The company first published global reports on the cryptocurrency marketplace with a focus on real-time insights.
The company has over 10 million users and delivers more than 10 billion API calls every month in support of cryptocurrency trading apps. The CoinGecko API has multiple endpoints that allow developers to ping the service and retrieve information about coins, exchanges, status updates, events, exchange rates, or global variables. The service currently supports over 6, cryptocurrency coins and trading exchanges. The CoinGecko API allows websites and mobile applications to include comprehensive historical data from crypto price records into their displays.
The CoinGecko API service supports cryptocurrency wallets, DeFi applications, block explorers, data aggregators, professional media services, and other innovative crypto trading platforms. The CoinGecko API is a comprehensive resource supporting both real-time and historical price discovery for cryptocurrency trading applications. CoinGecko offers a wider platform of cryptocurrency resources which includes reports on different coins and exchanges, as well as portfolio management and wallet information.
The service now also supports DeFi and yield farming. Decentralized finance or DeFi coins are used by traders to swap between different coin exchanges. CoinGecko records the historical price, volume, and market capitalization of these coins, as well as those used by various NFT platforms like Theta, Chiliz, Enjin, Decentraland, Rarible, etc. Crypto App Development : Build data-driven visualizations with rich chart displays for customized crypto trading applications on web and mobile with any UI framework.
The service is relied on by decentralized finance applications like Curve, Chainlink, Kyber Network, Zapper. With Swagger Codegen, client libraries in over 40 programming languages are implemented. Developers can utilize the service with RapidAPI keys for preferential connections. The free service supports up to queries per minute.
Sign up for a free account at RapidAPI to use the platform. The contents of the CoinGecko swagger. The commands listed above can be used to retrieve information from the CoinGecko API to build the required functionality for customizing cryptocurrency websites and mobile applications. Developers can use the code snippets below or widgets.
CoinGecko API Endpoints: Get coin history, status charts, market information, trading ranges, historical statistics, and other real-time updates for altcoin trading applications. These include cryptocurrency wallets, trading portals, banks, discovery applications, decentralized finance platforms, yield farming utilities, and NFT galleries.
RapidAPI users can take advantage of the platform for scripting and connection services. Developers can access free real-time and historical cryptocurrency market data such as price, market cap, volume, developer stats, social activity, and more. The CodeGecko API has code snippets available for 19 of the most popular programming languages for web design and mobile app development. Insert the custom parameters for each cryptocurrency coin or exchange to complete the template.
There are over 20 endpoints for the API, where each endpoint can be invoked by multiple different methods with each programming language. Choose the particular method from the RapidAPI interface that best suits your existing codebase or programming preference and style. Which one is chosen is determined by the personal preferences of the programmer.
At the current time, this includes 6, coins. Search the list for the token ID you need for the support of specific cryptocurrency coins in applications. Save these values for other API queries to support price discovery.
To retrieve a similar list of supported cryptocurrency exchanges, use the code:.
Binance has established itself as a market leader when it comes to cryptocurrency trading. It currently. As an example I have used WazirX, which is one of the crypto trading exchanges. They provide APIs to perform the trade and since I have an account in WazirX. Live run: deploy a strategy using real money via a crypto exchange's API. This is the last step after you know what you are doing and are willing to lose.