Open overstartup opened 3 years ago
Hi Ahmad,
The MovingAverage strategy and it's corresponding UI logic is there to provide an example that can be followed when creating your own custom strategy and corresponding view. A quick option would be to clone it and replace the implementation details with your own custom code. The code can be found in the following projects:
\ In the strategy, subscribe to the relevant feeds e.g. trade, candlestick, statistics etc. See create a strategy for some more information.
\ Provide your own implementation for representing data you want fed back to the UI for rendering on charts etc. See the example in MovingAverage strategy which implements the following:
\
In the view model, provide the necessary logic for translating the data to be rendered in the charts. For an example take a look at the TradeNotificationsAsync
method in MovingAverageViewModel.
\
See create a wpf strategy component for some more information.
\ You will also need to make the necessary changes to the charts in the view so have a look at how MovingAverageView does this. I also suggest looking at Live Charts for examples of how to chart your data. You can also easily replace the live chart component with another one if you prefer.
\ Finally, you will need to configure your account and strategy in the configuration module.
Great, thank you very much.
I have another question, is it possible to have robot trader? You know, I want to have bot to trade features in binance. If you have any suggestion, that will be nice.
The strategy runs on the TradeServer independently of the UI, which means it can act like a 'bot'.
You can create a custom strategy to subscribe to real-time trade feeds, order book, candlestick (if available), statistics and account details and real-time open orders etc. The custom strategy can be configured to run against a specified exchange (e.g. Binance) and you can provide an api key, secret key and, depending on the exchange, an optional pass phrase (e.g. pass phrase is required by Kucoin but not Binance). This will give the strategy access to the account and the ability to place or cancel orders based on your own custom logic i.e. based on real-time decisions your custom logic makes from the feeds the strategy has subscribed to.
Currently Binance and Kucoin API's are supported however, you can extend this to any exchange or add new features an exchange supports.
The TradeView UI simply allows you to do the following:
Note, if you launch a strategy from the UI, you can close the UI and the strategy will continue to run on the TradeServer.
You can also free to write your own custom app for launching a strategy. To do this you will need to understand how the TradeServer works.
Thank you very much.
Could you please give me help to set a strategy?
i got this error:
Why i can not see anything there?
To run a strategy you will need to do the following:
My recommendation is you first get the demo "Moving Average Strategy" working running then you can use that as a template for creating your own.
Here I will share some more information about each of the steps above.
Configuration -> Manage Strategies
The top group box, Strategy Runner, is for configuring the strategy that is run on the trade server, where:
The bottom group box, Strategy Display, is for configuring the WPF component to monitor the strategy is real time (this is what gets rendered in the area that empty in your second screenshot above):
Configuration -> Manage Trade Servers
The Trade Server Name and Uri must correspond to that which is specified for the Trade Server in step 3. below.
This is DevelopmentInProgress.TradeServer.Console application. Have a look at its Program.cs file and note the args which includes the uri and instance name, which is configured in step 2. above. Also look at the Startup.cs in DevelopmentInProgress.TradeServer.StrategyExecution.WebHost to see how the args are used.
Run the Trade Viewer WPF application click on the Strategies Module in the navigation panel and select the strategy.
Select the Trade Server from the trade server drop down list - image below. A green icon shows the trade server (from step 3 above) is running. Then click the Run Strategy button which is the icon to the right of the dropdown.
Put a breakpoint behind the Run Strategy button at RunAsync()
in StrategyRunnerViewModel.cs. You will see the strategy binaries configured in step 1 above, are uploaded to the running instance of the Trade Server via a HttpClient
request:
await httpClient.PostAsync(uri, multipartFormDataContent, cancellationToken).ConfigureAwait(false);
Put a breakpoint in the RunStrategyMiddleware of the trade servers DevelopmentInProgress.TradeServer.StrategyExecution.WebHost to see the incoming request to run the strategy. Step through and you will see the strategy assemblies loaded into memory and the strategy is executed.
Put a breakpoint inside the SubscribeTrades(TradeEventArgs tradeEventArgs)
in the MovingAverageStrategy.cs class and you will see the live trade feed.
Once the demo strategy is working you should see something like:
@overstartup here are some additional suggestions to help you get the demo "Moving Average Strategy" running.
If you are running Visual Studio:
Set the output path for each project to ..\..\output\
.
In the solution's properties, setting the following as startup projects so both the server and WPF app launch at startup.
Here are some default config files. You will need to place the config files in the same folder the binaries are output to e.g. ..\output\netcoreapp3.1
.
REPLACE_WITH_YOUR_USER_NAME_Accounts.txt REPLACE_WITH_YOUR_USER_NAME_Strategies.txt REPLACE_WITH_YOUR_USER_NAME_TradeServers.txt
The config file names starts with your login username so you will need to rename them to be picked up.
var userAccountsFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{Environment.UserName}_Accounts.txt");
var userStrategiesFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{Environment.UserName}_Strategies.txt");
var userServersFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{Environment.UserName}_TradeServers.txt");
Note: the config is set to run the strategy against Binance however, to get started you don't need to have a Binance account as the demo strategy doesn't actually place live orders.
Let me know how you get on.
Thank you very much. i will try it
Hi Grant Colley, I need help to create new strategy, well I need to use 4 EMA, 1 HMA ,MACD and fibo charts in this strategy. Could you please tell me how I can do that? Is it possible to create the logic and view?