question

Upvotes
Accepted
1 1 1 4

Redi Trade Automation

Hello All,

I am working on automating our trading based of an excel spreadsheet. We were provided a spreadsheet we can place orders in and click a button, running a macro to send the orders to the Redi Platform.

What we want to do from here is either update the existing macro or create a new one that automatically sends the trades, once all the required fields are populated. In other words once the Macro recognizes the required trade fields are all populated it will automatically trigger the existing macro sending the trades to the Redi system; without actually clicking to send the trades.

Would someone be able to help us either modify the existing macro or create a new one to trigger the existing Macro once the criteria is met?

Thanks!

excelredi-apivbatrade
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
23k 22 9 14

Hello @cisola,

We strive to help, by guiding developers and developer community toward coding, owning and maintaining robust solutions.

The examples that we provide to the community are simple, well-documented, and widely applicable.

We do not code custom use cases to requirements, rather we are willing to help in advisory capacity for you take responsibility for coding and maintaining.

But whenever possible, we try to find a way to help.

Your use case is not simple, as you require:

  1. To react to any change in price
  2. Validate all inputs and create a valid REDI order
  3. Submit order to REDI
  4. Update the worksheet with the result of the latest submission request, whether valid or not

In my understanding, the use case is just complex enough, that there are several ways to approach it. I have coded, as an example, within the code you have included, a version of what I believe your require.

The cornerstones of my approach are:

  • User Defined Function SENDORDERS that is in Module 6 and reacts to changes and submits orders.
  • public variables changeFlag cellToChange and ValueToSet that signal the change out of UDF and allow Status cells to be updated with the results
  • Sub Workbook_SheetCalculate on sheet itself, that updates the status on the sheet

It is very likely that this is not all that you require, or not exactly as you envision, or you would prefer a different approach.

In this case, I hope that the example that you will find attached, will help guide you toward fully implementing to your requirements, next.

-Zoya


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
410 1 0 1

Hi @cisola,

To confirm, does your sheet have a column/cell that says "Trade Now" or "True/False" or anything like that?

-Brian

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Hi @Brian.Mullane

Yes, I included a "Trade Now" cell

-Christian

Upvotes
23k 22 9 14

Hi @cisola,

We'd like to suggest, defining a User Defined Function in Excel

that will verify all the required cells are populated, with the valid values, and trigger as you require.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks, however could you possibly be more specific? I Just need the function to do: IF "Trade now" cell reads "Yes" THEN run "Send Orders" macro.

Upvote
23k 22 9 14

Hi @cisola

Not sure if what I am about to answer is what you are looking for :)

But will try to answer straight-on.

Developer-> View Code
Insert->Module

Type something like:

Function ORDERCOND(Ready) 
  If Ready = "Yes" Then 
    'Copy code from our order example for example 
     Dim hOrder As New OPTIONORDER 
     hOrder.Side = "Buy" 
     hOrder.symbol = "SBUX" 
     hOrder.Type = "Call" 
     hOrder.Date = "Apr '16" 
     '.... 
     b = hOrder.Submit(myerr) 
  End If 
End Function

And save.

When you type "=ORDERCOND" into one of your cells, enter the location of "Trade now" cell, such as

=ORDERCOND(B9)

If you are looking to validate more parameters, before creating the order, just use the same approach, increase the number of parameters into ORDERCOND and run the checks.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Thanks @zoya.farberov We have a macro that sends orders to Redi Unfortunately, to run that macro we need to click a button. Once clicked it takes the information filled in cells(side, symbol, etc.) &sends the order to Redi. We created a way to automatically populate required cells & have a cell that recognizes when all fields are populated ("Trade now"). Once "Trade Now" cell is populated "Yes" we want to automatically run the existing "Send Orders" Macro

something like this?

Function ORDERCOND(Ready)
If Ready = "Yes" Then

'Run Macro "Send Orders"

End If
End Function

Hello @cisola,

The macro that is associated with the button is implemented in code.

Are you able to view the code of the macro?

Do you see in the code the order being populated from the fields and submitted?

Are you able to introduce the check of the cell(s), that you require, into that code, prior to submit?

Hi @zoya.farberov

I have attached the Spreadsheet here, hopefully that works. the macro used is names "ThisWorkbook.SendOrders"... When the "trade now" (column P) is populated "yes" we want to instantly run the "send order" Macro without any human intervention.

Click below to post an Idea Post Idea